LPDFCompressor::InsertNormal

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_INT LPDFCompressor::InsertNormal(pBitmap)

Compresses the specified image, without segmenting it, and inserts the image in the PDF file in memory.

Parameters

LBitmapBase * pBitmap

Pointer to the bitmap handle that references the image to be inserted in the PDF document.

Returns

Value Meaning
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

See Also

Functions

Topics

Example

This example inserts an image in a pdf document without using MRC segmentation.

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; 
} 

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS MRC C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.