Compare commits

..

No commits in common. "f9f6209309335433ab9e5ea85525fc3ba6a64b98" and "f1535d3290f19840745321b672fdc0eb05051dcf" have entirely different histories.

10 changed files with 32 additions and 1248 deletions

View File

@ -221,7 +221,6 @@ SOURCES += \
../../../modules/imgfmt/HGPng.cpp \
../../../modules/imgfmt/HGPnm.cpp \
../../../modules/imgfmt/HGTiff.cpp \
../../../modules/imgfmt/dllmain.cpp \
../../../utility/HGString.cpp
HEADERS += \

View File

@ -3089,7 +3089,6 @@ static HGResult CopyImageWithBinary(HGImageImpl *srcImageImpl, HGImageImpl *dest
pDestEx[(destImageImpl->m_left + j) * 4] = (0 == value) ? 0 : 255;
pDestEx[(destImageImpl->m_left + j) * 4 + 1] = (0 == value) ? 0 : 255;
pDestEx[(destImageImpl->m_left + j) * 4 + 2] = (0 == value) ? 0 : 255;
pDestEx[(destImageImpl->m_left + j) * 4 + 3] = 255;
}
}
}
@ -3284,8 +3283,6 @@ HGResult HGAPI HGBase_CopyImage(HGImage image, HGImage destImage)
while (pEx < pExEnd)
{
pDestEx[0] = pDestEx[1] = pDestEx[2] = *pEx;
if (HGBASE_IMGTYPE_RGBA == destType || HGBASE_IMGTYPE_BGRA == destType)
pDestEx[3] = 255;
++pEx;
pDestEx += destChannels;
}
@ -3351,8 +3348,6 @@ HGResult HGAPI HGBase_CopyImage(HGImage image, HGImage destImage)
pDestEx[0] = pEx[0];
pDestEx[1] = pEx[1];
pDestEx[2] = pEx[2];
if (HGBASE_IMGTYPE_RGBA == destType || HGBASE_IMGTYPE_BGRA == destType)
pDestEx[3] = 255;
pEx += channels;
pDestEx += destChannels;
@ -3382,13 +3377,6 @@ HGResult HGAPI HGBase_CopyImage(HGImage image, HGImage destImage)
pDestEx[2] = pEx[0];
pDestEx[1] = pEx[1];
pDestEx[0] = pEx[2];
if (HGBASE_IMGTYPE_RGBA == destType || HGBASE_IMGTYPE_BGRA == destType)
{
if (HGBASE_IMGTYPE_RGBA == type || HGBASE_IMGTYPE_BGRA == type)
pDestEx[3] = pEx[3];
else
pDestEx[3] = 255;
}
pEx += channels;
pDestEx += destChannels;

View File

