←Select platform

ReadStamp(string,int) Method

Summary
Reads a thumbnail image stored in the image file.
Syntax
C#
Objective-C
C++/CLI
Python
public RasterImage ReadStamp( 
   string fileName, 
   int pageNumber 
) 
- (nullable LTRasterImage *)readStampFromFile:(NSString *)file  
                                   pageNumber:(NSInteger)pageNumber  
                                        error:(NSError **)error 
public: 
RasterImage^ ReadStamp(  
   String^ fileName, 
   int pageNumber 
)  
def ReadStamp(self,fileName,pageNumber): 

Parameters

fileName
A String containing the name of the file which contains the stamp image to load.

pageNumber
1-based index of the page from which the stamp image should be loaded.

Return Value

The RasterImage object that this method loads.

Remarks

Only EXIF, CMP, JPEG, FlashPix, HEIF/HEIC, and PNG formats support stamps. However, not all files of these formats contain stamps. To create a thumbnail image from any file, use ReadThumbnail.

Note

At this time, there are no multipage formats that support stamps.

Example

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
 
public void StampExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
   string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_WithCustomStamp.cmp"); 
   string stampFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Stamp.bmp"); 
 
   // Load the source file name 
   RasterImage image = codecs.Load(srcFileName); 
 
   // Save as the destination image 
   codecs.Save(image, destFileName, RasterImageFormat.Cmp, 24); 
 
   // Resize the image to fit into 128 by 128 pixels keeping the aspect ratio 
   LeadRect rc = new LeadRect(0, 0, 128, 128); 
   rc = RasterImage.CalculatePaintModeRectangle( 
      image.ImageWidth, 
      image.ImageHeight, 
      rc, 
      RasterPaintSizeMode.FitAlways, 
      RasterPaintAlignMode.Near, 
      RasterPaintAlignMode.Near); 
 
   SizeCommand command = new SizeCommand(); 
   command.Width = rc.Width; 
   command.Height = rc.Height; 
   command.Flags = RasterSizeFlags.None; 
   command.Run(image); 
 
   // Add the word "Stamp" on the image at the middle 
   string message = "Stamp"; 
 
   using (Leadtools.Drawing.RasterGraphics rg = Leadtools.Drawing.RasterImagePainter.CreateGraphics(image)) 
   { 
      using (System.Drawing.StringFormat sf = new System.Drawing.StringFormat()) 
      { 
         sf.Alignment = System.Drawing.StringAlignment.Center; 
         sf.LineAlignment = System.Drawing.StringAlignment.Center; 
         using (System.Drawing.Font f = new System.Drawing.Font("Arial", 20, System.Drawing.FontStyle.Bold)) 
         { 
            System.Drawing.Rectangle rcDraw = new System.Drawing.Rectangle(rc.X, rc.Y, rc.Width, rc.Height); 
            rg.Graphics.DrawString(message, f, System.Drawing.Brushes.Yellow, rcDraw, sf); 
         } 
      } 
   } 
 
   // Now set this image as the stamp for this file 
   codecs.SaveStamp(image, destFileName, 1, 1, 1, CodecsSavePageMode.Overwrite); 
   image.Dispose(); 
 
   // Load the stamp from the file and save it into another file 
   image = codecs.ReadStamp(destFileName, 1); 
   codecs.Save(image, stampFileName, RasterImageFormat.Bmp, 24); 
   image.Dispose(); 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 

Requirements

Target Platforms

See Also

RasterCodecs Class

RasterCodecs Members

Overload List

Implementing Extended FlashPix Support

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

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.