[FlagsAttribute()]
public enum RasterPaintDisplayModeFlags
Value | Member | Description |
---|---|---|
0x00000000 | None | Default |
0x00000001 | OrderedDither | Enables or disables ordered dithering when painting. Ordered dithering is faster than the default dithering method, which uses error diffusion, but the quality of the image is not as good. |
0x00000002 | FastPaint | Enables or disables fast painting. Fast painting should be performed only if the current video driver is good, and the image does not need to be dithered or resized to paint. No safety check for a faulty driver is performed. |
0x00000004 | IndexedPaint | Enables or disables painting that is mapped directly to the selected palette. You can this and let Windows do color matching between the paint palette and the selected palette. Indexed painting uses the colors from the currently selected palette. It is not used if the image is not palletized. |
0x00000008 | DitheredPaint | Enables or disables painting that is mapped directly to the selected palette. This is enabled by default; you can set this flag to disable it and let Windows do color matching between the paint palette and the selected palette. Indexed painting uses the colors from the currently selected palette. It is not used if the image is not palletized. |
0x00000010 | ScaleToGray | (Document/Medical only) Enables grayscaling of 1-bit images when they are displayed. This improves the readability of the images when they are zoomed in or zoomed out, but it slows down the display. |
0x00000020 | HalftonePrint | Enables use of the printing halftone (rather than the viewing halftone) when painting to a 1-bit device. |
0x00000040 | FavorBlack | (Document/Medical only) Enables a bias in preserving black objects when displaying zoomed-out 1-bit images. This can prevent the disappearance of fine lines and details, but it slows down the display. |
0x00000080 | FixedPalette | Enables the LEAD Fixed palette when displaying 24-bit (or greater) images on 8-bit (or less) devices. |
0x00000100 | NetscapePalette | Enables the Netscape Fixed palette when displaying 24-bit (or greater) images on 8-bit (or less) devices. |
0x00000200 | Resample | Enables resample resize when displaying images at zoom factors other than 1:1. |
0x00000400 | Bicubic | Enables bicubic resize when displaying images at zoom factors other than 1:1. |
This enumeration provides value for the RasterPaintProperties.PaintDisplayMode property.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Drawing;
public void RasterPaintPropertiesExample()
{
// Create the form
PaintPropertiesForm f = new PaintPropertiesForm();
f.ShowDialog();
}
class PaintPropertiesForm : Form
{
private int index = 0;
private RasterImage rasterImage;
private RasterPaintProperties paintProperties;
public PaintPropertiesForm()
{
Text = "GDI paint engine - normal - Double click to show next RasterPaintProperties options";
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
// Load an image
string fileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif");
using (RasterCodecs codecs = new RasterCodecs())
{
codecs.ThrowExceptionsOnInvalidImages = true;
rasterImage = codecs.Load(fileName);
}
paintProperties = RasterPaintProperties.Default;
// Start with GDI paint engine and normal paint scaling
paintProperties.PaintEngine = RasterPaintEngine.Gdi;
paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.None;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (rasterImage != null)
rasterImage.Dispose();
}
base.Dispose(disposing);
}
protected override void OnDoubleClick(EventArgs e)
{
switch (index)
{
case 0:
Text = "GDI paint engine - SourceAnd ROP - Double click to show next RasterPaintProperties options";
paintProperties.RasterOperation = RasterPaintProperties.SourceAnd;
break;
case 1:
Text = "GDI paint engine - Scale to gray - Double click to show next RasterPaintProperties options";
paintProperties.RasterOperation = RasterPaintProperties.SourceCopy;
paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.ScaleToGray;
break;
case 2:
Text = "GDI+ paint engine - Double click to set the opacity";
paintProperties.PaintEngine = RasterPaintEngine.GdiPlus;
break;
case 3:
Text = "GDI+ paint engine - Opacity set to 50% - Done";
paintProperties.Opacity = 128;
break;
default:
break;
}
index++;
Invalidate();
base.OnDoubleClick(e);
}
protected override void OnPaint(PaintEventArgs e)
{
// Paint the image
LeadRect destRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom);
destRect = RasterImage.CalculatePaintModeRectangle(
rasterImage.ImageWidth,
rasterImage.ImageHeight,
destRect,
RasterPaintSizeMode.Fit,
RasterPaintAlignMode.Center,
RasterPaintAlignMode.Center);
RasterImagePainter.Paint(rasterImage, e.Graphics, destRect, paintProperties);
base.OnPaint(e);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}