mirror of
https://github.com/simtactics/niotso.git
synced 2025-07-04 13:47:05 -04:00
Fixed the build system for Linux
This commit is contained in:
parent
aa50ab78ec
commit
6393955683
11 changed files with 103 additions and 43 deletions
|
@ -28,7 +28,7 @@ if(WIN32)
|
|||
set(FILEHANDLER_SOURCES ${FILEHANDLER_SOURCES} resource.rc)
|
||||
endif()
|
||||
|
||||
include_directories(${FILEHANDLER_INCLUDE_DIR} ${LIBMPG123_INCLUDE_DIR} ${LIBJPEGTURBO_INCLUDE_DIR} ${LIBPNG_INCLUDE_DIR})
|
||||
include_directories(${FILEHANDLER_INCLUDE} ${LIBMPG123_INCLUDE} ${LIBJPEGTURBO_INCLUDE} ${LIBPNG_INCLUDE})
|
||||
|
||||
#### Static library (uncomment to build)
|
||||
#add_library(FileHandler_static STATIC ${FILEHANDLER_SOURCES})
|
||||
|
@ -38,12 +38,15 @@ include_directories(${FILEHANDLER_INCLUDE_DIR} ${LIBMPG123_INCLUDE_DIR} ${LIBJPE
|
|||
# CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
add_library(FileHandler_shared SHARED ${FILEHANDLER_SOURCES})
|
||||
if(WIN32)
|
||||
set_target_properties(FileHandler_shared PROPERTIES OUTPUT_NAME "FileHandler${FILEHANDLER_SERIES}")
|
||||
else()
|
||||
set_target_properties(FileHandler_shared PROPERTIES OUTPUT_NAME "FileHandler")
|
||||
endif()
|
||||
set_target_properties(FileHandler_shared PROPERTIES
|
||||
OUTPUT_NAME "FileHandler${FILEHANDLER_SERIES}"
|
||||
VERSION ${FILEHANDLER_SERIES}${FILEHANDLER_MAJOR}.${FILEHANDLER_MINOR}.0
|
||||
SOVERSION ${FILEHANDLER_SERIES}${FILEHANDLER_MAJOR}
|
||||
VERSION ${FILEHANDLER_SERIES}.${FILEHANDLER_MAJOR}.${FILEHANDLER_MINOR}
|
||||
PREFIX ""
|
||||
IMPORT_PREFIX ""
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
target_link_libraries(FileHandler_shared far_static iff_static jpegturbo_static libmpg123_static libpng_static zlib_static m)
|
||||
target_link_libraries(FileHandler_shared far_static iff_static ${LIBJPEG_LINK} ${LIBMPG123_LINK} ${LIBPNG_LINK} ${ZLIB_LINK} m)
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
*/
|
||||
|
||||
#include "FileHandler.hpp"
|
||||
#include <setjmp.h> //Used by libpng
|
||||
#include <setjmp.h> //Used for libpng
|
||||
#include <jpeglib.h>
|
||||
#include <jerror.h>
|
||||
#include <png.h>
|
||||
#include "bmp/read_bmp.h"
|
||||
|
||||
|
@ -117,13 +118,44 @@ static uint8_t * ReadBMP(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
|||
return OutData;
|
||||
}
|
||||
|
||||
|
||||
// libjpeg-turbo v6 doesn't support jpeg_mem_src, so we have to implement it here
|
||||
static void term_source(j_decompress_ptr){}
|
||||
static int fill_mem_input_buffer(j_decompress_ptr cinfo){
|
||||
ERREXIT(cinfo, JERR_FILE_READ);
|
||||
return FALSE;
|
||||
}
|
||||
static void skip_input_data(j_decompress_ptr cinfo, long bytes)
|
||||
{
|
||||
struct jpeg_source_mgr * src = cinfo->src;
|
||||
|
||||
if(bytes > (long) src->bytes_in_buffer){
|
||||
ERREXIT(cinfo, JERR_FILE_READ);
|
||||
return;
|
||||
}
|
||||
src->next_input_byte += bytes;
|
||||
src->bytes_in_buffer -= bytes;
|
||||
}
|
||||
static uint8_t * ReadJPG(Image_t * Image, const uint8_t * InData, size_t FileSize){
|
||||
//Initialize
|
||||
jpeg_decompress_struct cinfo;
|
||||
jpeg_error_mgr jerr;
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
jpeg_create_decompress(&cinfo);
|
||||
jpeg_mem_src(&cinfo, (unsigned char*) InData, FileSize);
|
||||
|
||||
if (cinfo.src == NULL)
|
||||
cinfo.src = (jpeg_source_mgr *)
|
||||
(*cinfo.mem->alloc_small)((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof(jpeg_source_mgr));
|
||||
|
||||
jpeg_source_mgr *src = cinfo.src;
|
||||
src->init_source = term_source;
|
||||
src->fill_input_buffer = fill_mem_input_buffer;
|
||||
src->skip_input_data = skip_input_data;
|
||||
src->resync_to_restart = jpeg_resync_to_restart;
|
||||
src->term_source = term_source;
|
||||
src->bytes_in_buffer = FileSize;
|
||||
src->next_input_byte = InData;
|
||||
|
||||
if(jpeg_read_header(&cinfo, TRUE) != JPEG_HEADER_OK){
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return NULL;
|
||||
|
@ -174,8 +206,8 @@ struct pngdata_t {
|
|||
static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length){
|
||||
pngdata_t *pngdata = (pngdata_t *) png_get_io_ptr(png_ptr);
|
||||
if(length > pngdata->size) png_error(png_ptr, "");
|
||||
memcpy(data, pngdata->buffer, length);
|
||||
pngdata->buffer += length;
|
||||
memcpy(data, pngdata->buffer, length);
|
||||
pngdata->buffer += length;
|
||||
pngdata->size -= length;
|
||||
}
|
||||
static uint8_t * ReadPNG(Image_t * Image, const uint8_t * InData, size_t FileSize){
|
||||
|
@ -230,4 +262,4 @@ static uint8_t * ReadCUR(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
|||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue