mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-0.87.tar
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
69b1448f19
commit
4ee97b0891
32
pngtest.c
32
pngtest.c
@@ -1,10 +1,10 @@
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
*/
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -32,12 +32,14 @@ char inbuf[256], outbuf[256];
|
||||
int main()
|
||||
{
|
||||
FILE *fpin, *fpout;
|
||||
png_bytep row_buf;
|
||||
png_bytep row_buf;
|
||||
png_byte * near_row_buf;
|
||||
png_uint_32 rowbytes;
|
||||
png_uint_32 y;
|
||||
int channels, num_pass, pass;
|
||||
|
||||
row_buf = (png_bytep )0;
|
||||
row_buf = (png_bytep)0;
|
||||
near_row_buf = (png_byte *)0;
|
||||
|
||||
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||
|
||||
@@ -73,7 +75,7 @@ int main()
|
||||
}
|
||||
|
||||
if (setjmp(write_ptr.jmpbuf))
|
||||
{
|
||||
{
|
||||
fprintf(STDERR, "libpng write error\n");
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
@@ -91,7 +93,7 @@ int main()
|
||||
png_read_info(&read_ptr, &info_ptr);
|
||||
png_write_info(&write_ptr, &info_ptr);
|
||||
|
||||
if ((info_ptr.color_type & 3) == 2)
|
||||
if ((info_ptr.color_type & 3) == 2)
|
||||
channels = 3;
|
||||
else
|
||||
channels = 1;
|
||||
@@ -99,7 +101,8 @@ int main()
|
||||
channels++;
|
||||
|
||||
rowbytes = ((info_ptr.width * info_ptr.bit_depth * channels + 7) >> 3);
|
||||
row_buf = (png_bytep )malloc((size_t)rowbytes);
|
||||
near_row_buf = (png_byte *)malloc((size_t)rowbytes);
|
||||
row_buf = (png_bytep)near_row_buf;
|
||||
if (!row_buf)
|
||||
{
|
||||
fprintf(STDERR, "no memory to allocate row buffer\n");
|
||||
@@ -124,8 +127,11 @@ int main()
|
||||
{
|
||||
for (y = 0; y < info_ptr.height; y++)
|
||||
{
|
||||
png_read_rows(&read_ptr, (png_bytepp )&row_buf, (png_bytepp )0, 1);
|
||||
png_write_rows(&write_ptr, (png_bytepp )&row_buf, 1);
|
||||
#ifdef TESTING
|
||||
fprintf(STDERR, "Processing line #%ld\n", y);
|
||||
#endif
|
||||
png_read_rows(&read_ptr, (png_bytepp)&row_buf, (png_bytepp)0, 1);
|
||||
png_write_rows(&write_ptr, (png_bytepp)&row_buf, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +144,7 @@ int main()
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
|
||||
free((void *)row_buf);
|
||||
free((void *)near_row_buf);
|
||||
|
||||
fpin = fopen(inname, "rb");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user