<< Click to Display Table of Contents >> Navigation: Functions > PXCV_DrawPageToIStream |
PXCV_DrawPageToIStream renders the specified page and saves it to the stream object.
HRESULT PXCV_DrawPageToIStream(
PXVDocument Doc,
DWORD page_num,
LPPXV_CommonRenderParameters pParams,
COLORREF backcolor,
LPPXV_DrawToImageParams pImageParams,
IStream* pDest
);
Doc
[in] Specifies a document that PXCV_Init created.
page_num
[in] Specifies the zero-based page number to be rendered.
pParams
[in] Pointer to the PXV_CommonRenderParameters structure, which defines drawing parameters.
backcolor
[in] Specifies the color used to fill the background before pages are rendered. The most significant byte is used as the transparency value. 0 is full transparency and 255 is no transparency.
pImageParams
[in] Pointer to the PXV_DrawToImageParams structure, which defines the parameters of generated image files.
pDest
[in] Pointer to the IStream object where images that this function creates are stored.
Please note that all functions and parameters are case-sensitive.
If the function fails then the return value is an error code.
If the function succeeds then the return value is DS_OK, or a different value that isn't an error code.
HRESULT DrawPageToPNG(PXVDocument pDoc, DWORD page_num, LPCWSTR sFileName)
{
HRESULT hr = S_OK;
RECT rect;
PXV_CommonRenderParameters crp = {0}; // common render parameters - used to specify which part of the page and into with
// which size should rasterised (in our example whole page into 600x800 rect)
// also defines different render options
PXV_DrawToImageParams dip = {0}; // specify resulting image parameters, like format, bits per pixel
IStream* pImage = NULL; // in real app it will be the stream where image should be stored; here I'm using stream on file
// lets create a stream on file where our rendered image will be stored
hr = SHCreateStreamOnFile(sFileName, STGM_CREATE | STGM_READWRITE, &pImage);
// lets specify parameters for rendering
rect.left = 0; rect.top = 0;
rect.right = 600; rect.bottom = 800;
crp.WholePageRect = ▭
crp.DrawRect = ▭
crp.Flags = pxvrpf_EmbeddedFontAsCurves | pxvrpf_NoTransparentBkgnd;
crp.RenderTarget = pxvrm_Exporting;
dip.ImageFormat = IMGF_PNG;
dip.Flags = 0; // reserved
dip.Bpp = 24;
// rendering
hr = PXCV_DrawPageToIStream(pDoc, 0, &crp, RGB(255, 255, 255) | 0xFF000000, &dip, pImage);
pImage->Release();
return hr;
}