core: fix build failed in big-endian system (#117)

Close #40
This commit is contained in:
tobiichi3227 2023-12-26 01:08:13 +08:00 committed by GitHub
parent f8cab3c370
commit ef0e051255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -4,10 +4,6 @@
#include <sys/types.h>
#include <unistd.h>
#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
#error "your system is not little endian, jpeg will not work, ping vaxry or something"
#endif
cairo_surface_t* JPEG::createSurfaceFromJPEG(const std::string& path) {
if (!std::filesystem::exists(path)) {
@ -44,7 +40,11 @@ cairo_surface_t* JPEG::createSurfaceFromJPEG(const std::string& path) {
jpeg_mem_src(&decompressStruct, (const unsigned char*)imageRawData, fileInfo.st_size);
jpeg_read_header(&decompressStruct, true);
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
decompressStruct.out_color_space = JCS_EXT_BGRA;
#else
decompressStruct.out_color_space = JCS_EXT_ARGB;
#endif
// decompress
jpeg_start_decompress(&decompressStruct);

View file

@ -52,11 +52,11 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::string& path) {
}
if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
config.output.colorspace = MODE_bgrA;
else
config.output.colorspace = MODE_Argb;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
config.output.colorspace = MODE_bgrA;
#else
config.output.colorspace = MODE_Argb;
#endif
const auto CAIRODATA = cairo_image_surface_get_data(cairoSurface);
const auto CAIROSTRIDE = cairo_image_surface_get_stride(cairoSurface);