Subversion Repositories Kolibri OS

Rev

Rev 6733 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. ; pnginfo.inc - header file for PNG reference library
  3.  
  4. ; Last changed in libpng 1.6.1 [March 28, 2013]
  5. ; Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
  6. ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  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.inc
  12.  
  13. ; png_info is a structure that holds the information in a PNG file so
  14. ; that the application can find out the characteristics of the image.
  15. ; If you are reading the file, this structure will tell you what is
  16. ; in the PNG file.  If you are writing the file, fill in the information
  17. ; you want to put into the PNG file, using png_set_*() functions, then
  18. ; call png_write_info().
  19.  
  20. ; The names chosen should be very close to the PNG specification, so
  21. ; consult that document for information about the meaning of each field.
  22.  
  23. ; With libpng < 0.95, it was only possible to directly set and read the
  24. ; the values in the png_info_struct, which meant that the contents and
  25. ; order of the values had to remain fixed.  With libpng 0.95 and later,
  26. ; however, there are now functions that abstract the contents of
  27. ; png_info_struct from the application, so this makes it easier to use
  28. ; libpng with dynamic libraries, and even makes it possible to use
  29. ; libraries that don't have all of the libpng ancillary chunk-handing
  30. ; functionality.  In libpng-1.5.0 this was moved into a separate private
  31. ; file that is not visible to applications.
  32.  
  33. ; The following members may have allocated storage attached that should be
  34. ; cleaned up before the structure is discarded: palette, trans, text,
  35. ; pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
  36. ; splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these
  37. ; are automatically freed when the info structure is deallocated, if they were
  38. ; allocated internally by libpng.  This behavior can be changed by means
  39. ; of the png_data_freer() function.
  40.  
  41. ; More allocation details: all the chunk-reading functions that
  42. ; change these members go through the corresponding png_set_*
  43. ; functions.  A function to clear these members is available: see
  44. ; png_free_data().  The png_set_* functions do not depend on being
  45. ; able to point info structure members to any of the storage they are
  46. ; passed (they make their own copies), EXCEPT that the png_set_text
  47. ; functions use the same storage passed to them in the text_ptr or
  48. ; itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
  49. ; functions do not make their own copies.
  50.  
  51.  
  52. struct png_info_def
  53.         ; The following are necessary for every PNG file
  54.         width  dd ? ;uint_32 ;width of image in pixels (from IHDR)
  55.         height dd ? ;uint_32 ;height of image in pixels (from IHDR)
  56.         valid  dd ? ;uint_32 ;valid chunk data (see PNG_INFO_ below)
  57.         rowbytes dd ? ;png_size_t ;bytes needed to hold an untransformed row
  58.         palette  dd ? ;png_colorp ; array of color values (valid & PNG_INFO_PLTE)
  59.         num_palette dw ? ;uint_16 ;number of color entries in "palette" (PLTE)
  60.         num_trans   dw ? ;uint_16 ;number of transparent palette color (tRNS)
  61.         bit_depth   db ? ;byte ;1, 2, 4, 8, or 16 bits/channel (from IHDR)
  62.         color_type  db ? ;byte ;see PNG_COLOR_TYPE_ below (from IHDR)
  63.         ; The following three should have been named *_method not *_type
  64.         compression_type db ? ;byte ;must be PNG_COMPRESSION_TYPE_BASE (IHDR)
  65.         filter_type    db ? ;byte ;must be PNG_FILTER_TYPE_BASE (from IHDR)
  66.         interlace_type db ? ;byte ;One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7
  67.  
  68.         ; The following are set by png_set_IHDR, called from the application on
  69.         ; write, but the are never actually used by the write code.
  70.  
  71.         channels    db ? ;byte ;number of data channels per pixel (1, 2, 3, 4)
  72.         pixel_depth db ? ;byte ;number of bits per pixel
  73.         spare_byte  db ? ;byte ;to align the data, and for future use
  74.  
  75. if PNG_READ_SUPPORTED eq 1
  76.         ; This is never set during write
  77.         signature db 8 ;byte[8] ;magic bytes read by libpng from start of file
  78. end if
  79.  
  80.         ; The rest of the data is optional.  If you are reading, check the
  81.         ; valid field to see if the information in these are valid.  If you
  82.         ; are writing, set the valid field to those chunks you want written,
  83.         ; and initialize the appropriate fields below.
  84.  
  85.  
  86. if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
  87.         ; png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
  88.         ; defined.  When COLORSPACE is switched on all the colorspace-defining
  89.         ; chunks should be enabled, when GAMMA is switched on all the gamma-defining
  90.         ; chunks should be enabled.  If this is not done it becomes possible to read
  91.         ; inconsistent PNG files and assign a probably incorrect interpretation to
  92.         ; the information.  (In other words, by carefully choosing which chunks to
  93.         ; recognize the system configuration can select an interpretation for PNG
  94.         ; files containing ambiguous data and this will result in inconsistent
  95.         ; behavior between different libpng builds!)
  96.  
  97.         colorspace png_colorspace
  98. end if
  99.  
  100. if PNG_iCCP_SUPPORTED eq 1
  101.         ; iCCP chunk data.
  102.         iccp_name dd ? ;charp ;profile name
  103.         iccp_profile dd ? ;bytep ;International Color Consortium profile data
  104.         iccp_proflen dd ? ;uint_32 ;ICC profile data length
  105. end if
  106.  
  107. if PNG_TEXT_SUPPORTED eq 1
  108.         ; The tEXt, and zTXt chunks contain human-readable textual data in
  109.         ; uncompressed, compressed, and optionally compressed forms, respectively.
  110.         ; The data in "text" is an array of pointers to uncompressed,
  111.         ; null-terminated C strings. Each chunk has a keyword that describes the
  112.         ; textual data contained in that chunk.  Keywords are not required to be
  113.         ; unique, and the text string may be empty.  Any number of text chunks may
  114.         ; be in an image.
  115.  
  116.         num_text dd ? ;int ;number of comments read or comments to write
  117.         max_text dd ? ;int ;current size of text array
  118.         text dd ? ;png_textp ;array of comments read or comments to write
  119. end if ;TEXT
  120.  
  121. if PNG_tIME_SUPPORTED eq 1
  122.         ; The tIME chunk holds the last time the displayed image data was
  123.         ; modified.  See the png_time struct for the contents of this struct.
  124.  
  125.         mod_time png_time
  126. end if
  127.  
  128. if PNG_sBIT_SUPPORTED eq 1
  129.         ; The sBIT chunk specifies the number of significant high-order bits
  130.         ; in the pixel data.  Values are in the range [1, bit_depth], and are
  131.         ; only specified for the channels in the pixel data.  The contents of
  132.         ; the low-order bits is not specified.  Data is valid if
  133.         ; (valid & PNG_INFO_sBIT) is non-zero.
  134.  
  135.         sig_bit png_color_8 ; significant bits in color channels
  136. end if
  137.  
  138. if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
  139.         ; The tRNS chunk supplies transparency data for paletted images and
  140.         ; other image types that don't need a full alpha channel.  There are
  141.         ; "num_trans" transparency values for a paletted image, stored in the
  142.         ; same order as the palette colors, starting from index 0.  Values
  143.         ; for the data are in the range [0, 255], ranging from fully transparent
  144.         ; to fully opaque, respectively.  For non-paletted images, there is a
  145.         ; single color specified that should be treated as fully transparent.
  146.         ; Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
  147.  
  148.         trans_alpha dd ? ;bytep ; alpha values for paletted image
  149.         trans_color png_color_16 ;transparent color for non-palette image
  150. end if
  151.  
  152. if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
  153.         ; The bKGD chunk gives the suggested image background color if the
  154.         ; display program does not have its own background color and the image
  155.         ; is needs to composited onto a background before display.  The colors
  156.         ; in "background" are normally in the same color space/depth as the
  157.         ; pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
  158.  
  159.         background png_color_16
  160. end if
  161.  
  162. if PNG_oFFs_SUPPORTED eq 1
  163.         ; The oFFs chunk gives the offset in "offset_unit_type" units rightwards
  164.         ; and downwards from the top-left corner of the display, page, or other
  165.         ; application-specific co-ordinate space.  See the PNG_OFFSET_ defines
  166.         ; below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.
  167.  
  168.         x_offset dd ? ;int_32 ;x offset on page
  169.         y_offset dd ? ;int_32 ;y offset on page
  170.         offset_unit_type db ? ;byte ;offset units type
  171. end if
  172.  
  173. if PNG_pHYs_SUPPORTED eq 1
  174.         ; The pHYs chunk gives the physical pixel density of the image for
  175.         ; display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
  176.         ; defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
  177.  
  178.         x_pixels_per_unit dd ? ;uint_32 ;horizontal pixel density
  179.         y_pixels_per_unit dd ? ;uint_32 ;vertical pixel density
  180.         phys_unit_type db ? ;byte ;resolution type (see PNG_RESOLUTION_ below)
  181. end if
  182.  
  183. if PNG_hIST_SUPPORTED eq 1
  184.         ; The hIST chunk contains the relative frequency or importance of the
  185.         ; various palette entries, so that a viewer can intelligently select a
  186.         ; reduced-color palette, if required.  Data is an array of "num_palette"
  187.         ; values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
  188.         ; is non-zero.
  189.  
  190.         hist dd ? ;uint_16p
  191. end if
  192.  
  193. if PNG_pCAL_SUPPORTED eq 1
  194.         ; The pCAL chunk describes a transformation between the stored pixel
  195.         ; values and original physical data values used to create the image.
  196.         ; The integer range [0, 2^bit_depth - 1] maps to the floating-point
  197.         ; range given by [pcal_X0, pcal_X1], and are further transformed by a
  198.         ; (possibly non-linear) transformation function given by "pcal_type"
  199.         ; and "pcal_params" into "pcal_units".  Please see the PNG_EQUATION_
  200.         ; defines below, and the PNG-Group's PNG extensions document for a
  201.         ; complete description of the transformations and how they should be
  202.         ; implemented, and for a description of the ASCII parameter strings.
  203.         ; Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
  204.  
  205.         pcal_purpose dd ? ;charp ;pCAL chunk description string
  206.         pcal_X0 dd ? ;int_32 ;minimum value
  207.         pcal_X1 dd ? ;int_32 ;maximum value
  208.         pcal_units   dd ? ;charp ;Latin-1 string giving physical units
  209.         pcal_params  dd ? ;charpp ;ASCII strings containing parameter values
  210.         pcal_type    db ? ;byte ;equation type (see PNG_EQUATION_ below)
  211.         pcal_nparams db ? ;byte ;number of parameters given in pcal_params
  212. end if
  213.  
  214. ; New members added in libpng-1.0.6
  215.         free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
  216.  
  217. if PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1
  218.         ; Storage for unknown chunks that the library doesn't recognize.
  219.         unknown_chunks dd ? ;png_unknown_chunkp
  220.  
  221.         ; The type of this field is limited by the type of
  222.         ; png_struct::user_chunk_cache_max, else overflow can occur.
  223.  
  224.         unknown_chunks_num dd ? ;int
  225. end if
  226.  
  227. if PNG_sPLT_SUPPORTED eq 1
  228.         ; Data on sPLT chunks (there may be more than one).
  229.         splt_palettes dd ? ;png_sPLT_tp
  230.         splt_palettes_num dd ? ;int ;Match type returned by png_get API
  231. end if
  232.  
  233. if PNG_sCAL_SUPPORTED eq 1
  234.         ; The sCAL chunk describes the actual physical dimensions of the
  235.         ; subject matter of the graphic.  The chunk contains a unit specification
  236.         ; a byte value, and two ASCII strings representing floating-point
  237.         ; values.  The values are width and height corresponsing to one pixel
  238.         ; in the image.  Data values are valid if (valid & PNG_INFO_sCAL) is
  239.         ; non-zero.
  240.  
  241.         scal_unit db ? ;byte ;unit of physical scale
  242.         scal_s_width dd ? ;charp ;string containing height
  243.         scal_s_height dd ? ;charp ;string containing width
  244. end if
  245.  
  246. if PNG_INFO_IMAGE_SUPPORTED eq 1
  247.         ; Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
  248.         ; non-zero
  249.         ; Data valid if (valid & PNG_INFO_IDAT) non-zero
  250.         row_pointers dd ? ;bytepp ;the image bits
  251. end if
  252.  
  253. ends
  254.