LEADTOOLS GDI/GDI+ (Leadtools.Drawing assembly)
LEAD Technologies, Inc

PaintCmykPlanes(RasterImage,Graphics,LeadRect,LeadRect,LeadRect,LeadRect,RasterPaintProperties,Object) Method

Example 





The source image.
The destination System.Drawing.Graphics object where the CMYK planes will be displayed.

A Leadtools.LeadRect object that specifies the part of the image to use as the display source.

The coordinates in the srcRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image.

A Leadtools.LeadRect object specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source image has changed.

The coordinates in the srcClipRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image

A Leadtools.LeadRect object that determines how the source rectangle is scaled and how the image is positioned in the destination graphics object.

The coordinates in the destRect object are relative to the graphics object. There is no default for this parameter. You must specify the Leadtools.LeadRect object.

A Leadtools.LeadRect object that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the destClipRect are relative to the System.Drawing.Graphics object. You can pass Rectangle.Empty to use the default, which matches the System.Drawing.Graphics object. In most cases, however, you should use the rectangle returned by the .NET PaintEventArgs.ClipRectangle or Windows WM_PAINT message.

Options for the display.
Optional RasterColorConverter object used to convert CMYK data to BGR during painting. Pass null (Nothing in VB) to let LEADTOOLS use the built-in color conversion functions.
Displays the CMYK planes stored in the image in the given System.Drawing.Graphics object.
Syntax
public static void PaintCmykPlanes( 
   RasterImage image,
   Graphics graphics,
   LeadRect srcRect,
   LeadRect srcClipRect,
   LeadRect destRect,
   LeadRect destClipRect,
   RasterPaintProperties properties,
   object colorConverter
)
'Declaration
 
Public Overloads Shared Sub PaintCmykPlanes( _
   ByVal image As RasterImage, _
   ByVal graphics As Graphics, _
   ByVal srcRect As LeadRect, _
   ByVal srcClipRect As LeadRect, _
   ByVal destRect As LeadRect, _
   ByVal destClipRect As LeadRect, _
   ByVal properties As RasterPaintProperties, _
   ByVal colorConverter As Object _
) 
'Usage
 
Dim image As RasterImage
Dim graphics As Graphics
Dim srcRect As LeadRect
Dim srcClipRect As LeadRect
Dim destRect As LeadRect
Dim destClipRect As LeadRect
Dim properties As RasterPaintProperties
Dim colorConverter As Object
 
RasterImagePainter.PaintCmykPlanes(image, graphics, srcRect, srcClipRect, destRect, destClipRect, properties, colorConverter)
public static void PaintCmykPlanes( 
   RasterImage image,
   Graphics graphics,
   LeadRect srcRect,
   LeadRect srcClipRect,
   LeadRect destRect,
   LeadRect destClipRect,
   RasterPaintProperties properties,
   object colorConverter
)
 function Leadtools.Drawing.RasterImagePainter.PaintCmykPlanes(RasterImage,Graphics,LeadRect,LeadRect,LeadRect,LeadRect,RasterPaintProperties,Object)( 
   image ,
   graphics ,
   srcRect ,
   srcClipRect ,
   destRect ,
   destClipRect ,
   properties ,
   colorConverter 
)
public:
static void PaintCmykPlanes( 
   RasterImage^ image,
   Graphics^ graphics,
   LeadRect srcRect,
   LeadRect srcClipRect,
   LeadRect destRect,
   LeadRect destClipRect,
   RasterPaintProperties properties,
   Object^ colorConverter
) 

Parameters

image
The source image.
graphics
The destination System.Drawing.Graphics object where the CMYK planes will be displayed.
srcRect

A Leadtools.LeadRect object that specifies the part of the image to use as the display source.

The coordinates in the srcRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image.

srcClipRect

A Leadtools.LeadRect object specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source image has changed.

The coordinates in the srcClipRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image

destRect

A Leadtools.LeadRect object that determines how the source rectangle is scaled and how the image is positioned in the destination graphics object.

The coordinates in the destRect object are relative to the graphics object. There is no default for this parameter. You must specify the Leadtools.LeadRect object.

destClipRect

A Leadtools.LeadRect object that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the destClipRect are relative to the System.Drawing.Graphics object. You can pass Rectangle.Empty to use the default, which matches the System.Drawing.Graphics object. In most cases, however, you should use the rectangle returned by the .NET PaintEventArgs.ClipRectangle or Windows WM_PAINT message.

