←Select platform

ForceSize Property

Summary
Gets or sets a value which indicates whether the generated thumbnail should be forced to the requested size, even if MaintainAspectRatio is set to true.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool ForceSize { get; set; } 
@property (nonatomic, assign) BOOL forceSize; 
public boolean getForceSize() 
public void setForceSize(boolean value) 
public: 
property bool ForceSize { 
   bool get(); 
   void set (    bool ); 
} 
ForceSize # get and set (CodecsThumbnailOptions) 

Property Value

Value Description
true To generate the thumbnail image by creating a "canvas" image with the requested size and then centering the actual image inside that image. Note that this is a slower process.
false To not generate the thumbnail image by creating a "canvas" image with the requested size and then centering the actual image inside that image. Note that this is a faster process. The default value is false.
Remarks

This parameter is ignored if MaintainAspectRatio is false.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
public void ReadThumbnailExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
 
   // Create a thumbnail with default options 
   CodecsThumbnailOptions options = CodecsThumbnailOptions.Default; 
   options.LoadStamp = false; 
   RasterImage thumbnail = codecs.ReadThumbnail(srcFileName, options, 1); 
 
   Debug.WriteLine("Thumbnail with default option:"); 
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel); 
   thumbnail.Dispose(); 
 
   // Create a thumbnail with some options 
   options.LoadStamp = false; 
   options.Width = 40; 
   options.Height = 80; 
   options.ForceSize = true; 
   options.MaintainAspectRatio = false; 
   options.BackColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue); 
   options.BitsPerPixel = 8; 
   options.DitheringMethod = RasterDitheringMethod.None; 
   options.Order = RasterByteOrder.Rgb; 
   options.PaletteFlags = ColorResolutionCommandPaletteFlags.None; 
   options.Resample = false; 
   thumbnail = codecs.ReadThumbnail(srcFileName, options, 1); 
 
   Debug.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}", 
      options.Width, options.Height, options.BitsPerPixel, options.ForceSize); 
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel); 
   thumbnail.Dispose(); 
 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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.