←Select platform

CreateThumbnail Method

Summary
Creates a thumbnail image of this RasterImage.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (nullable LTRasterImage *)createThumbnailWithWidth:(NSInteger)width  
                                     thumbnailHeight:(NSInteger)height  
                                        bitsPerPixel:(NSInteger)bitsPerPixel  
                                viewPerspectiveToUse:(LTRasterViewPerspective)viewPerspective  
                                           sizeFlags:(LTRasterSizeFlags)sizeFlags  
                                               error:(NSError ** )error 

Parameters

thumbnailWidth
The desired maximum width of the thumbnail image in pixels.

thumbnailHeight
The desired maximum height of the thumbnail image in pixels.

bitsPerPixel
The desired bits per pixel.

viewPerspective
The desired view perspective.

sizeFlags
Flags that control the resize operation.

Return Value

A new RasterImage that is the thumbnail image.

Remarks

If the image width and height is less than thumbnailWidth and thumbnailHeight, then this method returns a copy of the image in the original size.

If the image width or height is greater than thumbnailWidth and thumbnailHeight, then this method will return the biggest thumbnail it can fit into the dimensions specified by thumbailWidth and thumbnailHeight, keeping the original image aspect ratio.

The result image will always have a resolution of 96 by 96 regardless of the resolution this RasterImage and will never return a thumbnail bigger than the original image.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using Leadtools.Svg; 
 
 
public void CreateThumbnailExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp"); 
 
   // Load the image 
   RasterImage srcImage = codecs.Load(srcFileName); 
 
   // Use the CreateTumbnail method to create a thumbnail of this image 
   RasterImage thumbnail = srcImage.CreateThumbnail(200, 200, 24, RasterViewPerspective.TopLeft, RasterSizeFlags.Bicubic); 
   Assert.IsTrue(thumbnail.PageCount == 1); 
 
   // Clean up 
   thumbnail.Dispose(); 
   srcImage.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.IOException; 
import java.io.InputStream; 
import java.util.ArrayList; 
import java.util.List; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.core.*; 
import leadtools.svg.*; 
import leadtools.imageprocessing.CloneCommand; 
import leadtools.imageprocessing.FillCommand; 
import leadtools.imageprocessing.FlipCommand; 
import leadtools.imageprocessing.GrayscaleCommand; 
import leadtools.imageprocessing.color.InvertCommand; 
import leadtools.imageprocessing.color.PosterizeCommand; 
 
 
public void createThumbnailExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
   String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "image1.cmp"); 
 
   // Load the image 
   RasterImage srcImage = codecs.load(srcFileName); 
 
   // Use the CreateTumbnail method to create a thumbnail of this image 
   RasterImage thumbnail = srcImage.createThumbnail(200, 200, 24, RasterViewPerspective.TOP_LEFT, 
         RasterSizeFlags.BICUBIC.getValue()); 
   assertTrue(thumbnail.getPageCount() == 1); 
 
   // Save it 
   codecs.save(srcImage, srcFileName, RasterImageFormat.CMP, 0); 
 
   // Clean up 
   thumbnail.dispose(); 
   srcImage.dispose(); 
   codecs.dispose(); 
 
   assertTrue("file unsuccessfully saved to " + srcFileName, (new File(srcFileName)).exists()); 
   System.out.printf("File saved successfully to %s%n", srcFileName); 
} 
Requirements

Target Platforms

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

Leadtools Assembly

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