OLD | NEW |
1 | 1 |
2 /* pngwio.c - functions for data output | 2 /* pngwio.c - functions for data output |
3 * | 3 * |
4 * Last changed in libpng 1.6.0 [February 14, 2013] | 4 * Last changed in libpng 1.6.15 [November 20, 2014] |
5 * Copyright (c) 1998-2013 Glenn Randers-Pehrson | 5 * Copyright (c) 1998-2014 Glenn Randers-Pehrson |
6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
8 * | 8 * |
9 * This code is released under the libpng license. | 9 * This code is released under the libpng license. |
10 * For conditions of distribution and use, see the disclaimer | 10 * For conditions of distribution and use, see the disclaimer |
11 * and license in png.h | 11 * and license in png.h |
12 * | 12 * |
13 * This file provides a location for all output. Users who need | 13 * This file provides a location for all output. Users who need |
14 * special handling are expected to write functions that have the same | 14 * special handling are expected to write functions that have the same |
15 * arguments as these and perform similar functions, but that possibly | 15 * arguments as these and perform similar functions, but that possibly |
16 * use different output methods. Note that you shouldn't change these | 16 * use different output methods. Note that you shouldn't change these |
17 * functions, but rather write replacement functions and then change | 17 * functions, but rather write replacement functions and then change |
18 * them at run time with png_set_write_fn(...). | 18 * them at run time with png_set_write_fn(...). |
19 */ | 19 */ |
| 20 |
20 #include "pngpriv.h" | 21 #include "pngpriv.h" |
21 | 22 |
22 #ifdef PNG_WRITE_SUPPORTED | 23 #ifdef PNG_WRITE_SUPPORTED |
23 | 24 |
24 /* Write the data to whatever output you are using. The default routine | 25 /* Write the data to whatever output you are using. The default routine |
25 * writes to a file pointer. Note that this routine sometimes gets called | 26 * writes to a file pointer. Note that this routine sometimes gets called |
26 * with very small lengths, so you should implement some kind of simple | 27 * with very small lengths, so you should implement some kind of simple |
27 * buffering if you are using unbuffered writes. This should never be asked | 28 * buffering if you are using unbuffered writes. This should never be asked |
28 * to write more than 64K on a 16 bit machine. | 29 * to write more than 64K on a 16-bit machine. |
29 */ | 30 */ |
30 | 31 |
31 void /* PRIVATE */ | 32 void /* PRIVATE */ |
32 png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) | 33 png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) |
33 { | 34 { |
34 /* NOTE: write_data_fn must not change the buffer! */ | 35 /* NOTE: write_data_fn must not change the buffer! */ |
35 if (png_ptr->write_data_fn != NULL ) | 36 if (png_ptr->write_data_fn != NULL ) |
36 (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), | 37 (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), |
37 length); | 38 length); |
38 | 39 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 142 |
142 if (output_flush_fn != NULL) | 143 if (output_flush_fn != NULL) |
143 png_ptr->output_flush_fn = output_flush_fn; | 144 png_ptr->output_flush_fn = output_flush_fn; |
144 | 145 |
145 else | 146 else |
146 png_ptr->output_flush_fn = png_default_flush; | 147 png_ptr->output_flush_fn = png_default_flush; |
147 | 148 |
148 # else | 149 # else |
149 png_ptr->output_flush_fn = output_flush_fn; | 150 png_ptr->output_flush_fn = output_flush_fn; |
150 # endif | 151 # endif |
151 #endif /* PNG_WRITE_FLUSH_SUPPORTED */ | 152 #else |
| 153 PNG_UNUSED(output_flush_fn) |
| 154 #endif /* WRITE_FLUSH */ |
152 | 155 |
| 156 #ifdef PNG_READ_SUPPORTED |
153 /* It is an error to read while writing a png file */ | 157 /* It is an error to read while writing a png file */ |
154 if (png_ptr->read_data_fn != NULL) | 158 if (png_ptr->read_data_fn != NULL) |
155 { | 159 { |
156 png_ptr->read_data_fn = NULL; | 160 png_ptr->read_data_fn = NULL; |
157 | 161 |
158 png_warning(png_ptr, | 162 png_warning(png_ptr, |
159 "Can't set both read_data_fn and write_data_fn in the" | 163 "Can't set both read_data_fn and write_data_fn in the" |
160 " same structure"); | 164 " same structure"); |
161 } | 165 } |
| 166 #endif |
162 } | 167 } |
163 #endif /* PNG_WRITE_SUPPORTED */ | 168 #endif /* WRITE */ |
OLD | NEW |