UseDpi Property

Summary

Gets or sets a value that indicates whether LEAD's automated scaling properties are used to account for the physical resolution of the bitmap.

Syntax

C#
C++/CLI
C++
public virtual bool UseDpi { get; set; } 
public: 
virtual property bool UseDpi { 
   bool get(); 
   void set (    bool ); 
} 
public:  
   virtual property bool UseDpi 
   { 
      bool get() 
      void set(bool value) 
   } 

Property Value

true Account for the physical resolution. Default value is false.

Remarks

The physical resolution of an image is measured in dots per inch (DPI). When you load an image, the Leadtools.RasterImage.XResolution and Leadtools.RasterImage.YResolution properties are updated with the DPI values for the horizontal and vertical resolution. Some images have different horizontal and vertical resolutions. For example, the horizontal resolution of a fax image is typically twice its vertical resolution (for example 200 by 100). In such cases, the displayed images will appear elongated if you do not account for the resolution. If the values of the Leadtools.RasterImage.XResolution property and the Leadtools.RasterImage.YResolution property are not equal, set the UseDpi property to true to have LEAD's automated scaling properties account for the physical resolution of the image.

Example

C#
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Drawing; 
 
public void RasterImageViewer_RasterImageViewer() 
{ 
   MyForm1 form = new MyForm1(); 
   form.ShowDialog(); 
} 
 
class MyForm1 : Form 
{ 
   RasterImageViewer theViewer; 
 
   public MyForm1() 
   { 
      // Create the raster viewer 
      theViewer = new RasterImageViewer(); 
      theViewer.Dock = DockStyle.Fill; 
      theViewer.DoubleBuffer = true; 
      theViewer.BorderStyle = BorderStyle.Fixed3D; 
      theViewer.AutoResetScaleFactor = true; 
      theViewer.AutoResetScrollPosition = true; 
      theViewer.HorizontalAlignMode = RasterPaintAlignMode.Center; 
      theViewer.VerticalAlignMode = RasterPaintAlignMode.Far; 
      theViewer.FrameSize = new SizeF(10, 5); 
      theViewer.FrameColor = Color.Red; 
      theViewer.FramesIsPartOfImage = true; 
      theViewer.FrameShadowSize = new SizeF(5, 5); 
      theViewer.FrameShadowColor = Color.Blue; 
      theViewer.AutoScroll = true; 
      theViewer.UseDpi = true; 
 
      // Set the paint properties 
      RasterPaintProperties p = new RasterPaintProperties(); 
      p.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; 
      p.PaintEngine = RasterPaintEngine.GdiPlus; 
      p.UsePaintPalette = true; 
      theViewer.PaintProperties = p; 
 
      theViewer.AnimateRegion = true; 
      theViewer.EnableTimer = true; 
      theViewer.EnableScrollingInterface = true; 
 
      Controls.Add(theViewer); 
      theViewer.BringToFront(); 
 
      // load an image into the viewer 
      RasterCodecs codecs = new RasterCodecs(); 
      theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp")); 
      codecs.Dispose(); 
 
      Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      theViewer.DoubleClick += new EventHandler(theViewer_DoubleClick); 
   } 
 
   void theViewer_DoubleClick(object sender, EventArgs e) 
   { 
      switch (theViewer.SizeMode) 
      { 
         case RasterPaintSizeMode.Normal: 
            theViewer.SizeMode = RasterPaintSizeMode.Stretch; 
            break; 
 
         case RasterPaintSizeMode.Stretch: 
            theViewer.SizeMode = RasterPaintSizeMode.Fit; 
            break; 
 
         case RasterPaintSizeMode.Fit: 
            theViewer.SizeMode = RasterPaintSizeMode.FitAlways; 
            break; 
 
         case RasterPaintSizeMode.FitAlways: 
            theViewer.SizeMode = RasterPaintSizeMode.FitWidth; 
            break; 
 
         case RasterPaintSizeMode.FitWidth: 
            theViewer.SizeMode = RasterPaintSizeMode.Normal; 
            break; 
      } 
 
      Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      base.OnDoubleClick(e); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 

Requirements

Target Platforms

See Also

Reference

RasterImageViewer Class

RasterImageViewer Members

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

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