Menu ▾ ▴

#97 Explicit definition of endianness and color order

None
closed
None
5
2015-03-15
2014-12-01
No

Hi Hervé,

currently, FREEIMAGE_COLORORDER is hard linked to FREEIMAGE_BIGENDIAN. There are cases in which one needs to specify color order and endianness explicitly. So, in order to offer this, could you please replace lines 72 to 87 in FreeImage.h with these lines:

// Endianness:
// Some versions of gcc may have BYTE_ORDER or __BYTE_ORDER defined.
// If your big endian system isn't being detected, add an OS specific check
// or define any of FREEIMAGE_BIGENDIAN and FREEIMAGE_LITTLEENDIAN directly
// to specify the desired endianness.
#if (!defined(FREEIMAGE_BIGENDIAN) && !defined(FREEIMAGE_LITTLEENDIAN))
#if (defined(BYTE_ORDER) && BYTE_ORDER==BIG_ENDIAN) || \
    (defined(__BYTE_ORDER) && __BYTE_ORDER==__BIG_ENDIAN) || \
    defined(__BIG_ENDIAN__)
#define FREEIMAGE_BIGENDIAN
#endif // BYTE_ORDER
#endif // !FREEIMAGE_[BIG|LITTLE]ENDIAN

// Color-Order:
// The specified order of color components red, green and blue affects 24-
// and 32-bit images of type FIT_BITMAP as well as the colors that are part
// of a color palette. All other images always use RGB order. By default,
// color order is coupled to endianness:
// little-endian -> BGR
// big-endian    -> RGB
// However, you can always define FREEIMAGE_COLORORDER to any of the known
// orders FREEIMAGE_COLORORDER_BGR (0) and FREEIMAGE_COLORORDER_RGB (1) to
// specify your preferred color order.
#define FREEIMAGE_COLORORDER_BGR    0
#define FREEIMAGE_COLORORDER_RGB    1
#if (!defined(FREEIMAGE_COLORORDER)) || \
    ((FREEIMAGE_COLORORDER != FREEIMAGE_COLORORDER_BGR) && \
     (FREEIMAGE_COLORORDER != FREEIMAGE_COLORORDER_RGB))
#if defined(FREEIMAGE_BIGENDIAN)
#define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_RGB
#else
#define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_BGR
#endif // FREEIMAGE_BIGENDIAN
#endif // FREEIMAGE_COLORORDER

Discussion

  • Hervé Drolon

    Hervé Drolon - 2015-02-19
    • status: open --> pending
    • Group: -->
     
  • Hervé Drolon

    Hervé Drolon - 2015-02-19

    Hi Carsten,

    These #defines have been added to the FreeImage.h file and are now available in the CVS.

    Hervé

     
  • Hervé Drolon

    Hervé Drolon - 2015-03-15

    fixed in release 3.17.0

     
  • Hervé Drolon

    Hervé Drolon - 2015-03-15
    • status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel