mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
tIME and text position handling
The handling of tIME and text chunks on read now records the location of the chunks relative to PLTE and IDAT. Behavior on write is unchanged except that if the position was recorded on read it will be re-used. This involves an ABI change to the png_text_struct; a one byte location field is added (with the same meaning as the one used to record unknown chunk location.) Because this field is only used on read there is no API change unless a png_info from a libpng read is passed to a subsequent libpng write (this did not work very well before 1.7; the tIME chunk could get duplicated.) png_set_text ignores the new field, resetting it to the current position in the read or write stream. On write the position is set to the next location to be written unless the write has not started (the position is before the signature) in which case the location is set to PNG_HAVE_PLTE|PNG_AFTER_IDAT. When the chunk is written the position is set to the actual write location (effectively the position is frozen.) Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
@@ -2218,12 +2218,6 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Duplicate tIME chunks are invalid; this works round a bug in png_write_png
|
||||
* where it would write the tIME chunk once before and once after the IDAT.
|
||||
*/
|
||||
if (png_ptr->wrote_tIME)
|
||||
return;
|
||||
|
||||
png_save_uint_16(buf, mod_time->year);
|
||||
buf[2] = mod_time->month;
|
||||
buf[3] = mod_time->day;
|
||||
@@ -2232,7 +2226,6 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
|
||||
buf[6] = mod_time->second;
|
||||
|
||||
png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
|
||||
png_ptr->wrote_tIME = 1U;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user