PICTools Programmer's Reference
PNG_UNION

PNG_UNION: OP_PNGE and OP_PNGP

The PNG_UNION structure supplies parameters to the OP_PNGE and OP_PNGP opcodes used for expanding PNG files to DIBs or Raw images and for compressing DIBs or Raw images to PNG files.

 
Copy Code
typedef struct {
   DWORD                           Reserved0;
   BYTE PICHUGE*                   Reserved1;
   BYTE PICHUGE*                   Reserved2;
   BYTE PICHUGE*                   Reserved3;
   BYTE PICHUGE*                   Reserved4;
   BYTE PICHUGE*                   MaskBuffer;
   BYTE PICHUGE*                   Reserved6;
   BYTE PICHUGE*                   Reserved7;
   BYTE PICHUGE*                   Reserved8;
   PICFLAGS                        PicFlags;
   PICFLAGS                        PicFlags2;
   REGION                          Region;
   LONG                            StripSize;
   DWORD                           FilterSampleSize;
   DWORD                           AlphaBpp;
   DWORD                           AlphaStride;
   DWORD                           BytesRem;
   BYTE                            Background[6];
   BYTE                            Trans[6];
   BYTE                            LastTrans;
   BYTE                            Action;
   BYTE                            Filter;
   BYTE                            BitDepth;
   DWORD                           MinReadData;
   WORD                            Palette_Entries;
   WORD                            ResolutionUnit;
   DWORD                           XResolution;
   DWORD                           YResolution;
   RGBQUAD16                       BackgroundColorRGB;
   RGBQUAD16                       TransparentColorRGB;
   LONG                            BackgroundColorIndex;
   BYTE                            Interlace;
} PNG_UNION;

Fields:

Name Description

Reserved0

This field is not currently used and must be set to 0.

Reserved1

Reserved2

Reserved3

Reserved4

Reserved5

Reserved6

Reserved7

Reserved8

These fields are not used and must be set to NULL.

PicFlags

Flags that control or report on the operation.

Value

Meaning

PF_HaveBackground

OP_PNGE:

Background value is available for use with transparent pixels or with the alpha channel.  u.PNG.BackgroundColorRGB will be set.  This flag is set by the bKGD chunk in the PNG file and is returned to the user.

OP_PNGP:

Indicates that u.PNG.BackgroundColorRGB should be save to the PNG file as the background color.

PF_HaveTransparency

OP_PNGE:

A Transparency value is available for use with transparent pixels.  u.PNG.TransparentColorRGB will be set.  This flag is set by the tRNS chunk in the PNG file and is returned to the user.

OP_PNGP:

Indicates that u.PNG.TransparentColorRGB should be saved to the PNG file as the transparent color.

PF_BlendWithBuffer

OP_PNGE:

The buffer has valid data in it.  The buffer data can be used for blending with the alpha channel or with any transparent pixels.  If this flag is not set and there is an alpha channel or transparent pixels then the background is used instead of the buffer data.  If PF_HaveBackground is false then the background is assumed black.  This flag is set by the user. This flag will be ignored if PF2_RetrieveAlpha is set.

OP_PNGP:

Ignored.

PF_OptimalFilter

OP_PNGE:

Ignored.

OP_PNGP:

Causes the opcode to try all of the various pixel filters and use the one that produces the smallest compressed image.

PF_IsColorMapped

OP_PNGE:

Set if the original image was color mapped.

OP_PNGP:

Ignored.

PF_IsGray

OP_PNGE:

Set if the original image was gray or was color-mapped with a gray palette.

OP_PNGP:

Indicates that the image should be saved as gray.

PicFlags2

Flags that control or report on the OP_PNGE operation.

Value

Meaning

PF2_RetrieveAlpha

OP_PNGE:

Indicates that an alpha channel should be returned if any alpha information is present in the PNG file.  This flag is set by the user.

OP_PNGP:

Same as PF2_SaveAlpha.

PF2_HaveAlpha

OP_PNGE:

Set if the original image had alpha or transparency information.

OP_PNGP:

Ignored.

PF2_SaveAlpha

OP_PNGE:

Same as PF2_RetrieveAlpha.

OP_PNGP:

Indicates that the alpha channel should be saved to the PNG file. This flag is only valid with input pixels with alpha channel data and with color-mapped images when  ColorTable[].rgbReserved has alpha map data.

StripSize

Following REQ_INIT, this is set to the size of one input strip. 

  • For OP_PNGE, the Put queue buffer must be large enough to hold at least one strip.  
  • For OP_PNGP, the Get queue buffer must be large enough to hold at least one strip.  Must be adjusted by you after REQ_INIT if you change u.PNG.Region.Stride after REQ_INIT.

FilterSampleSize

Reserved for opcode use.

AlphaBpp

Number of bits per pixel, before possibly being modified by the presence of F_Bmp or PF2_RetrieveAlpha.  Set by OP_PNGE during REQ_INIT.  The number of bits per pixel, after being adjusted for F_Bmp and PF2_RetrieveAlpha, will be placed into Region.Bpp during REQ_INIT.

AlphaStride

This field is set by OP_PNGE during REQ_INIT. The value is calculated as the stride needed to include an Alpha channel. If you set PF2_RetrieveAlpha after REQ_INIT but before REQ_EXEC, use AlphaStride when correcting Region.Stride and StripSize according to the output image.  Divide StripSize by Stride, set Stride to the value of AlphaStride, then multiply StripSize by the new Stride.

BytesRem

Background[]

Trans[]

LastTrans

Action

Reserved for opcode use.

Filter

  • For OP_PNGE, specifies which Filter was used to compress this PNG file.
  • For OP_PNGP, specifies the filter to use to compress the image. If PF_OptimalFilter is set in u.PNG.PicFlags, this field will be ignored and OP_PNGP will analyze the image to determine the filter which provides the best compression.

BitDepth

This is the number of bits per component.

MinReadData

Reserved for opcode use.

Palette_Entries

Reserved, set to 0.

ResolutionUnit

ResolutionUnit = 0 and non-zero XResolution/YResolution specifies the Aspect Ratio of Width / Height, otherwise ResolutionUnit = 1 and non-zero XResolution/YResolution are pixels per meter.

XResolution

Horizontal Pixels / Resolution Unit

YResolution

Vertical Pixels / Resolution Unit

BackgroundColorRGB

  • OP_PNGE will set this to the background color, if it is defined in the PNG file. Note that the color values range from 0 to 65,535 instead of 0 to 255, to accommodate 16 bit per sample images.
  • OP_PNGP will save this color as the background color, if PF_HaveBackground is set..

TransparentColorRGB

  • OP_PNGE will set this to the transparent color, if it is defined in the PNG file. Note that the color values range from 0 to 65,535 instead of 0 to 255, to accommodate 16 bit per sample images.
  • OP_PNGP will save this color as the transparent color, if PF_HaveTransparency is set.

BackgroundColorIndex

For color-mapped images, OP_PNGE will set this to the index of the background color.

Interlace

  • For OP_PNGE, this will be set during REQ_INIT to the interlace method used to compress the PNG file. 0 indicates no interlacing, and 1 indicates 'Adam7' interlacing.
  • For OP_PNGP, 1 will cause the PNG image to be interlaced and 0 will cause it to not be interlaced.

 

 


©2022. Accusoft Corporation. All Rights Reserved.

Send Feedback