properties
Options for the display.
colorConverter
Optional RasterColorConverter object used to convert CMYK data to BGR during painting. Pass null (Nothing in VB) to let LEADTOOLS use the built-in color conversion functions.
Remarks

The image must contain pages that represent each of the CMYK planes.

The data is automatically converted to BGR and dithered (if necessary) without affecting the original data in the image.

The image planes are typically created using RasterCodecs.LoadCmykPlanes.

Windows can only paint BGR data. Therefore, we need to convert CMYK data to BGR during the painting process. You will notice that the painting of regular images (which are already BGR) is faster than the painting of CMYK planes.

The color conversion can be performed using RasterColorConverter.

These conversions are accurate, but are slower than the built-in CMYK->RGB conversion formulas. To use the accurate conversions, create a RasterColorConverter object and pass it as colorConverter. To use the fast conversions, pass null (Nothing for Visual Basic) for colorConverter.

Note that there is a visible difference between using a RasterColorConverter object or not. Also, make sure you create a correct CMYK->BGR RasterColorConverter object.

If destRect is larger or smaller than the image's actual dimensions, then the image will be scaled to fit destRect.

For more information refer to RasterImage and GDI/GDI+.

For more information, refer to Changing Image Coordinates.

For more information, refer to Handling Palette Changes.

For more information, refer to Flags for the PaintDisplayMode Property.

Example
 
Public Sub PaintCmykPlanesExample()
      Dim f As New PaintCmykPlanesForm()
      f.ShowDialog()
   End Sub

   Class PaintCmykPlanesForm
      Inherits Form
      Private image As RasterImage

      Public Sub New()
         ' Load the cmyk planes
         Dim codecs As New RasterCodecs()

         Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ET\src_cmyk_image.tif")
         image = codecs.LoadCmykPlanes(srcFileName, 0, 1)

         Text = "PaintCmykPlanes Example"
      End Sub

      Protected Overrides Sub Dispose(ByVal disposing As Boolean)
         ' Clean up
         If disposing Then
            image.Dispose()
         End If

         MyBase.Dispose(disposing)
      End Sub

      Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
         ' Draw the image fit and center on this form
         Dim destRect As LeadRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom)
         destRect = RasterImage.CalculatePaintModeRectangle( _
            image.ImageWidth, _
            image.ImageHeight, _
            destRect, _
            RasterPaintSizeMode.Fit, _
            RasterPaintAlignMode.Center, _
            RasterPaintAlignMode.Center)
         Dim props As RasterPaintProperties = RasterPaintProperties.Default
         props.UsePaintPalette = True
         RasterImagePainter.PaintCmykPlanes(image, e.Graphics, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, props, Nothing)

         MyBase.OnPaint(e)
      End Sub
   End Class

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void PaintCmykPlanesExample()
   {
      PaintCmykPlanesForm f = new PaintCmykPlanesForm();
      f.ShowDialog();
   }

   class PaintCmykPlanesForm : Form
   {
      private RasterImage image;

      public PaintCmykPlanesForm()
      {
         // Load the cmyk planes
         RasterCodecs codecs = new RasterCodecs();

         string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, @"ET\src_cmyk_image.tif");
         image = codecs.LoadCmykPlanes(srcFileName, 0, 1);

         Text = "PaintCmykPlanes Example";
      }

      protected override void Dispose(bool disposing)
      {
         // Clean up
         if(disposing)
         {
            image.Dispose();
         }

         base.Dispose(disposing);
      }

      protected override void OnPaint(PaintEventArgs e)
      {
         // Draw the image fit and center on this form
         LeadRect destRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom);
         destRect = RasterImage.CalculatePaintModeRectangle(
            image.ImageWidth,
            image.ImageHeight,
            destRect,
            RasterPaintSizeMode.Fit,
            RasterPaintAlignMode.Center,
            RasterPaintAlignMode.Center);
         RasterPaintProperties props = RasterPaintProperties.Default;
         props.UsePaintPalette = true;
         RasterImagePainter.PaintCmykPlanes(image, e.Graphics, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, props, null);

         base.OnPaint(e);
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterImagePainter Class
RasterImagePainter Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.