convertRegionToBitmap2

Convert a rectangular region to a raw bitmap.
convertRegionToBitmap2([in] int page, [in] int regionX, [in] int regionY, [in] int regionW, [in] int regionH, [in] double hDPI, [in] double vDPI, [in] int color, [out] int *width, [out] int *height, [out] int *stride, [out, retval] HGLOBAL *data)
This function converts a rectangular region of a PDF page to a raw bitmap. It is identical to convertRegionToPicture2, except that it returns a raw bitmap instead of an OLE IPicture object.

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:

Note that the color settings are read-only properties on the COM component, so you'll need to use pdf.imageMono, etc.

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

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

The imageGrayToMono 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.

NB: The returned value is an HGLOBAL (i.e., XpdfRasterizer allocates it with GlobalAlloc), and the caller is responsible for calling GlobalFree (or Marshal.FreeHGBlobal) to free it.

C#:
int width, height, stride; IntPtr bitmapData = pdf.convertRegionToBitmap2(5, 0, 0, 1000, 500, 120, 120, pdf.imageRGB, out width, out height, out stride); Bitmap bmp = new Bitmap(width, height, stride, PixelFormat.Format24bppRgb, bitmapData); // ... use bmp ... Marshal.FreeHGlobal(bitmapData);
convertRegionToPicture2
convertPageToBitmap2