UserSegmentInfo Example for Visual C++ 5.0 and later
void CTestPDFCOMP::OnInsertWitUserSegments()
{
ILEADRaster* m_pltRaster;
ILEADRasterIO* m_pltRasterIO;
ILEADPDFCompressor* m_pltPDFComp;
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_LEADRaster, NULL, CLSCTX_ALL, IID_ILEADRaster, (void**)&m_pltRaster);
if (FAILED(hr))
return;
hr = CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&m_pltRasterIO);
if (FAILED(hr))
{
m_pltRaster->Release();
m_pltRaster = NULL;
return;
}
hr = CoCreateInstance(CLSID_LEADPDFCompressor, NULL, CLSCTX_ALL, IID_ILEADPDFCompressor, (void**)&m_pltPDFComp);
if (FAILED(hr))
{
m_pltRasterIO->Release();
m_pltRasterIO = NULL;
m_pltRaster->Release();
m_pltRaster = NULL;
return;
}
m_pltRasterIO->LoadArray (m_pltRaster,"c:\\Image.cmp",0,0,1);
m_pltPDFComp->PDFCompInit (FALSE);
m_pltPDFComp->UserSegmentInfoCount = 2;
m_pltPDFComp->UserSegmentInfo[0]->SegmentLeft = 0;
m_pltPDFComp->UserSegmentInfo[0]->SegmentBottom = m_pltRaster->BitmapHeight / 2;
m_pltPDFComp->UserSegmentInfo[0]->SegmentRight = m_pltRaster->BitmapWidth / 2;
m_pltPDFComp->UserSegmentInfo[0]->SegmentType = PDFCOMP_SEGMENT_TYPE_PICTURE;
m_pltPDFComp->UserSegmentInfo[0]->SegmentColorsCount = 0;
m_pltPDFComp->UserSegmentInfo[1]->SegmentTop = m_pltRaster->BitmapHeight / 2;
m_pltPDFComp->UserSegmentInfo[1]->SegmentLeft = m_pltRaster->BitmapHeight / 2;
m_pltPDFComp->UserSegmentInfo[1]->SegmentBottom = m_pltRaster->BitmapHeight;
m_pltPDFComp->UserSegmentInfo[1]->SegmentRight = m_pltRaster->BitmapWidth;
m_pltPDFComp->UserSegmentInfo[1]->SegmentType = PDFCOMP_SEGMENT_TYPE_PICTURE;
m_pltPDFComp->UserSegmentInfo[1]->SegmentColorsCount = 0;
m_pltPDFComp->PDFCompInsertSegments ( m_pltRaster, RGB(255,255,255), TRUE);
m_pltPDFComp->PDFCompWrite ("c:\\output.pdf");
m_pltPDFComp->PDFCompFree ();
m_pltRasterIO->Release();
m_pltRaster->Release();
m_pltPDFComp->Release();
m_pltPDFComp = NULL;
m_pltRasterIO = NULL;
m_pltRaster = NULL;
}