PICTools Programmer's Reference
OP_D2F, OP_D2FPLUS

OP_D2F, OP_D2FPLUS: Convert DIB to another image file format, or convert JPEG, unmodified, into TIFF.

See the D2F_STRUC: OP_D2F, OP_D2FPLUS section for additional information.  Supported output image file formats are Bitmap, DCX, ICON, PBM, PCX, PDF (wrapper around G4 compressed image), PGM, PPM, PNM, TIFF, Targa, and WBMP. OP_D2FPLUS also supports GIF format.

General Notes

When PF2_InputJPEG is set in D2F.PicFlags2:

When PF2_InputJPEG is clear in D2F.PicFlags2:

Queue Behavior

When PF2_InputJPEG is set in D2F.PicFlags2, the Get queue must contain the entire JPEG-compressed image. Additional requests for input data are not made.

BMP Output

The input image may be 1, 4, 8, or 24 bits-per-pixel.  D2F.OutBpp is ignored.  The output BMP bit depth is the same as the input image bit depth.

OP_D2F BMP output images are not compressed.

If D2F.AuxSpace points to a buffer containing a chunk whose type is AUX_BMP_EXTRABI (defined in AUXCODES.H), then that chunk's data will be embedded into the output file following the BITMAPINFOHEADER and preceding the color table, if any.  The output BITMAPFILEHEADER biSize and bfOffBits fields and the output BITMAPINFOHEADER biSize field are increased by the Length of the chunk's data. Therefore, any application which locates the image bits using the BITMAPFILEHEADER bfOffBits field and which locates the color table offset by adding biSize to the offset of the BITMAPINFOHEADER, will be able to view the resulting output BMP correctly.

If this AUX_BMP_EXTRABI data is exactly 24 bytes of zeroes, then the resulting output BMP is also an OS/2 2.1-compatible bitmap file.

Otherwise, the AUX_BMP_EXTRABI data can be used to embed an image comment or image annotation into the output image.

PCX Output

The input image may be 8 or 24 bits-per-pixel.  D2F.OutBpp is ignored.  The output PCX bit depth is the same as the input image bit depth. D2F.AuxSpace is ignored for PCX output.

The OP_D2F PCX image file header version field is set to 5 to denote PCX version 3.0.

Targa Output

The input image may be 8 or 24 bits-per-pixel color or 8 bits-per-pixel gray scale.  If the input image is 24-bits-per-pixel, then the output image is a Targa Type 2 (true color) 16 or 24 bits-per-pixel image according to D2F.OutBpp.  Otherwise, the input image 8 bits-per-pixel and D2F.OutBpp is ignored.  In that case, the output image is Type 1 (color) if the input image is color or Type 3 (gray scale) if the input image is gray scale.  D2F.AuxSpace is ignored for Targa output.

OP_D2F Targa output images are uncompressed images which are compliant with the Targa version 2.0 specification.

TIFF Output

The input image is either:

OP_D2F TIFF output images are compliant with the TIFF version 6.0 specification.

The output TIFF image can be appended to an existing TIFF file to create or append to a multi-image TIFF file. Set PF_MultiImage in D2F.PicFlags to append the output image to an existing file. See the TIFF Multi-Image Output discussion below for additional information.

When PF2_InputJPEG is set in D2F.PicFlags2, the D2F.Compression value is ignored, and this opcode does not require a JPEG compressor opcode.

The TIFF output image can be uncompressed or compressed, as specified by setting D2F.Compression. See the D2F_STRUC: OP_D2F, OP_D2FPLUS section for the allowable settings for the Compression field. For JPEG compression, this opcode uses OP_D2S, OP_D2SE, or OP_D2SEPLUS (depending on which of these opcodes is present and registered). The JPEG compressor opcode registration data is passed to this opcode in the PicParm.PIC2List P2PktRegistration packets. See the PIC2List Functions section for more information.

The output TIFF bit depth is the same as input image bit depth except for CMYK input where only the K component is to be output (output as 8-bits-per-pixel). A 24-bit output image has a PhotometricInterpretation tag type of 2 (RGB). A 1-bit or 8-bit color output image has a PhotometricInterpretation tag type of 3 (color). A 1-bit or 8-bit uncompressed gray scale output image has a PhotometricInterpretation tag type of 1 (BlackIsZero gray scale). A 1-bit gray scale G3 or G4 compressed output image has a PhotometricInterpretation tag type of 0 (WhiteIsZero).

