Mercurial > fife-parpg
view utils/frmconv/out_png.c @ 59:129d3dafd3a5
fix initialization of opengl, SDL_GL_DOUBLEBUFFER was accidently used as flag for SDL_SetVideoMode, instead it has to be used with SDL_GL_SetAttribute, thanks to austin_, who reported that.
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 15 Jul 2008 15:34:47 +0000 |
parents | 4a0efb7baf70 |
children |
line wrap: on
line source
#ifdef _WIN32 #define ssize_t int #include <io.h> #include <sys/types.h> #include <Winsock2.h> #else #include <netinet/in.h> #include <unistd.h> #endif #include <stdio.h> #include <png.h> #include "frm.h" #include "out_png.h" void png_my_error(png_structp a, png_const_charp b) { printf("png_my_error: %s\n", b); } void png_my_warning(png_structp a, png_const_charp b) { printf("png_my_warn: %s\n", b); } void writePNGFile(frm_frame *frame, frm_color *pal, FILE *file) { if (!file) { printf("ERR: write open failed\n"); return; } png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, png_my_error, png_my_warning); if (!png_ptr) return; png_infop 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); printf("Error: return setjmp\n"); return; } png_init_io(png_ptr, file); png_set_IHDR(png_ptr, info_ptr, frame->width, frame->height, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_set_PLTE(png_ptr, info_ptr, (png_color*)pal, 256); png_set_rows(png_ptr, info_ptr, frame->rowptr); png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); }