pdfGetDeviceNAlphaBitmap
Get a bitmap for the DeviceN alpha channel.
int pdfGetDeviceNAlphaBitmap(PDFHandle pdf, int rowPad, int upsideDown, PDFImageHeader *imgHdr, char **bits)
This function retrieves the bitmap for the alpha channel generated by
the last call to
pdfConvertPageToDeviceNImageWithAlpha
.
The bitmap will be an 8-bit grayscale bitmap, indicating the alpha
value at each pixel. The bitmap is handled in the same way as for
pdfConvertPageToBitmap2
in pdfImageGray
mode:
rowPad
= each row will be padded out to a multiple of this number of bytes (typically 1 for no padding, or 4 to pad to a 32-bit boundary)upsideDown
= non-zero to store the bitmap with the bottom row firstimgHdr
= a struct describing the output bitmap, with the following fields:width
= image widthheight
= image heightcolor
=pdfImageGray
bits
= pointer to the returned bitmap data
pdfConvertPageToDeviceNImageWithAlpha
and
pdfConvertRegionToDeviceNImageWithAlpha
.
C:
int nChannels, i;
char *channelName;
unsigned int channelCMYK;
PDFImageHeader hdr;
char *bits;
int err;
err = pdfConvertPageToDeviceNImageWithAlpha(pdf, pageNum, dpi);
if (err != pdfOk) {
/* handle the error */
...
}
nChannels = pdfGetNumDeviceNChannels(pdf);
for (i = 0; i < nChannels; ++i) {
channelName = pdfGetDeviceNChannelName(pdf, i);
channelCMYK = pdfGetDeviceNChannelCMYK(pdf, i);
printf("channel %d: %s = %08x\n", channelName, channelCMYK);
pdfGetDeviceNBitmap(pdf, i, 1, 0, &hdr, &bits);
/* hdr and bits represent a grayscale bitmap --
similar to pdfConvertPageToBitmap2 with pdfImageGray */
/* each channel has an 8-bit bitmap; the bitmaps for
all channels will have the same width and height */
...
/* the bitmap memory must be freed when you are finished */
pdfFreeMemory(bits);
}
pdfGetDeviceNAlphaBitmap(pdf, 1, 0, &hdr, &bits);
/* hdr and bits work the same as for the color channel bitmaps */
...
pdfFreeMemory(bits);
/* free the internal storage used by pdfConvertPageToDeviceNImage */
pdfClearDeviceNImage(pdf);