getDeviceNAlphaBitmap
Get a raw bitmap for the DeviceN alpha channel.
getDeviceNAlphaBitmap([out] int *width, [out] int *height, [out] int *stride, [out, retval] HGLOBAL *data)
This function retrieves a raw bitmap for the alpha channel generated
by the last call to
convertPageToDeviceNImageWithAlpha
. It is
identical to getDeviceNAlphaPicture
, except that it returns a raw
bitmap instead of an OLE IPicture object.
The bitmap will be an 8-bit grayscale bitmap, indicating the alpha value at each pixel.
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.
Note: this function is only useful with
convertPageToDeviceNImageWithAlpha
and
convertRegionToDeviceNImageWithAlpha
.
C#:
rast.convertPageToDeviceNImage(page, dpi);
nChannels = rast.getNumDeviceNChannels();
for (int i = 0; i < nChannels; ++i) {
int width, height, stride;
IntPtr bitmapData = rast.getDeviceNBitmap(i, out width, out height, out stride);
Bitmap bmp = new Bitmap(width, height, stride, PixelFormat.Format8bppIndexed, bitmapData);
// ... use bmp ...
Marshal.FreeHGlobal(bitmapData);
}
int width, height, stride;
IntPtr bitmapData = rast.getDeviceNAlphaBitmap(out width, out height, out stride);
// the returned image is similar to the color channel images
Bitmap bmp = new Bitmap(width, height, stride, PixelFormat.Format8bppIndexed, bitmapData);
// ... use bmp ...
Marshal.FreeHGlobal(bitmapData);
rast.clearDeviceNImage();