#include "ltwrappr.h"
#include "LTCPDFComp.h"
L_INT LPDFCompressor::InsertNormal(pBitmap)
LBitmapBase * pBitmap; |
/* pointer to an LBitmapBase object */ |
Compresses the specified image, without segmenting it, and inserts the image in the PDF file in memory.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle that references the image to be inserted in the PDF document. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
To segment an image using MRC segmentation, compress it, and insert the bitmap to the PDF file in memory, call LPDFCompressor::InsertMRC.
Required DLLs and Libraries
LCMRC |
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
|
Topics: |
|
|
Example
This example inserts an image in a pdf document without using MRC segmentation.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName class LPDFCompressorKidIN : public LPDFCompressor { protected: L_INT ImageCallBack(L_INT nPage, LPSEGMENTINFO pSegment) { UNREFERENCED_PARAMETER(nPage); if(pSegment->uSegmentType == SEGTYPE_BACKGROUND) return FAILURE; else return SUCCESS; } }; L_INT LPDFCompressor__InsertNormalExample() { LPDFCompressorKidIN pdf; L_INT nRet; LBitmap LEADBitmap; PDFCOMPOPTIONS PDFOptions; CString szMsg; CString szImagesPath = MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")); CString szOutPath = MAKE_IMAGE_PATH(TEXT("Output(InsertNormal).pdf")); memset(&PDFOptions,0,sizeof(&PDFOptions)); nRet = pdf.Init (); if (nRet != SUCCESS) { MessageBox(NULL, TEXT("Couldn't initialize pdf compressor"), TEXT("Error"), MB_OK) ; return nRet; } PDFOptions.imageQuality = PDFCOMP_IMAGEQUALITY_USER; PDFOptions.outputQuality = PDFCOMP_OUTPUTQUALITY_USER; PDFOptions.uCleanSize = 7; PDFOptions.uBackGroundThreshold = 15; PDFOptions.uCombineThreshold = 100; PDFOptions.uSegmentQuality = 50; PDFOptions.uColorThreshold = 25; nRet = LEADBitmap.Load((L_TCHAR *)(LPCTSTR)szImagesPath); if(nRet != SUCCESS) { szMsg.Format(TEXT("Failed to load source image %s"),szImagesPath); MessageBox(NULL,szMsg, TEXT("Error"), MB_OK) ; pdf.Free (); return nRet; } nRet = pdf.InsertNormal(&LEADBitmap); if(nRet != SUCCESS) return nRet; nRet = pdf.Write ((L_TCHAR *)(LPCTSTR)szOutPath); if (nRet ==SUCCESS) { szMsg.Format(TEXT("result saved to %s"),szOutPath); MessageBox(NULL,szMsg, TEXT("Error"), MB_OK) ; } else { MessageBox(NULL, TEXT("failed to save result"), TEXT("Error"), MB_OK) ; return nRet; } pdf.Free (); return SUCCESS; }