22.03.2015 Views

DLI Implementation and Reference Guide - Datalogics

DLI Implementation and Reference Guide - Datalogics

DLI Implementation and Reference Guide - Datalogics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

11.4 <strong>DLI</strong> <strong>Implementation</strong> <strong>and</strong> <strong>Reference</strong> <strong>Guide</strong><br />

description of resolution (samples per inch horizontal <strong>and</strong>/or vertical). The stream<br />

may be compressed, in which case the compression algorithm <strong>and</strong> parameters must<br />

also be given.<br />

Concepts <strong>and</strong> Facilities: <strong>Guide</strong> to the DL Pager Composition System<br />

These images may be expressed at various levels, from something as simple as “Here<br />

is a bitmap of n lines by n samples in 1-bit gray scale,” to more-complex references to<br />

st<strong>and</strong>ards for graphics encoding <strong>and</strong> compression (e.g. JPEG/JPG, TIFF, GIF, PNG,<br />

etc.). However, the Adobe PDF Library package contains no logic to transform<br />

bitmaps, so they must all be presented to the Adobe PDF Library in a common<br />

manner.<br />

This excerpt from the graphical image example shows the logic for inserting a raw<br />

bitmapped graphic into a document.<br />

"C" Example: Bitmapped Graphic via dlpdfimagecreatefrombmp<br />

/* Allocate memory to hold the image bitmap */<br />

ImageString = malloc (ImageWidth * ImageDepth);<br />

/* Open read the bitmap, <strong>and</strong> close the bitmap file */<br />

ImageFile = fopen (ImageName, "rb");<br />

fread (ImageString, 1, ImageWidth * ImageDepth, ImageFile);<br />

fclose (ImageFile);<br />

/* Get the color space DeviceGray as a COS object */<br />

GraySpace = PDEColorSpaceCreateFromName (ASAtomFromString<br />

("DeviceGray"));<br />

PDEColorSpaceGetCosObj (GraySpace, &Color);<br />

/* Create a DLPDFIMAGE object from the bitmap */<br />

Image = dlpdfimagecreatefrombmp (Doc, "Bear", ImageString,<br />

ImageDepth * ImageWidth,<br />

ImageWidth, ImageDepth,<br />

8, Color, FALSE);<br />

/* Free the image string from memory */<br />

free (ImageString);<br />

/* "Paste" the image into the container, centered over the<br />

* red box */<br />

dlpdfcontentreferenceimage (Content, Image,<br />

(fixedFour * 72) - ((Image->BBox.left + Image->BBox.right)/2),<br />

(fixedFour * 72) - ((Image->BBox.top + Image->BBox.bottom)/2),<br />

0, fixedOne, fixedOne);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!