#include "quakedef.h"
+#include "image.h"
#include "jpeg.h"
*/
qboolean JPEG_OpenLibrary (void)
{
- const char* dllname;
+ const char* dllnames [] =
+ {
+#if defined(WIN64)
+ "libjpeg64.dll",
+#elif defined(WIN32)
+ "libjpeg.dll",
+#elif defined(MACOSX)
+ "libjpeg.62.dylib",
+#else
+ "libjpeg.so.62",
+ "libjpeg.so",
+#endif
+ NULL
+ };
// Already loaded?
if (jpeg_dll)
return true;
-// TODO: make Sys_LoadLibrary support multiple names
-#ifdef WIN32
- dllname = "libjpeg.dll";
-#elif defined(__FreeBSD__)
- dllname = "libjpeg.so";
-#else
- dllname = "libjpeg.so.62";
-#endif
-
// Load the DLL
- if (! Sys_LoadLibrary (dllname, &jpeg_dll, jpegfuncs))
+ if (! Sys_LoadLibrary (dllnames, &jpeg_dll, jpegfuncs))
{
Con_Printf ("JPEG support disabled\n");
return false;
cinfo->src->bytes_in_buffer -= num_bytes;
}
-static void JPEG_MemSrc (j_decompress_ptr cinfo, qbyte *buffer)
+static void JPEG_MemSrc (j_decompress_ptr cinfo, const qbyte *buffer)
{
cinfo->src = cinfo->mem->alloc_small ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof (struct jpeg_source_mgr));
Load a JPEG image into a RGBA buffer
====================
*/
-qbyte* JPEG_LoadImage (qbyte *f, int matchwidth, int matchheight)
+qbyte* JPEG_LoadImage (const qbyte *f, int matchwidth, int matchheight)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
// Write any data remaining in the buffer
if (datacount > 0)
- if (FS_Write (dest->outfile, dest->buffer, datacount) != datacount)
+ if (FS_Write (dest->outfile, dest->buffer, datacount) != (fs_offset_t)datacount)
error_in_jpeg = true;
}
}
// Open the file
- file = FS_Open (filename, "wb", true);
+ file = FS_Open (filename, "wb", true, false);
if (!file)
return false;