mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-1.2.0beta4.tar
This commit is contained in:
34
pngwutil.c
34
pngwutil.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.2.0beta3 - May 18, 2001
|
||||
* libpng 1.2.0beta4 - June 23, 2001
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -25,7 +25,7 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
|
||||
buf[3] = (png_byte)(i & 0xff);
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_pCAL_SUPPORTED)
|
||||
#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
/* The png_save_int_32 function assumes integers are stored in two's
|
||||
* complement format. If this isn't the case, then this routine needs to
|
||||
* be modified to write data in two's complement format.
|
||||
@@ -332,7 +332,8 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
|
||||
/* handle the no-compression case */
|
||||
if (comp->input)
|
||||
{
|
||||
png_write_chunk_data(png_ptr, (png_bytep)comp->input, comp->input_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)comp->input,
|
||||
(png_size_t)comp->input_len);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -641,7 +642,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
|
||||
|
||||
png_debug(1, "in png_write_gAMA\n");
|
||||
/* file_gamma is saved in 1/100,000ths */
|
||||
png_save_uint_32(buf, file_gamma);
|
||||
png_save_uint_32(buf, (png_uint_32)file_gamma);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
||||
}
|
||||
#endif
|
||||
@@ -763,7 +764,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
||||
png_save_uint_16(entrybuf + 6, ep->alpha);
|
||||
png_save_uint_16(entrybuf + 8, ep->frequency);
|
||||
}
|
||||
png_write_chunk_data(png_ptr, entrybuf, entry_size);
|
||||
png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
|
||||
}
|
||||
#else
|
||||
ep=spalette->entries;
|
||||
@@ -938,32 +939,32 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf, white_x);
|
||||
png_save_uint_32(buf + 4, white_y);
|
||||
png_save_uint_32(buf, (png_uint_32)white_x);
|
||||
png_save_uint_32(buf + 4, (png_uint_32)white_y);
|
||||
|
||||
if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid cHRM fixed red point specified");
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf + 8, red_x);
|
||||
png_save_uint_32(buf + 12, red_y);
|
||||
png_save_uint_32(buf + 8, (png_uint_32)red_x);
|
||||
png_save_uint_32(buf + 12, (png_uint_32)red_y);
|
||||
|
||||
if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid fixed cHRM green point specified");
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf + 16, green_x);
|
||||
png_save_uint_32(buf + 20, green_y);
|
||||
png_save_uint_32(buf + 16, (png_uint_32)green_x);
|
||||
png_save_uint_32(buf + 20, (png_uint_32)green_y);
|
||||
|
||||
if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid fixed cHRM blue point specified");
|
||||
return;
|
||||
}
|
||||
png_save_uint_32(buf + 24, blue_x);
|
||||
png_save_uint_32(buf + 28, blue_y);
|
||||
png_save_uint_32(buf + 24, (png_uint_32)blue_x);
|
||||
png_save_uint_32(buf + 28, (png_uint_32)blue_y);
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
|
||||
}
|
||||
@@ -1383,8 +1384,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
#if defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
/* write the oFFs chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
|
||||
png_uint_32 y_offset,
|
||||
png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
|
||||
int unit_type)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
@@ -1396,8 +1396,8 @@ png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
|
||||
if (unit_type >= PNG_OFFSET_LAST)
|
||||
png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");
|
||||
|
||||
png_save_uint_32(buf, x_offset);
|
||||
png_save_uint_32(buf + 4, y_offset);
|
||||
png_save_int_32(buf, x_offset);
|
||||
png_save_int_32(buf + 4, y_offset);
|
||||
buf[8] = (png_byte)unit_type;
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
|
||||
|
||||
Reference in New Issue
Block a user