// CSynapseClient API
bool RequestAPI(APIDescriptor_t *pAPI);
const char* GetInfo();
-
+
CSynapseClientImage() { }
virtual ~CSynapseClientImage() { }
};
CSynapseServer* g_pSynapseServer = NULL;
CSynapseClientImage g_SynapseClient;
-extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
-{
+#if __GNUC__ >= 4
+#pragma GCC visibility push(default)
+#endif
+extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
+#if __GNUC__ >= 4
+#pragma GCC visibility pop
+#endif
if (strcmp(version, SYNAPSE_VERSION))
{
Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
g_SynapseClient.AddAPI(IMAGE_MAJOR, "png", sizeof(_QERPlugImageTable));
g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
// NOTE: if imagepng starts being used for non "VFS" "pk3" config, need to add a dynamic config chunk
- // see:
- // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=794
- // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=800
g_SynapseClient.AddAPI(VFS_MAJOR, "pk3", sizeof(_QERFileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
return &g_SynapseClient;
bool CSynapseClientImage::RequestAPI(APIDescriptor_t *pAPI)
{
if (!strcmp(pAPI->major_name, IMAGE_MAJOR))
- {
+ {
_QERPlugImageTable* pTable= static_cast<_QERPlugImageTable*>(pAPI->mpTable);
if (!strcmp(pAPI->minor_name, "png"))
{
return;
p_fbuffer = fbuffer;
-
+
// the reading glue
// http://www.libpng.org/pub/png/libpng-manual.html
png_structp png_ptr = png_create_read_struct
- (PNG_LIBPNG_VER_STRING, png_voidp_NULL,
+ (PNG_LIBPNG_VER_STRING, NULL,
user_error_fn, user_warning_fn);
if (!png_ptr)
{
g_FuncTable.m_pfnSysPrintf ("libpng error: png_create_read_struct\n");
return;
}
-
+
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_read_struct(&png_ptr,
- png_infopp_NULL, png_infopp_NULL);
+ NULL, NULL);
g_FuncTable.m_pfnSysPrintf ("libpng error: png_create_info_struct (info_ptr)\n");
return;
}
-
+
png_infop end_info = png_create_info_struct(png_ptr);
if (!end_info) {
png_destroy_read_struct(&png_ptr, &info_ptr,
- png_infopp_NULL);
+ NULL);
g_FuncTable.m_pfnSysPrintf ("libpng error: png_create_info_struct (end_info)\n");
return;
}
int color_type = png_get_color_type(png_ptr, info_ptr);
// we want to treat all images the same way
- // The following code transforms grayscale images of less than 8 to 8 bits,
- // changes paletted images to RGB, and adds a full alpha channel if there is
+ // The following code transforms grayscale images of less than 8 to 8 bits,
+ // changes paletted images to RGB, and adds a full alpha channel if there is
// transparency information in a tRNS chunk.
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png_ptr);
- if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
- png_set_gray_1_2_4_to_8(png_ptr);
+ if ( color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 ) {
+ // png_set_gray_1_2_4_to_8 was renamed to png_set_expand_gray_1_2_4_to_8
+ png_set_expand_gray_1_2_4_to_8(png_ptr);
+ }
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png_ptr);
png_color_16 my_background, *image_background;
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
- png_set_background(png_ptr, image_background,
+ png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
// allocate the pixel buffer, and the row pointers
int size = (*width)*(*height)*4;
// still have to use that g_malloc heresy
- // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=491
*pic = (unsigned char *)g_malloc(size);
row_pointers = (png_byte**) malloc((*height) * sizeof(png_byte*));
png_read_end(png_ptr, info_ptr);
/* free up the memory structure */
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
free(row_pointers);
g_FileSystemTable.m_pfnFreeFile (fbuffer);
}
-
-