pdfConvertRegionToBitmap2
Convert a region of a page to a bitmap.
int pdfConvertRegionToBitmap2(PDFViewerHandle viewer, int page,
double x0, double y0, double x1, double y1,
double dpi, int color,
BITMAPINFOHEADER *dibHdr, char **bits)
This function converts the specified rectangular region of a page to a
bitmap, at the specified resolution (
dpi
, in dots per
inch).
The x0, y0
and x1, y1
arguments are the
corners of the rectangle, in PDF coordinates.
The color
argument must be one of the following:
pdfImageMono
: monochrome (1 bit per pixel)pdfImageGray
: grayscale (8 bits per pixel)pdfImageRGB
: RGB color (24 bits per pixel)pdfImageDevNToRGB
: 8-bit RGB, rasterized in DeviceN and then converted to RGBpdfImageGrayToMono
: 1-bit monochrome, rasterized in 8-bit grayscale and then converted to 1-bit
dibHdr
argument points to a BITMAPINFOHEADER object
that must be allocated by the caller.
The bits
argument returns a pointer to the image data.
The caller is responsible for freeing this with pdfFreeMemory
.
C:
int page;
double x0, y0, x1, y1;
BITMAPINFOHEADER dibHdr;
char *bits;
int err;
if (pdfGetCurrentSelection2(viewer, &page, &x0, &y0, &x1, &y1)) {
err = pdfConvertPageToBitmap2(viewer, page, x0, y0, x1, y1,
120, pdfImageRGB, &dibHdr, &bits);
if (err == pdfOk) {
/* use the returned header (dibHdr) and data (bits) */
...
pdfFreeMemory(bits);
} else {
/* error ... */
}
}