update ConvertImage
This commit is contained in:
parent
f64a3fd1ce
commit
518367b8eb
@ -7,23 +7,29 @@ add_definitions(-DUNICODE -D_UNICODE)
|
||||
include_directories("DevIL Windows SDK/include")
|
||||
link_directories("DevIL Windows SDK/lib/x64/unicode/Release")
|
||||
|
||||
set(SOURCE_FILE main.cpp pixel_format.cpp
|
||||
ILImage.h
|
||||
ILImageSupport.cpp
|
||||
ConvertImage.cpp
|
||||
TextureFileCreater.h
|
||||
TextureFileCreater.cpp
|
||||
TextureFileCreaterR.cpp
|
||||
TextureFileCreaterRG.cpp
|
||||
TextureFileCreaterRGB.cpp
|
||||
TextureFileCreaterRGBA.cpp)
|
||||
SET(ILIMAGE_SOURCE ILImage.h
|
||||
ILImageSupport.cpp)
|
||||
|
||||
set(HEADER_FILE pixel_format.h ConvertImage.h)
|
||||
SET(PIXEL_FORMAT_SOURCE pixel_format.cpp
|
||||
pixel_format.h)
|
||||
|
||||
SOURCE_GROUP("Header Files" FILES ${HEADER_FILE})
|
||||
SOURCE_GROUP("Source Files" FILES ${SOURCE_FILE})
|
||||
SET(TEXTURE_FILE_CREATER_SOURCE TextureFileCreater.h
|
||||
TextureFileCreater.cpp
|
||||
TextureFileCreaterR.cpp
|
||||
TextureFileCreaterRG.cpp
|
||||
TextureFileCreaterRGB.cpp
|
||||
TextureFileCreaterRGBA.cpp)
|
||||
|
||||
add_executable(TexConv ${SOURCE_FILE} ${HEADER_FILE})
|
||||
set(SOURCE_FILE main.cpp
|
||||
ConvertImage.cpp)
|
||||
|
||||
set(HEADER_FILE )
|
||||
|
||||
SOURCE_GROUP("Image File" FILES ${ILIMAGE_SOURCE})
|
||||
SOURCE_GROUP("Pixel Format" FILES ${PIXEL_FORMAT_SOURCE})
|
||||
SOURCE_GROUP("Texture File Creater" FILES ${TEXTURE_FILE_CREATER_SOURCE})
|
||||
|
||||
add_executable(TexConv ${SOURCE_FILE} ${ILIMAGE_SOURCE} ${PIXEL_FORMAT_SOURCE} ${TEXTURE_FILE_CREATER_SOURCE})
|
||||
|
||||
target_link_libraries(TexConv PRIVATE DevIL)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include"ConvertImage.h"
|
||||
#include<hgl/log/LogInfo.h>
|
||||
#include"ILImage.h"
|
||||
#include"TextureFileCreater.h"
|
||||
|
||||
@ -7,45 +7,25 @@ TextureFileCreater *CreateTextureFileCreaterRG(const PixelFormat *,ILImage *);
|
||||
TextureFileCreater *CreateTextureFileCreaterRGB(const PixelFormat *,ILImage *);
|
||||
TextureFileCreater *CreateTextureFileCreaterRGBA(const PixelFormat *,ILImage *);
|
||||
|
||||
ConvertImage::ConvertImage()
|
||||
bool ConvertImage(const OSString &filename,const PixelFormat **pf)
|
||||
{
|
||||
image=nullptr;
|
||||
}
|
||||
ILImage image;
|
||||
|
||||
ConvertImage::~ConvertImage()
|
||||
{
|
||||
SAFE_CLEAR(image);
|
||||
}
|
||||
LOG_INFO(OS_TEXT("File: ")+filename);
|
||||
|
||||
bool ConvertImage::Load(const OSString &fn)
|
||||
{
|
||||
LOG_INFO(OS_TEXT("File: ")+fn);
|
||||
|
||||
image=new ILImage();
|
||||
|
||||
if(!image->LoadFile(fn))
|
||||
{
|
||||
delete image;
|
||||
if(!image.LoadFile(filename))
|
||||
return(false);
|
||||
}
|
||||
|
||||
filename=fn;
|
||||
image.Bind();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool ConvertImage::Convert(const PixelFormat **pf)
|
||||
{
|
||||
image->Bind();
|
||||
|
||||
const uint channels=image->channels();
|
||||
const uint channels=image.channels();
|
||||
|
||||
TextureFileCreater *tex_file_creater;
|
||||
|
||||
if(channels==1)tex_file_creater=CreateTextureFileCreaterR(pf[0],image);else
|
||||
if(channels==2)tex_file_creater=CreateTextureFileCreaterRG(pf[1],image);else
|
||||
if(channels==3)tex_file_creater=CreateTextureFileCreaterRGB(pf[2],image);else
|
||||
if(channels==4)tex_file_creater=CreateTextureFileCreaterRGBA(pf[3],image);else
|
||||
if(channels==1)tex_file_creater=CreateTextureFileCreaterR(pf[0],&image);else
|
||||
if(channels==2)tex_file_creater=CreateTextureFileCreaterRG(pf[1],&image);else
|
||||
if(channels==3)tex_file_creater=CreateTextureFileCreaterRGB(pf[2],&image);else
|
||||
if(channels==4)tex_file_creater=CreateTextureFileCreaterRGBA(pf[3],&image);else
|
||||
{
|
||||
LOG_ERROR(OS_TEXT("image format don't support "));
|
||||
return(false);
|
||||
@ -69,3 +49,4 @@ bool ConvertImage::Convert(const PixelFormat **pf)
|
||||
delete tex_file_creater;
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/BaseString.h>
|
||||
#include<hgl/log/LogInfo.h>
|
||||
#include"pixel_format.h"
|
||||
|
||||
using namespace hgl;
|
||||
|
||||
class ILImage;
|
||||
|
||||
class ConvertImage
|
||||
{
|
||||
OSString filename;
|
||||
|
||||
ILImage *image;
|
||||
|
||||
private:
|
||||
|
||||
bool CreateTextureFile(const PixelFormat *);
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
ConvertImage();
|
||||
~ConvertImage();
|
||||
|
||||
bool Load(const OSString &fn);
|
||||
bool Convert(const PixelFormat **);
|
||||
};//class ConvertImage
|
10
main.cpp
10
main.cpp
@ -6,7 +6,7 @@
|
||||
#include<hgl/Time.h>
|
||||
#include<hgl/filesystem/EnumFile.h>
|
||||
#include<hgl/log/LogInfo.h>
|
||||
#include"ConvertImage.h"
|
||||
#include"pixel_format.h"
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::filesystem;
|
||||
@ -20,6 +20,8 @@ bool gen_mipmaps =false; //是否产生mipmaps
|
||||
bool use_color_key =false; //是否使用ColorKey
|
||||
uint8 color_key[3]; //ColorKey颜色
|
||||
|
||||
bool ConvertImage(const OSString &filename,const PixelFormat **pf);
|
||||
|
||||
const PixelFormat *ParseParamFormat(const CmdParse &cmd,const os_char *flag,const PixelFormat *default_format)
|
||||
{
|
||||
OSString fmtstr;
|
||||
@ -74,11 +76,7 @@ protected:
|
||||
|
||||
void ProcFile(EnumFileConfig *efc,FileInfo &fi) override
|
||||
{
|
||||
ConvertImage ci;
|
||||
|
||||
if(!ci.Load(fi.fullname))return;
|
||||
|
||||
if(!ci.Convert(pixel_fmt))return;
|
||||
ConvertImage(fi.fullname,pixel_fmt);
|
||||
}
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user