pdfConvertRegionToBitmap2

Convert a rectangular region to a bitmap in memory.
int pdfConvertRegionToBitmap2(PDFHandle pdf, int page, int regionX, int regionY, int regionW, int regionH, double dpi, int color, int reverseBytes, int rowPad, int upsideDown, PDFImageHeader *imgHdr, char **bits)
This function converts a rectangular region of a PDF page to a bitmap in memory. It is similar to pdfConvertRegionToBitmap, but offers more control over the output bitmap format, and has an identical API on all platforms.

The rectangular region is specified by the x,y coordinates of its upper-left corner and its width and height - in bitmap coordinates, not PDF coordinates. That is, if the whole-page bitmap would have been 1000 pixels wide and 2000 pixels high, and you request a region with (x,y) = (0,0) and (w,h) = (1000,500), the resulting bitmap will be the top fourth of the page.

The arguments are:

The pdfImageDevNToRGB mode produces RGB output like pdfImageRGB, but does the rasterization in DeviceN (CMYK + spot colors) so overprint previews will be more accurate.

The pdfImageDevNToCMYK mode produces CMYK output like pdfImageCMYK, but does the rasterization in DeviceN (CMYK + spot colors) so overprint previews will be more accurate.

The pdfImageGrayToMono mode does the rasterization in 8-bit grayscale and converts to 1-bit monochrome at the end. This is useful for files that use transparency – because 1-bit monochrome mode doesn't support transparency.

On Windows, the data returned in bits is stored in bottom-up (upside-down) format, with each line padded to a multiple of 32 bits (standard Windows bitmap format).

On Linux and OS X, the data returned in bits is stored in top-down format, with no line padding. The PDFImageHeader struct contains the following fields:

The pdfConvertPageToBitmap function returns pdfOk if successful, otherwise an error code.

The caller is responsible for freeing the bits pointer after using it, by calling pdfFreeMemory.

C:
int reverseBytes, rowPad, upsideDown; PDFImageHeader hdr; char *bits; reverseBytes = 0; /* RGB ordering */ rowPad = 1; /* no extra padding on rows */ upsideDown = 0; /* store top row first */ pdfConvertRegionToBitmap2(pdf, 5, 0, 0, 1000, 500, 72, pdfImageRGB, reverseBytes, rowPad, upsideDown, &hdr, &bits); ... pdfFreeMemory(bits);
pdfWritePageBitmap
pdfConvertPageToBitmap
pdfConvertPageToBitmap2
pdfConvertPageToBitmap3
pdfConvertRegionToBitmap
pdfConvertRegionToBitmap3