[devel] Changed "// ..." comments to "/* .. */" in the visupng project.

This commit is contained in:
Glenn Randers-Pehrson
2011-09-03 09:53:07 -05:00
parent ad8b7b71b4
commit ef43c17bfe
3 changed files with 189 additions and 182 deletions

View File

@@ -1,12 +1,13 @@
//-------------------------------------
// PNGFILE.C -- Image File Functions
//-------------------------------------
// Copyright 2000, Willem van Schaik.
//
// This code is released under the libpng license.
// For conditions of distribution and use, see the disclaimer
// and license in png.h
/*-------------------------------------
* PNGFILE.C -- Image File Functions
*-------------------------------------
*
* Copyright 2000, Willem van Schaik.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
#include <windows.h>
#include <commdlg.h>
@@ -28,7 +29,7 @@ static png_structp png_ptr = NULL;
static png_infop info_ptr = NULL;
// cexcept interface
/* cexcept interface */
static void
png_cexcept_error(png_structp png_ptr, png_const_charp msg)
@@ -43,7 +44,7 @@ png_cexcept_error(png_structp png_ptr, png_const_charp msg)
}
}
// Windows open-file functions
/* Windows open-file functions */
void PngFileInitialize (HWND hwnd)
{
@@ -57,13 +58,13 @@ void PngFileInitialize (HWND hwnd)
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = NULL; // Set in Open and Close functions
ofn.lpstrFile = NULL; /* Set in Open and Close functions */
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = NULL; // Set in Open and Close functions
ofn.lpstrFileTitle = NULL; /* Set in Open and Close functions */
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL;
ofn.Flags = 0; // Set in Open and Close functions
ofn.Flags = 0; /* Set in Open and Close functions */
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = TEXT ("png");
@@ -92,7 +93,7 @@ BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
return GetSaveFileName (&ofn);
}
// PNG image handler functions
/* PNG image handler functions */
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor)
@@ -109,7 +110,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
static png_byte **ppbRowPointers = NULL;
int i;
// open the PNG input file
/* open the PNG input file */
if (!pstrFileName)
{
@@ -123,7 +124,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
return FALSE;
}
// first check the eight byte PNG signature
/* first check the eight byte PNG signature */
fread(pbSig, 1, 8, pfFile);
if (png_sig_cmp(pbSig, 0, 8))
@@ -132,7 +133,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
return FALSE;
}
// create the two png(-info) structures
/* create the two png(-info) structures */
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
@@ -153,7 +154,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
Try
{
// initialize the png structure
/* initialize the png structure */
#ifdef PNG_STDIO_SUPPORTED
png_init_io(png_ptr, pfFile);
@@ -163,17 +164,17 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
png_set_sig_bytes(png_ptr, 8);
// read all PNG info up to image data
/* read all PNG info up to image data */
png_read_info(png_ptr, info_ptr);
// get width, height, bit-depth and color-type
/* get width, height, bit-depth and color-type */
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
&iColorType, NULL, NULL, NULL);
// expand images of all color-type and bit-depth to 3x8 bit RGB images
// let the library process things like alpha, transparency, background
/* expand images of all color-type and bit-depth to 3x8-bit RGB */
/* let the library process alpha, transparency, background, etc. */
#ifdef PNG_READ_16_TO_8_SUPPORTED
if (iBitDepth == 16)
@@ -193,7 +194,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
iColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
// set the background color to draw transparent and alpha images over.
/* set the background color to draw transparent and alpha images over */
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
{
png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
@@ -206,28 +207,28 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
pBkgColor = NULL;
}
// if required set gamma conversion
/* if required set gamma conversion */
if (png_get_gAMA(png_ptr, info_ptr, &dGamma))
png_set_gamma(png_ptr, (double) 2.2, dGamma);
// after the transformations have been registered update info_ptr data
/* after the transformations are registered, update info_ptr data */
png_read_update_info(png_ptr, info_ptr);
// get again width, height and the new bit-depth and color-type
/* get again width, height and the new bit-depth and color-type */
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
&iColorType, NULL, NULL, NULL);
// row_bytes is the width x number of channels
/* row_bytes is the width x number of channels */
ulRowBytes = png_get_rowbytes(png_ptr, info_ptr);
ulChannels = png_get_channels(png_ptr, info_ptr);
*piChannels = ulChannels;
// now we can allocate memory to store the image
/* now we can allocate memory to store the image */
if (pbImageData)
{
@@ -241,7 +242,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
}
*ppbImageData = pbImageData;
// and allocate memory for an array of row-pointers
/* and allocate memory for an array of row-pointers */
if ((ppbRowPointers = (png_bytepp) malloc((*piHeight)
* sizeof(png_bytep))) == NULL)
@@ -249,25 +250,25 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
png_error(png_ptr, "Visual PNG: out of memory");
}
// set the individual row-pointers to point at the correct offsets
/* set the individual row-pointers to point at the correct offsets */
for (i = 0; i < (*piHeight); i++)
ppbRowPointers[i] = pbImageData + i * ulRowBytes;
// now we can go ahead and just read the whole image
/* now we can go ahead and just read the whole image */
png_read_image(png_ptr, ppbRowPointers);
// read the additional chunks in the PNG file (not really needed)
/* read the additional chunks in the PNG file (not really needed) */
png_read_end(png_ptr, NULL);
// and we're done
/* and we're done */
free (ppbRowPointers);
ppbRowPointers = NULL;
// yepp, done
/* yepp, done */
}
Catch (msg)
@@ -301,7 +302,7 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
static png_byte **ppbRowPointers = NULL;
int i;
// open the PNG output file
/* open the PNG output file */
if (!pstrFileName)
return FALSE;
@@ -309,7 +310,7 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
if (!(pfFile = fopen(pstrFileName, "wb")))
return FALSE;
// prepare the standard PNG structures
/* prepare the standard PNG structures */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
@@ -328,7 +329,7 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
Try
{
// initialize the png structure
/* initialize the png structure */
#ifdef PNG_STDIO_SUPPORTED
png_init_io(png_ptr, pfFile);
@@ -336,52 +337,52 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush);
#endif
// we're going to write a very simple 3x8 bit RGB image
/* we're going to write a very simple 3x8-bit RGB image */
png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth,
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
PNG_FILTER_TYPE_BASE);
// write the file header information
/* write the file header information */
png_write_info(png_ptr, info_ptr);
// swap the BGR pixels in the DiData structure to RGB
/* swap the BGR pixels in the DiData structure to RGB */
png_set_bgr(png_ptr);
// row_bytes is the width x number of channels
/* row_bytes is the width x number of channels */
ulRowBytes = iWidth * ciChannels;
// we can allocate memory for an array of row-pointers
/* we can allocate memory for an array of row-pointers */
if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL)
Throw "Visualpng: Out of memory";
// set the individual row-pointers to point at the correct offsets
/* set the individual row-pointers to point at the correct offsets */
for (i = 0; i < iHeight; i++)
ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2);
// write out the entire image data in one call
/* write out the entire image data in one call */
png_write_image (png_ptr, ppbRowPointers);
// write the additional chunks to the PNG file (not really needed)
/* write the additional chunks to the PNG file (not really needed) */
png_write_end(png_ptr, info_ptr);
// and we're done
/* and we're done */
free (ppbRowPointers);
ppbRowPointers = NULL;
// clean up after the write, and free any memory allocated
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
// yepp, done
/* yepp, done */
}
Catch (msg)
@@ -443,6 +444,7 @@ png_flush(png_structp png_ptr)
#endif
//-----------------
// end of source
//-----------------
/*-----------------
* end of source
*-----------------
*/