Skip to content

Commit

Permalink
Updates FreeImageRe -> Support of RGB(A)32 images
Browse files Browse the repository at this point in the history
  • Loading branch information
agruzdev committed Jul 2, 2023
1 parent 18814be commit ae5b567
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
22 changes: 21 additions & 1 deletion 3rdParty/freeimage/include/FreeImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,24 @@ typedef struct tagFIRGBA16 {
WORD alpha;
} FIRGBA16;


/** 96-bit RGB
*/
typedef struct tagFIRGB32 {
DWORD red;
DWORD green;
DWORD blue;
} FIRGB32;

/** 128-bit RGBA
*/
typedef struct tagFIRGBA32 {
DWORD red;
DWORD green;
DWORD blue;
DWORD alpha;
} FIRGBA32;

/** 96-bit RGB Float
*/
typedef struct tagFIRGBF {
Expand Down Expand Up @@ -429,7 +447,9 @@ FI_ENUM(FREE_IMAGE_TYPE) {
FIT_RGB16 = 9, //! 48-bit RGB image : 3 x 16-bit
FIT_RGBA16 = 10, //! 64-bit RGBA image : 4 x 16-bit
FIT_RGBF = 11, //! 96-bit RGB float image : 3 x 32-bit IEEE floating point
FIT_RGBAF = 12 //! 128-bit RGBA float image : 4 x 32-bit IEEE floating point
FIT_RGBAF = 12, //! 128-bit RGBA float image : 4 x 32-bit IEEE floating point
FIT_RGB32 = 13, //! 96-bit RGB image : 3 x 32-bit
FIT_RGBA32 = 14 //! 128-bit RGBA image : 4 x 32-bit
};

/** Image color type used in FreeImage.
Expand Down
Binary file modified 3rdParty/freeimage/lib/linux64/libFreeImage.so
Binary file not shown.
Binary file modified 3rdParty/freeimage/lib/win64/FreeImage.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions src/FreeImageExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ const char* FreeImageExt_DescribeImageType(FIBITMAP* dib)
case FIT_RGB16:
return "RGB16";

case FIT_RGBA32:
return "RGBA32";

case FIT_RGB32:
return "RGB32";

case FIT_UINT16:
return "Greyscale 16bit";

Expand Down
8 changes: 8 additions & 0 deletions src/Pixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ bool Pixel::getBitmapPixel(FIBITMAP* src, uint32_t y, uint32_t x, Pixel* pixel)
pixel->repr = pixelToString3<FIRGB16>(rawPixel);
break;

case FIT_RGBA32:
pixel->repr = pixelToString4<FIRGBA32>(rawPixel);
break;

case FIT_RGB32:
pixel->repr = pixelToString3<FIRGB32>(rawPixel);
break;

case FIT_UINT16:
pixel->repr = pixelToString1<uint16_t>(rawPixel);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,14 @@ ImageFrame Player::cvtToInternalType(FIBITMAP* src, bool & dstNeedUnload)
break;

case FIT_RGBA16:
assert(bpp == 64);
case FIT_RGBA32:
frame.flags = FrameFlags::eHRD | FrameFlags::eRGB;
frame.bmp = FreeImage_ConvertToRGBAF(src);
dstNeedUnload = true;
break;

case FIT_RGB16:
assert(bpp == 48);
case FIT_RGB32:
frame.flags = FrameFlags::eHRD | FrameFlags::eRGB;
frame.bmp = FreeImage_ConvertToRGBF(src);
dstNeedUnload = true;
Expand Down

0 comments on commit ae5b567

Please sign in to comment.