pdfGetDeviceNToRGBBitmap
Convert a DeviceN image to RGB.
int pdfGetDeviceNToRGBBitmap(PDFHandle pdf, int rowPad, PDFImageHeader *imgHdr, char **bits)
This function converts the DeviceN bitmap generated by the last call
to
pdfConvertPageToDeviceNImage
to RGB.
The bitmap will be a 24-bit RGB bitmap, handled in the
same way as for pdfConvertPageToBitmap2
in pdfImageRGB
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)imgHdr
= a struct describing the output bitmap, with the following fields:width
= image widthheight
= image heightcolor
=pdfImageDevNToRGB
bits
= pointer to the returned bitmap data
pdfConvertPageToBitmap2
in pdfImageDevNToRGB
mode.
The difference is that individual color channels can be removed with
pdfRemoveDeviceNChannel
.
The caller is responsible for freeing the bits
pointer
after using it, by calling pdfFreeMemory
.
C:
int nChannels, i;
char *channelName;
unsigned int channelCMYK;
PDFImageHeader hdr;
char *bits;
int err;
err = pdfConvertPageToDeviceNImage(pdf, pageNum, dpi);
if (err != pdfOk) {
/* handle the error */
...
}
nChannels = pdfGetNumDeviceNChannels(pdf);
for (i = 0; i < nChannels; ++i) {
channelName = pdfGetDeviceNChannelName(pdf, i);
if ( ... ) {
pdfRemoveDeviceNChannel(pdf, i);
}
}
pdfGetDeviceNToRGBBitmap(pdf, 4, &hdr, &bits);
... use the bitmap ...
/* the bitmap memory must be freed when you are finished */
pdfFreeMemory(bits);
/* free the internal storage used by pdfConvertPageToDeviceNImage */
pdfClearDeviceNImage(pdf);