Changeset 561 for trunk/src/3rdparty/libpng/pngwio.c
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/3rdparty/libpng/pngwio.c
r2 r561 2 2 /* pngwio.c - functions for data output 3 3 * 4 * Last changed in libpng 1.2.13 November 13, 2006 5 * For conditions of distribution and use, see copyright notice in png.h 6 * Copyright (c) 1998-2006 Glenn Randers-Pehrson 4 * Last changed in libpng 1.2.37 [June 4, 2009] 5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 * 9 * This code is released under the libpng license. 10 * For conditions of distribution and use, see the disclaimer 11 * and license in png.h 9 12 * 10 13 * This file provides a location for all output. Users who need … … 21 24 22 25 /* Write the data to whatever output you are using. The default routine 23 writes to a file pointer. Note that this routine sometimes gets called 24 with very small lengths, so you should implement some kind of simple 25 buffering if you are using unbuffered writes. This should never be asked 26 to write more than 64K on a 16 bit machine. */ 26 * writes to a file pointer. Note that this routine sometimes gets called 27 * with very small lengths, so you should implement some kind of simple 28 * buffering if you are using unbuffered writes. This should never be asked 29 * to write more than 64K on a 16 bit machine. 30 */ 27 31 28 32 void /* PRIVATE */ … … 37 41 #if !defined(PNG_NO_STDIO) 38 42 /* This is the function that does the actual writing of data. If you are 39 not writing to a standard C stream, you should create a replacement 40 write_data function and use it at run time with png_set_write_fn(), rather 41 than changing the library. */ 43 * not writing to a standard C stream, you should create a replacement 44 * write_data function and use it at run time with png_set_write_fn(), rather 45 * than changing the library. 46 */ 42 47 #ifndef USE_FAR_KEYWORD 43 48 void PNGAPI … … 46 51 png_uint_32 check; 47 52 48 if(png_ptr == NULL) return; 53 if (png_ptr == NULL) 54 return; 49 55 #if defined(_WIN32_WCE) 50 56 if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) … … 57 63 } 58 64 #else 59 /* this is the model-independent version. Since the standard I/O library60 61 62 */65 /* This is the model-independent version. Since the standard I/O library 66 * can't handle far buffers in the medium and small models, we have to copy 67 * the data. 68 */ 63 69 64 70 #define NEAR_BUF_SIZE 1024 … … 72 78 png_FILE_p io_ptr; 73 79 74 if(png_ptr == NULL) return; 80 if (png_ptr == NULL) 81 return; 75 82 /* Check if data really is near. If so, use usual code. */ 76 83 near_data = (png_byte *)CVT_PTR_NOCHECK(data); … … 94 101 { 95 102 written = MIN(NEAR_BUF_SIZE, remaining); 96 png_memcpy(buf, data, written); /* copy far buffer to near buffer */103 png_memcpy(buf, data, written); /* Copy far buffer to near buffer */ 97 104 #if defined(_WIN32_WCE) 98 105 if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) … … 103 110 if (err != written) 104 111 break; 112 105 113 else 106 114 check += err; 115 107 116 data += written; 108 117 remaining -= written; … … 118 127 119 128 /* This function is called to output any data pending writing (normally 120 to disk). After png_flush is called, there should be no data pending 121 writing in any buffers. */ 129 * to disk). After png_flush is called, there should be no data pending 130 * writing in any buffers. 131 */ 122 132 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 123 133 void /* PRIVATE */ … … 135 145 png_FILE_p io_ptr; 136 146 #endif 137 if(png_ptr == NULL) return; 147 if (png_ptr == NULL) 148 return; 138 149 #if !defined(_WIN32_WCE) 139 150 io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); 140 if (io_ptr != NULL) 141 fflush(io_ptr); 151 fflush(io_ptr); 142 152 #endif 143 153 } … … 146 156 147 157 /* This function allows the application to supply new output functions for 148 libpng if standard C streams aren't being used. 149 150 This function takes as its arguments: 151 png_ptr - pointer to a png output data structure 152 io_ptr - pointer to user supplied structure containing info about 153 the output functions. May be NULL. 154 write_data_fn - pointer to a new output function that takes as its 155 arguments a pointer to a png_struct, a pointer to 156 data to be written, and a 32-bit unsigned int that is 157 the number of bytes to be written. The new write 158 function should call png_error(png_ptr, "Error msg") 159 to exit and output any fatal error messages. 160 flush_data_fn - pointer to a new flush function that takes as its 161 arguments a pointer to a png_struct. After a call to 162 the flush function, there should be no data in any buffers 163 or pending transmission. If the output method doesn't do 164 any buffering of ouput, a function prototype must still be 165 supplied although it doesn't have to do anything. If 166 PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile 167 time, output_flush_fn will be ignored, although it must be 168 supplied for compatibility. */ 158 * libpng if standard C streams aren't being used. 159 * 160 * This function takes as its arguments: 161 * png_ptr - pointer to a png output data structure 162 * io_ptr - pointer to user supplied structure containing info about 163 * the output functions. May be NULL. 164 * write_data_fn - pointer to a new output function that takes as its 165 * arguments a pointer to a png_struct, a pointer to 166 * data to be written, and a 32-bit unsigned int that is 167 * the number of bytes to be written. The new write 168 * function should call png_error(png_ptr, "Error msg") 169 * to exit and output any fatal error messages. May be 170 * NULL, in which case libpng's default function will 171 * be used. 172 * flush_data_fn - pointer to a new flush function that takes as its 173 * arguments a pointer to a png_struct. After a call to 174 * the flush function, there should be no data in any buffers 175 * or pending transmission. If the output method doesn't do 176 * any buffering of ouput, a function prototype must still be 177 * supplied although it doesn't have to do anything. If 178 * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile 179 * time, output_flush_fn will be ignored, although it must be 180 * supplied for compatibility. May be NULL, in which case 181 * libpng's default function will be used, if 182 * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not 183 * a good idea if io_ptr does not point to a standard 184 * *FILE structure. 185 */ 169 186 void PNGAPI 170 187 png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, 171 188 png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) 172 189 { 173 if(png_ptr == NULL) return; 190 if (png_ptr == NULL) 191 return; 192 174 193 png_ptr->io_ptr = io_ptr; 175 194 … … 177 196 if (write_data_fn != NULL) 178 197 png_ptr->write_data_fn = write_data_fn; 198 179 199 else 180 200 png_ptr->write_data_fn = png_default_write_data; … … 187 207 if (output_flush_fn != NULL) 188 208 png_ptr->output_flush_fn = output_flush_fn; 209 189 210 else 190 211 png_ptr->output_flush_fn = png_default_flush; … … 207 228 #if defined(USE_FAR_KEYWORD) 208 229 #if defined(_MSC_VER) 209 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)230 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 210 231 { 211 232 void *near_ptr; … … 213 234 FP_OFF(near_ptr) = FP_OFF(ptr); 214 235 far_ptr = (void FAR *)near_ptr; 215 if(check != 0) 216 if(FP_SEG(ptr) != FP_SEG(far_ptr)) 217 png_error(png_ptr,"segment lost in conversion"); 236 237 if (check != 0) 238 if (FP_SEG(ptr) != FP_SEG(far_ptr)) 239 png_error(png_ptr, "segment lost in conversion"); 240 218 241 return(near_ptr); 219 242 } 220 243 # else 221 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)244 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 222 245 { 223 246 void *near_ptr; … … 225 248 near_ptr = (void FAR *)ptr; 226 249 far_ptr = (void FAR *)near_ptr; 227 if(check != 0) 228 if(far_ptr != ptr) 229 png_error(png_ptr,"segment lost in conversion"); 250 251 if (check != 0) 252 if (far_ptr != ptr) 253 png_error(png_ptr, "segment lost in conversion"); 254 230 255 return(near_ptr); 231 256 }
Note:
See TracChangeset
for help on using the changeset viewer.