Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/libpng/pngwio.c

    r2 r561  
    22/* pngwio.c - functions for data output
    33 *
    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
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (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
    912 *
    1013 * This file provides a location for all output.  Users who need
     
    2124
    2225/* 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 */
    2731
    2832void /* PRIVATE */
     
    3741#if !defined(PNG_NO_STDIO)
    3842/* 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 */
    4247#ifndef USE_FAR_KEYWORD
    4348void PNGAPI
     
    4651   png_uint_32 check;
    4752
    48    if(png_ptr == NULL) return;
     53   if (png_ptr == NULL)
     54      return;
    4955#if defined(_WIN32_WCE)
    5056   if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
     
    5763}
    5864#else
    59 /* this is the model-independent version. Since the standard I/O library
    60    can't handle far buffers in the medium and small models, we have to copy
    61    the data.
    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 */
    6369
    6470#define NEAR_BUF_SIZE 1024
     
    7278   png_FILE_p io_ptr;
    7379
    74    if(png_ptr == NULL) return;
     80   if (png_ptr == NULL)
     81      return;
    7582   /* Check if data really is near. If so, use usual code. */
    7683   near_data = (png_byte *)CVT_PTR_NOCHECK(data);
     
    94101      {
    95102         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 */
    97104#if defined(_WIN32_WCE)
    98105         if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
     
    103110         if (err != written)
    104111            break;
     112
    105113         else
    106114            check += err;
     115
    107116         data += written;
    108117         remaining -= written;
     
    118127
    119128/* 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 */
    122132#if defined(PNG_WRITE_FLUSH_SUPPORTED)
    123133void /* PRIVATE */
     
    135145   png_FILE_p io_ptr;
    136146#endif
    137    if(png_ptr == NULL) return;
     147   if (png_ptr == NULL)
     148      return;
    138149#if !defined(_WIN32_WCE)
    139150   io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
    140    if (io_ptr != NULL)
    141       fflush(io_ptr);
     151   fflush(io_ptr);
    142152#endif
    143153}
     
    146156
    147157/* 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 */
    169186void PNGAPI
    170187png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
    171188   png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
    172189{
    173    if(png_ptr == NULL) return;
     190   if (png_ptr == NULL)
     191      return;
     192
    174193   png_ptr->io_ptr = io_ptr;
    175194
     
    177196   if (write_data_fn != NULL)
    178197      png_ptr->write_data_fn = write_data_fn;
     198
    179199   else
    180200      png_ptr->write_data_fn = png_default_write_data;
     
    187207   if (output_flush_fn != NULL)
    188208      png_ptr->output_flush_fn = output_flush_fn;
     209
    189210   else
    190211      png_ptr->output_flush_fn = png_default_flush;
     
    207228#if defined(USE_FAR_KEYWORD)
    208229#if defined(_MSC_VER)
    209 void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
     230void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
    210231{
    211232   void *near_ptr;
     
    213234   FP_OFF(near_ptr) = FP_OFF(ptr);
    214235   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
    218241   return(near_ptr);
    219242}
    220243#  else
    221 void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
     244void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
    222245{
    223246   void *near_ptr;
     
    225248   near_ptr = (void FAR *)ptr;
    226249   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
    230255   return(near_ptr);
    231256}
Note: See TracChangeset for help on using the changeset viewer.