pdfConvertRegionToBitmap2
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:
page
= page numberregionX
,regionY
= upper-left corner of regionregionW
,regionH
= width and height of regiondpi
= resolution (dots per inch)color
= color setting - one of:pdfImageMono
: 1-bit monochromepdfImageGray
: 8-bit grayscalepdfImageRGB
: 8-bit RGBpdfImageCMYK
: 8-bit CMYKpdfImageDevNToRGB
: 8-bit RGB, rasterized in DeviceN and then converted to RGBpdfImageDevNToCMYK
: 8-bit CMYK, rasterized in DeviceN and then converted to CMYKpdfImageGrayToMono
: 1-bit monochrome, rasterized in 8-bit grayscale and then converted to 1-bit
reverseBytes
= non-zero to store RGB color data in BGR order (this argument has no effect for pdfImageMono or pdfImageGray)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
= the color argument passed topdfConvertPageToBitmap2
bits
= pointer to the returned bitmap data
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:
width
= image widthheight
= image heightcolor
= the color argument passed topdfConvertPageToBitmap
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
.