For G3 or G4 output images, set NegateImage to output the negative of the input image.  Otherwise, the input color whose luminance is greater is output as white and the other input color is output as black.

D2F.AuxSpace is ignored for TIFF output.

When PF2_InputJPEG is set in D2F.PicFlags2, only the D2F.Expansion1[3] value, which sets endianness, is honored.

D2F.Expansion1 and D2F.Expansion2 specify additional TIFF parameters.  Regarding D2F.Expansion1 as an array of BYTES:

Byte ordering:

X/Y resolution tags:

CMYK output (32 bits-per-pixel input image only):

TIFF Multi-Image Output

The TIFF output image can be appended to an existing TIFF file by setting PF_MultiImage in D2F.PicFlags. The display order of the inserted images can be controlled by setting the optional field D2F. InsertAfterIFDOffset to the appropriate value. The optional fields D2F.MultiImageSize and D2F.TIFFFirstByte can be set for more efficient operation. The field D2F. IFDOffset is returned by REQ_EXEC. See the Operation Structures section for more information about these fields.

The existing TIFF file is supplied to OP_D2F using the Put queue.  In the first case considered in the following, the Put queue is large enough to hold the entire existing TIFF file.  In the second case, the Put queue is too small to hold the entire existing TIFF file.

Large enough Put queue:

In this case, read the existing file into the Put queue beginning at Put.Start, setting Put.Front to Put.Start, Put.Rear to the first byte following the file data and setting Q_EOF in Put.QFlags.  If the Put queue is not large enough for the existing file plus the new output TIFF image, RES_PUT_NEED_SPACE events will be returned as usual and can be handled normally.  In that case, the Put queue can either be reallocated to a larger size or the Put queue data can be written to an output TIFF file beginning at file offset 0, advancing Put.Front to the first byte of data not written.

Put queue too small:

In this case, things are more complicated because existing file data is supplied using the Put queue and output file data is returned using the same Put queue.  If the existing file size is known, D2F.MultiImageSize should be set to that existing file size.  This is an optimization which saves OP_D2F from having to read through the entire file to determine the file size.

Initially, the location pointed to by Put.Front is presumed to correspond to offset 0 in the existing TIFF file.  When RES_PUTQ_GET_NEED_DATA is returned, the Put queue will be empty.  You should read up to Put.End - Put.Start - 1 bytes of data from the existing TIFF file into the Put queue at Put.Start starting at file offset SeekInfo & SEEK_OFFSET.  Set Put.Front to Put.Start and set Put.Rear to point to the byte following the last byte read from the existing file.  Set Q_EOF in Put.QFlags if the end of the existing file is reached.  Finally, restore the file offset to SeekInfo & SEEK_OFFSET.  This is so a RES_PUT_NEED_SPACE can unconditionally be written to the file at the current file offset.

SeekInfo is set during RES_PUTQ_GET_NEED_DATA as a convenience.  Successive RES_PUTQ_GET_NEED_DATA responses will always be sequentially contiguous in the existing file unless a RES_SEEK response is returned.

A RES_SEEK response will only be returned when the Put queue is empty.  In that case, set the current file offset to SeekInfo & SEEK_OFFSET.

A RES_PUT_NEED_SPACE response can be handled as normally.  Alternatively, if Q_READING is set in Put.QFlags, then the queue data was not modified by OP_D2F.  In that case, if the queue data are available at another location, the queue data can optionally be discarded instead of written.

GIF Output

The input image must be 1, 4, or 8 bits-per-pixel.  The output GIF bit depth is large enough to represent Head.biClrImportant colors (but at least 2 bits).  If u.D2F.ImageType is BI_GIFI, then the output GIF image is interlaced, otherwise the output GIF image is not interlaced.  If PF_ApplyTransparency is set in u.D2F.PicFlags, then a GIF89a graphics extension block is output defining the transparent color index to be u.D2F.TransparentColorIndex.  If CommentLen is not 0, then a GIF89a comment extension block is output containing the comment pointed to by Comment.

If PF_ApplyTransparency is set or CommentLen is not 0, then the output GIF version is GIF89a, otherwise the output GIF version is GIF87a.

Set PF_MultiImage in D2F.PicFlags to combine multiple input GIF images into a single file.

 

 


©2022. Accusoft Corporation. All Rights Reserved.

Send Feedback