25 static OPENFILENAME ofn;
38 #ifndef PNG_NO_CONSOLE_IO 39 fprintf(stderr,
"libpng error: %s\n", msg);
50 static TCHAR szFilter[] = TEXT (
"PNG Files (*.PNG)\0*.png\0")
51 TEXT (
"All Files (*.*)\0*.*\0\0");
53 ofn.lStructSize =
sizeof (OPENFILENAME);
56 ofn.lpstrFilter = szFilter;
57 ofn.lpstrCustomFilter =
NULL;
58 ofn.nMaxCustFilter = 0;
61 ofn.nMaxFile = MAX_PATH;
62 ofn.lpstrFileTitle =
NULL;
63 ofn.nMaxFileTitle = MAX_PATH;
64 ofn.lpstrInitialDir =
NULL;
65 ofn.lpstrTitle =
NULL;
68 ofn.nFileExtension = 0;
69 ofn.lpstrDefExt = TEXT (
"png");
72 ofn.lpTemplateName =
NULL;
78 ofn.lpstrFile = pstrFileName;
79 ofn.lpstrFileTitle = pstrTitleName;
80 ofn.Flags = OFN_HIDEREADONLY;
82 return GetOpenFileName (&ofn);
88 ofn.lpstrFile = pstrFileName;
89 ofn.lpstrFileTitle = pstrTitleName;
90 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
92 return GetSaveFileName (&ofn);
98 int *piWidth,
int *piHeight,
int *piChannels,
png_color *pBkgColor)
108 png_byte *pbImageData = *ppbImageData;
116 *ppbImageData = pbImageData =
NULL;
120 if (!(pfFile = fopen(pstrFileName,
"rb")))
122 *ppbImageData = pbImageData =
NULL;
128 fread(pbSig, 1, 8, pfFile);
131 *ppbImageData = pbImageData =
NULL;
138 (png_error_ptr)png_cexcept_error, (png_error_ptr)
NULL);
141 *ppbImageData = pbImageData =
NULL;
149 *ppbImageData = pbImageData =
NULL;
158 #if !defined(PNG_NO_STDIO) 173 &iColorType, NULL, NULL, NULL);
214 &iColorType, NULL, NULL, NULL);
222 *piChannels = ulChannels;
234 png_error(png_ptr,
"Visual PNG: out of memory");
236 *ppbImageData = pbImageData;
243 png_error(png_ptr,
"Visual PNG: out of memory");
248 for (i = 0; i < (*piHeight); i++)
249 ppbRowPointers[i] = pbImageData + i * ulRowBytes;
261 free (ppbRowPointers);
262 ppbRowPointers =
NULL;
271 *ppbImageData = pbImageData =
NULL;
274 free (ppbRowPointers);
288 int iWidth,
int iHeight,
png_color bkgColor)
290 const int ciBitDepth = 8;
291 const int ciChannels = 3;
303 if (!(pfFile = fopen(pstrFileName,
"wb")))
309 (png_error_ptr)png_cexcept_error, (png_error_ptr)
NULL);
327 #if !defined(PNG_NO_STDIO) 349 ulRowBytes = iWidth * ciChannels;
354 Throw "Visualpng: Out of memory";
358 for (i = 0; i < iHeight; i++)
359 ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2);
371 free (ppbRowPointers);
372 ppbRowPointers =
NULL;
386 free (ppbRowPointers);
409 (FILE *)png_ptr->io_ptr);
422 check = fwrite(
data, 1, length, (FILE *)(png_ptr->io_ptr));
433 io_ptr = (FILE *)
CVT_PTR((png_ptr->io_ptr));
GLenum GLuint GLenum GLsizei length
void PNGAPI png_set_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
void PNGAPI png_write_image(png_structp png_ptr, png_bytepp image)
png_infop PNGAPI png_create_info_struct(png_structp png_ptr)
define_exception_type(const char *)
BOOL PngFileOpenDlg(HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
#define PNG_INTERLACE_NONE
png_uint_32 PNGAPI png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
void PngFileInitialize(HWND hwnd)
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_PALETTE
png_uint_32 PNGAPI png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
void PNGAPI png_set_background(png_structp png_ptr, png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)
#define PNG_LIBPNG_VER_STRING
void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes)
PNG_CONST char FAR * png_const_charp
void PNGAPI png_set_strip_16(png_structp png_ptr)
void PNGAPI png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
BOOL PngFileSaveDlg(HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
#define PNG_BACKGROUND_GAMMA_FILE
void png_flush(png_structp png_ptr)
void PNGAPI png_set_bgr(png_structp png_ptr)
png_byte FAR *FAR * png_bytepp
png_struct FAR * png_structp
void PNGAPI png_write_info(png_structp png_ptr, png_infop info_ptr)
#define png_error(s1, s2)
void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr)
png_uint_32 PNGAPI png_get_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_type, int *compression_type, int *filter_type)
GLsizei GLsizei GLenum GLenum const GLvoid * data
#define PNG_COLOR_TYPE_GRAY
void PNGAPI png_write_end(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
int PNGAPI png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
#define PNG_FILTER_TYPE_BASE
png_structp PNGAPI png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
#define PNG_COMPRESSION_TYPE_BASE
void PNGAPI png_set_expand(png_structp png_ptr)
png_uint_32 PNGAPI png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p *background)
void PNGAPI png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
BOOL PngLoadImage(PTSTR pstrFileName, png_byte **ppbImageData, int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor)
void PNGAPI png_read_image(png_structp png_ptr, png_bytepp image)
png_structp PNGAPI png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
unsigned long png_uint_32
png_info FAR *FAR * png_infopp
png_uint_32 PNGAPI png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)
void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp)
struct exception_context the_exception_context[1]
png_byte PNGAPI png_get_channels(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_gray_to_rgb(png_structp png_ptr)
BOOL PngSaveImage(PTSTR pstrFileName, png_byte *pDiData, int iWidth, int iHeight, png_color bkgColor)