getDeviceNToRGBBitmap
Convert a DeviceN image to a raw RGB bitmap.
getDeviceNToRGBBitmap([out] int *width, [out] int *height, [out] int *stride, [out, retval] HGLOBAL *data)
This function converts the DeviceN bitmap generated by the last call
to
convertPageToDeviceNImage
to RGB, and returns a raw bitmap. It
is identical to getDeviceNToRGBPicture
, except that it returns a
raw bitmap instead of an OLE IPicture object.
The image will be returned as a 24-bit RGB bitmap.
By default, this function will return the same thing as
convertPageToBitmap2
in imageDevNToRGB
mode. The
difference is that individual color channels can be removed with
removeDeviceNChannel
.
width
, height
, and stride
are
output arguments that provide the bitmap width, height, and stride
(bytes per row).
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#:
rast.convertPageToDeviceNImage(page, dpi);
int nChannels = rast.getNumDeviceNChannels();
for (int i = 0; i < nChannels; ++i) {
string channelName = rast.getDeviceNChannelName(i);
if (....) {
rast.removeDeviceNChannel(i);
}
}
int width, height, stride;
IntPtr bitmapData = rast.getDeviceNToRGBBitmap(out width, out height, out stride);
Bitmap bmp = new Bitmap(width, height, stride, PixelFormat.Format24bppRgb, bitmapData);
// ... use bmp ...
Marshal.FreeHGlobal(bitmapData);
rast.clearDeviceNImage()