@ -21,7 +21,12 @@ static HGResult FBITMAPToHGImage(FIBITMAP *dib, HGUInt imgType, HGUInt imgOrigin
assert(NULL != dib);
assert(NULL != image);
BYTE *data = FreeImage_GetBits(dib);
HGUInt width = FreeImage_GetWidth(dib);
HGUInt height = FreeImage_GetHeight(dib);
HGUInt bpp = FreeImage_GetBPP(dib);
HGUInt pitch = FreeImage_GetPitch(dib);
if (0 == imgType)
{
imgType = HGBASE_IMGTYPE_RGB;
@ -39,10 +44,10 @@ static HGResult FBITMAPToHGImage(FIBITMAP *dib, HGUInt imgType, HGUInt imgOrigin
}
HGImageInfo imgInfo;
imgInfo.width = FreeImage_GetWidth(dib);
imgInfo.height = FreeImage_GetHeight(dib);
imgInfo.width = width;
imgInfo.height = height;
imgInfo.type = 0;
imgInfo.widthStep = FreeImage_GetPitch(dib);
imgInfo.widthStep = pitch;
imgInfo.origin = HGBASE_IMGORIGIN_BOTTOM;
if (1 == bpp)
@ -56,7 +61,7 @@ static HGResult FBITMAPToHGImage(FIBITMAP *dib, HGUInt imgType, HGUInt imgOrigin
if (0 != imgInfo.type)
{
HGResult ret = HGBase_CreateImageFromData(FreeImage_GetBits(dib), &imgInfo, NULL, imgType, imgOrigin, image);
HGResult ret = HGBase_CreateImageFromData(data, &imgInfo, NULL, imgType, imgOrigin, image);
if (HGBASE_ERR_OK == ret)
{
HGBase_SetImageDpi(*image, (HGUInt)((double)FreeImage_GetDotsPerMeterX(dib) / 39.3700787 + 0.5),
@ -72,14 +77,17 @@ static HGResult FBITMAPToHGImage(FIBITMAP *dib, HGUInt imgType, HGUInt imgOrigin
return HGBASE_ERR_FAIL;
}
HGImageInfo imgInfo2;
imgInfo2.width = FreeImage_GetWidth(dib2);
imgInfo2.height = FreeImage_GetHeight(dib2);
imgInfo2.type = HGBASE_IMGTYPE_BGRA;
imgInfo2.widthStep = FreeImage_GetPitch(dib2);
imgInfo2.origin = HGBASE_IMGORIGIN_BOTTOM;
data = FreeImage_GetBits(dib2);
width = FreeImage_GetWidth(dib2);
height = FreeImage_GetHeight(dib2);
pitch = FreeImage_GetPitch(dib2);
HGResult ret = HGBase_CreateImageFromData(FreeImage_GetBits(dib2), &imgInfo2, NULL, imgType, imgOrigin, image);
imgInfo.width = width;
imgInfo.height = height;
imgInfo.type = HGBASE_IMGTYPE_BGRA;
imgInfo.widthStep = pitch;
imgInfo.origin = HGBASE_IMGORIGIN_BOTTOM;
HGResult ret = HGBase_CreateImageFromData(data, &imgInfo, NULL, imgType, imgOrigin, image);
if (HGBASE_ERR_OK == ret)
{
HGBase_SetImageDpi(*image, (HGUInt)((double)FreeImage_GetDotsPerMeterX(dib2) / 39.3700787 + 0.5),
@ -90,29 +98,19 @@ static HGResult FBITMAPToHGImage(FIBITMAP *dib, HGUInt imgType, HGUInt imgOrigin
return ret;
}
static HGResult HGImageToFIBITMAP(HGImage image, FREE_IMAGE_FORMAT fif, FIBITMAP **dib)
static HGResult HGImageToFIBITMAP(HGImage image, FIBITMAP **dib)
{
assert(NULL != image);
assert(NULL != dib);
HGImage image2 = image;
HGImage image2 = NULL;
HGImageInfo imgInfo;
HGBase_GetImageInfo(image2, &imgInfo);
if ((HGBASE_IMGTYPE_RGB == imgInfo.type) || (HGBASE_IMGTYPE_RGBA == imgInfo.type)
|| (HGBASE_IMGTYPE_BINARY == imgInfo.type && FIF_TARGA == fif))
HGBase_GetImageInfo(image, &imgInfo);
if (HGBASE_IMGTYPE_RGB == imgInfo.type || HGBASE_IMGTYPE_RGBA == imgInfo.type)
{
HGUInt type = HGBASE_IMGTYPE_BGR;
if (HGBASE_IMGTYPE_RGBA == imgInfo.type)
type = HGBASE_IMGTYPE_BGRA;
else if (HGBASE_IMGTYPE_BINARY == imgInfo.type && FIF_TARGA == fif)
type = HGBASE_IMGTYPE_GRAY;
HGImageRoi imageRoi;
HGBase_GetImageROI(image, &imageRoi);
HGBase_ResetImageROI(image);
HGResult ret = HGBase_CloneImage(image, type, imgInfo.origin, &image2);
HGBase_SetImageROI(image, &imageRoi);
HGResult ret = HGBase_CloneImage(image, (HGBASE_IMGTYPE_RGB == imgInfo.type ? HGBASE_IMGTYPE_BGR : HGBASE_IMGTYPE_BGRA),
imgInfo.origin, &image2);
if (HGBASE_ERR_OK != ret)
{
return ret;
@ -120,6 +118,10 @@ static HGResult HGImageToFIBITMAP(HGImage image, FREE_IMAGE_FORMAT fif, FIBITMAP
HGBase_GetImageInfo(image2, &imgInfo);
}
else
{
image2 = image;
}
HGByte *data = NULL;
HGBase_GetImageData(image2, &data);
@ -136,7 +138,7 @@ static HGResult HGImageToFIBITMAP(HGImage image, FREE_IMAGE_FORMAT fif, FIBITMAP
else
assert(HGBASE_IMGTYPE_BINARY == imgInfo.type);
*dib = FreeImage_ConvertFromRawBitsEx(TRUE, data, FIT_BITMAP, imgInfo.width, imgInfo.height, imgInfo.widthStep,
*dib = FreeImage_ConvertFromRawBits(data, imgInfo.width, imgInfo.height, imgInfo.widthStep,
bpp, 0, 0, 0, (HGBASE_IMGORIGIN_TOP == imgInfo.origin));
if (NULL != *dib)
{
@ -251,7 +253,7 @@ static HGResult SaveFIImage(HGImage image, const HGImgFmtSaveInfo* info, const H
}
FIBITMAP *dib = NULL;
HGResult ret = HGImageToFIBITMAP(image, fif, &dib);
HGResult ret = HGImageToFIBITMAP(image, &dib);
if (HGBASE_ERR_OK != ret)
{
return ret;

View File

@ -1,42 +0,0 @@
#include "../base/HGDef.h"
#if defined(HG_CMP_MSC)
#include "FreeImage.h"
#endif
#if defined(HG_CMP_MSC)
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
FreeImage_Initialise();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
FreeImage_DeInitialise();
break;
}
return TRUE;
}
#else
void __attribute__((constructor)) global_load(void);
void __attribute__((destructor)) global_unload(void);
void global_load(void)
{
}
void global_unload(void)
{
}
#endif

Binary file not shown.

File diff suppressed because it is too large Load Diff