//-------------------------------------
// PNGFILE.C -- Image File Functions
//-------------------------------------
// Copyright 2000, Willem van Schaik. For conditions of distribution and
// use, see the copyright/license/disclaimer notice in png.h
#include <windows.h>
#include <commdlg.h>
#include <stdio.h>
#include <stdlib.h>
#include "png.h"
#include "pngfile.h"
#include "cexcept.h"
define_exception_type(const char *);
// cexcept interface
static void
{
if(png_ptr)
;
#ifndef PNG_NO_CONSOLE_IO
#endif
{
}
}
// Windows open-file functions
{
TEXT ("All Files (*.*)\0*.*\0\0");
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
}
{
return GetOpenFileName (&ofn);
}
{
return GetSaveFileName (&ofn);
}
// PNG image handler functions
{
int iBitDepth;
int iColorType;
double dGamma;
int i;
// open the PNG input file
if (!pstrFileName)
{
return FALSE;
}
{
return FALSE;
}
// first check the eight byte PNG signature
{
return FALSE;
}
// create the two png(-info) structures
if (!png_ptr)
{
return FALSE;
}
if (!info_ptr)
{
return FALSE;
}
{
// initialize the png structure
#if !defined(PNG_NO_STDIO)
#else
#endif
// read all PNG info up to image data
// get width, height, bit-depth and color-type
// expand images of all color-type and bit-depth to 3x8 bit RGB images
// let the library process things like alpha, transparency, background
if (iBitDepth == 16)
if (iColorType == PNG_COLOR_TYPE_PALETTE)
if (iBitDepth < 8)
if (iColorType == PNG_COLOR_TYPE_GRAY ||
// set the background color to draw transparent and alpha images over.
{
}
else
{
}
// if required set gamma conversion
// after the transformations have been registered update info_ptr data
// get again width, height and the new bit-depth and color-type
// row_bytes is the width x number of channels
*piChannels = ulChannels;
// now we can allocate memory to store the image
if (pbImageData)
{
free (pbImageData);
pbImageData = NULL;
}
{
}
// and allocate memory for an array of row-pointers
{
}
// set the individual row-pointers to point at the correct offsets
for (i = 0; i < (*piHeight); i++)
// now we can go ahead and just read the whole image
// read the additional chunks in the PNG file (not really needed)
// and we're done
// yepp, done
}
{
if(ppbRowPointers)
return FALSE;
}
return TRUE;
}
{
int i;
// open the PNG output file
if (!pstrFileName)
return FALSE;
return FALSE;
// prepare the standard PNG structures
if (!png_ptr)
{
return FALSE;
}
if (!info_ptr) {
return FALSE;
}
{
// initialize the png structure
#if !defined(PNG_NO_STDIO)
#else
#endif
// we're going to write a very simple 3x8 bit RGB image
// write the file header information
// swap the BGR pixels in the DiData structure to RGB
// row_bytes is the width x number of channels
// we can allocate memory for an array of row-pointers
Throw "Visualpng: Out of memory";
// set the individual row-pointers to point at the correct offsets
for (i = 0; i < iHeight; i++)
// write out the entire image data in one call
// write the additional chunks to the PNG file (not really needed)
// and we're done
// clean up after the write, and free any memory allocated
// yepp, done
}
{
if(ppbRowPointers)
return FALSE;
}
return TRUE;
}
#ifdef PNG_NO_STDIO
static void
{
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
* instead of an int, which is what fread() actually returns.
*/
{
}
}
static void
{
{
}
}
static void
{
}
#endif
//-----------------
// end of source
//-----------------