#include <stdio.h>
#include <malloc.h>
#include "png.h"
#include "cartographer.h"
void savePng( FILE * fp, unsigned __int16 raster_index)
{
unsigned __int8 trans[]={_transparent_color};
png_infop info_ptr;
png_structp png_ptr;
png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if (!png_ptr)
return ;
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_write_struct(&png_ptr,
(png_infopp)NULL);
return;
}
if (setjmp(png_jmpbuf(png_ptr)))
{
png_destroy_write_struct(&png_ptr, &info_ptr);
return;
}
png_init_io(png_ptr, fp);
/* set the zlib compression level */
png_set_compression_level(png_ptr,
Z_NO_COMPRESSION);
/*set information chunk*/
png_set_IHDR(png_ptr, info_ptr, _width, _height,
_bit_depth, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_set_packing(png_ptr);
png_set_PLTE(png_ptr, info_ptr, _palette,
_palette_count);
png_set_tRNS(png_ptr, info_ptr, trans, 1,
NULL);
png_write_info(png_ptr, info_ptr);//<------it stops here
png_set_flush(png_ptr, _height);
png_write_image(png_ptr, _rasters+raster_index);
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
}
Problem with libpng and Visual C++ Express Edition
Hi,
I tried to create a small program in C and link it against libpng
However it gives me an error in form of:
Unhandled exception at 0x776bb15f in child_server.exe: 0xC0000005: Access violation writing location 0x00000014.
The project is called child_server.exe
[Edited by - vallentin on May 29, 2008 11:36:24 AM]
Are you sure fp isn't NULL?
The program tries to write to memory adress 0x00000014. That is NULL plus a small offset of 0x14 = 20 bytes, that suggests you have an unchecked NULL pointer in there. It can't be info_ptr or png_ptr, because you check them both. This only leaves fp as I see no other pointers in there.
The program tries to write to memory adress 0x00000014. That is NULL plus a small offset of 0x14 = 20 bytes, that suggests you have an unchecked NULL pointer in there. It can't be info_ptr or png_ptr, because you check them both. This only leaves fp as I see no other pointers in there.
you may be right about the NULL thing, but fp is actually 1700140104(0x65561448)
[Edited by - vallentin on May 30, 2008 11:35:12 AM]
[Edited by - vallentin on May 30, 2008 11:35:12 AM]
Quote:Original post by vallentinI find that hard to believe. That's an extremely high address, and it certainly doesn't look like a file pointer, which is stored as a global internally. Or is this Vista?
you may be right about the NULL thingie, but fp is actually 1700140104(0x65561448)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement