PICTools Programmer's Reference
OP_PNGP

OP_PNGP: Compress DIB or Raw to PNG

See the PNG_UNION:OP_PNGP section for additional information.  Note that OP_PNGP requires that ParmVerMinor be 2.

OP_PNGP compression may be used to compress all standard .PNG images. The compression algorithm used is standard PNG.  If the PF_OptimalFilter flag is set then each line of the image is compressed five times with each of the five standard PNG filters.  The best one is saved in the compressed file.  If the PF_OptimalFilter flag is not set then the Filter value is used to determine which filter to apply to all lines.  The acceptable range for this value is 0 to 4 which correspond to the basic PNG filter methods as shown below. The default value if no Filter input is provided is 0 (no filtering).

Type    Name
0 None
1 Sub
2 Up
3 Average
4 Paeth

For PNG images, the bit depth of the input DIB is the same as that of the output compressed image.

Region is set by the user prior to REQ_INIT.  If there is a palette then the Head.biClrUsed value and the ColorTable array also need to be set. The region values reflect the values to be saved in the IHDR chunk and in any PLTE chunk of the PNG file.  If the stride is not set in u.PNG.Region.Stride, the opcode will assume DWORD padding. If there is a palette Red and Blue are swapped if the PF_SwapColors flag is set.  The number of colors must be placed in the Head.biClrUsed field.

StripSize will have been set by OP_PNGP after REQ_INIT is complete.  The Get queue must be at least StripSize bytes in length.  Q_REVERSE is supported for the Get queue.  Q_REVERSE is not supported for the Put queue.

An application uses PIC2List packets to supply OP_PNGP with text (a comment, application data, etc.).  Therefore OP_PNGP requires that ParmVerMinor equals 2.  See the PIC2List section of Accessing Comments and Other Auxiliary Data in the PICTools and AIMTools Programmer's Guide for more information about PIC2List packets.  Add P2PktPngText packets to PIC2List to place tEXt chunks in the output file.  The structure is defined in pic2file.h.  The Key field holds the key string to be written to the chunk.  The Text field holds the text to be written to the chunk.  Add P2PktComment packets to PIC2List to place tEXt chunks with a key of 'Comment' in the output file.

If there is a background pixel color then the PF_HaveBackground flag must be set. u.PNG.BackgroundColorRGB will hold the color to be treated as Background.  For all input image types, u.PNG.BackgroundColorRGB holds 16-bit samples.

If there is a transparent pixel then the PF_HaveTransparency flag must be set.  u.PNG.TransparentColorRGB  will hold the color to be treated as Transparent.  For all input image types, u.PNG.TransparentColorRGB holds 16-bit samples.

For a color-mapped image with transparency information, set PF2_SaveAlpha in u.PNG.PicFlags2 and provide the alpha information for each color in the color map in the ColorTable[].rgbReserved fields.  0 is transparent, 255 is opaque and PNG supports values between 0 and 255 specifying different amounts of opacity.

Interlaced images can be created by setting u.PNG.Interlace to 1.

RGB images with an alpha channel can be created by providing RGBA input in the Get queue and setting PF2_SaveAlpha.

 

 


©2022. Accusoft Corporation. All Rights Reserved.

Send Feedback