#include "quakedef.h"
+#include "image.h"
#include "jpeg.h"
*/
qboolean JPEG_OpenLibrary (void)
{
- const char* dllname;
- const dllfunction_t *func;
-
- // Already loaded?
- if (jpeg_dll)
- return true;
-
+ const char* dllnames [] =
+ {
#ifdef WIN32
- dllname = "libjpeg.dll";
+ "libjpeg.dll",
+#elif defined(MACOSX)
+ "libjpeg.62.dylib",
#else
- dllname = "libjpeg.so.62";
+ "libjpeg.so.62",
+ "libjpeg.so",
#endif
+ NULL
+ };
- // Initializations
- for (func = jpegfuncs; func && func->name != NULL; func++)
- *func->funcvariable = NULL;
+ // Already loaded?
+ if (jpeg_dll)
+ return true;
// Load the DLL
- if (! (jpeg_dll = Sys_LoadLibrary (dllname)))
+ if (! Sys_LoadLibrary (dllnames, &jpeg_dll, jpegfuncs))
{
- Con_Printf ("Can't find %s. JPEG support disabled\n", dllname);
+ Con_Printf ("JPEG support disabled\n");
return false;
}
- // Get the function adresses
- for (func = jpegfuncs; func && func->name != NULL; func++)
- if (!(*func->funcvariable = (void *) Sys_GetProcAddress (jpeg_dll, func->name)))
- {
- Con_Printf ("missing function \"%s\" - broken JPEG library!\n", func->name);
- JPEG_CloseLibrary ();
- return false;
- }
-
- Con_Printf ("%s loaded. JPEG support enabled\n", dllname);
+ Con_Printf ("JPEG support enabled\n");
return true;
}
*/
void JPEG_CloseLibrary (void)
{
- if (!jpeg_dll)
- return;
-
- Sys_UnloadLibrary (jpeg_dll);
- jpeg_dll = NULL;
+ Sys_UnloadLibrary (&jpeg_dll);
}
// No DLL = no JPEGs
if (!jpeg_dll)
{
- Con_Printf ("You need the libjpeg library to save JPEG images\n");
+ Con_Print("You need the libjpeg library to save JPEG images\n");
return false;
}
// Open the file
- file = FS_Open (filename, "wb", true);
+ file = FS_Open (filename, "wb", true, false);
if (!file)
return false;
cinfo.in_color_space = JCS_RGB;
cinfo.input_components = 3;
qjpeg_set_defaults (&cinfo);
- qjpeg_set_quality (&cinfo, 90, TRUE); // 90% quality; FIXME: use a cvar
+ qjpeg_set_quality (&cinfo, scr_screenshot_jpeg_quality.value * 100, TRUE);
qjpeg_start_compress (&cinfo, true);
// Compress each scanline