- image
- The source image.
- graphics
- The destination graphics object where the image will be displayed.
- index
- The index of the overlay used for painting. The overlay should have an image. If the overlay is embedded into an image bitplane, make sure you create an overlay image prior to calling this method. This index is zero-based.
- srcRect
- Rectangle which determines the portion of the image to paint.
- srcClipRect
- Rectangle which further clips the source image.
- destRect
- Rectangle which determines where the image is placed, and how it is scaled.
- destClipRect
- Rectangle which clips the image display.
- properties
- Options for the display.
Visual Basic (Declaration) | |
---|---|
Overloads Public Shared Sub PaintOverlay( _ ByVal image As RasterImage, _ ByVal graphics As Graphics, _ ByVal index As Integer, _ ByVal srcRect As LeadRect, _ ByVal srcClipRect As LeadRect, _ ByVal destRect As LeadRect, _ ByVal destClipRect As LeadRect, _ ByVal properties As RasterPaintProperties _ ) |
Visual Basic (Usage) | ![]() |
---|---|
Dim image As RasterImage Dim graphics As Graphics Dim index As Integer Dim srcRect As LeadRect Dim srcClipRect As LeadRect Dim destRect As LeadRect Dim destClipRect As LeadRect Dim properties As RasterPaintProperties RasterImagePainter.PaintOverlay(image, graphics, index, srcRect, srcClipRect, destRect, destClipRect, properties) |
C# | |
---|---|
public static void PaintOverlay( RasterImage image, Graphics graphics, int index, LeadRect srcRect, LeadRect srcClipRect, LeadRect destRect, LeadRect destClipRect, RasterPaintProperties properties ) |
C++/CLI | |
---|---|
public: static void PaintOverlay( RasterImage^ image, Graphics^ graphics, int index, LeadRect srcRect, LeadRect srcClipRect, LeadRect destRect, LeadRect destClipRect, RasterPaintProperties properties ) |
Parameters
- image
- The source image.
- graphics
- The destination graphics object where the image will be displayed.
- index
- The index of the overlay used for painting. The overlay should have an image. If the overlay is embedded into an image bitplane, make sure you create an overlay image prior to calling this method. This index is zero-based.
- srcRect
- Rectangle which determines the portion of the image to paint.
- srcClipRect
- Rectangle which further clips the source image.
- destRect
- Rectangle which determines where the image is placed, and how it is scaled.
- destClipRect
- Rectangle which clips the image display.
- properties
- Options for the display.
Visual Basic | ![]() |
---|---|
Public Sub PaintOverlayExample() Dim f As New PaintOverlayForm() f.ShowDialog() End Sub Class PaintOverlayForm Inherits Form Private image As RasterImage Private props As RasterPaintProperties Public Sub New() ' Load the image Dim codecs As New RasterCodecs() image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image2.dcm") Using overlay As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif") Dim cmd As New ResizeCommand() Using destImage As New RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 1, RasterByteOrder.Bgr, image.ViewPerspective, Nothing, IntPtr.Zero, 0) cmd.Flags = RasterSizeFlags.FavorBlack cmd.DestinationImage = destImage cmd.Run(overlay) image.SetOverlayImage(0, destImage, RasterGetSetOverlayImageMode.Copy) End Using End Using Dim attributes As RasterOverlayAttributes = image.GetOverlayAttributes(0, _ RasterGetSetOverlayAttributesFlags.Color Or _ RasterGetSetOverlayAttributesFlags.Flags Or _ RasterGetSetOverlayAttributesFlags.Origin Or _ RasterGetSetOverlayAttributesFlags.BitIndex) attributes.AutoPaint = False attributes.Color = New RasterColor(255, 0, 0) image.UpdateOverlayAttributes( _ 0, _ attributes, _ RasterGetSetOverlayAttributesFlags.Color Or _ RasterGetSetOverlayAttributesFlags.Flags Or _ RasterGetSetOverlayAttributesFlags.Origin Or _ RasterGetSetOverlayAttributesFlags.BitIndex) Text = "PaintOverlay Example" props = RasterPaintProperties.Default props.UsePaintPalette = True 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) RasterImagePainter.Paint(image, e.Graphics, LeadRect.Empty, destRect, props) RasterImagePainter.PaintOverlay(image, e.Graphics, 0, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, props) MyBase.OnPaint(e) End Sub End Class |
C# | ![]() |
---|---|
public void PaintOverlayExample() { PaintOverlayForm f = new PaintOverlayForm(); f.ShowDialog(); } class PaintOverlayForm : Form { private RasterImage image; private RasterPaintProperties props; public PaintOverlayForm() { // Load the image RasterCodecs codecs = new RasterCodecs(); image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image2.dcm")); using(RasterImage overlay = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"))) { ResizeCommand cmd = new ResizeCommand(); using(RasterImage destImage = new RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 1, RasterByteOrder.Bgr, image.ViewPerspective, null, IntPtr.Zero, 0)) { cmd.Flags = RasterSizeFlags.FavorBlack; cmd.DestinationImage = destImage; cmd.Run(overlay); image.SetOverlayImage(0, destImage, RasterGetSetOverlayImageMode.Copy); } } RasterOverlayAttributes attributes = image.GetOverlayAttributes(0, RasterGetSetOverlayAttributesFlags.Color | RasterGetSetOverlayAttributesFlags.Flags | RasterGetSetOverlayAttributesFlags.Origin | RasterGetSetOverlayAttributesFlags.BitIndex); attributes.AutoPaint = false; attributes.Color = new RasterColor(255, 0, 0); image.UpdateOverlayAttributes( 0, attributes, RasterGetSetOverlayAttributesFlags.Color | RasterGetSetOverlayAttributesFlags.Flags | RasterGetSetOverlayAttributesFlags.Origin | RasterGetSetOverlayAttributesFlags.BitIndex); Text = "PaintOverlay Example"; props = RasterPaintProperties.Default; props.UsePaintPalette = true; } 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); RasterImagePainter.Paint(image, e.Graphics, LeadRect.Empty, destRect, props); RasterImagePainter.PaintOverlay(image, e.Graphics, 0, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, props); base.OnPaint(e); } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
This method will paint an overlay image. For more information on the paint rectangles, see Paint(RasterImage,Graphics,LeadRect,RasterPaintProperties).
Paint(RasterImage,Graphics,LeadRect,RasterPaintProperties) will paint all the overlays that have RasterOverlayAttributes.AutoPaint set to true. The overlays are painted in ascending index order: overlay 0 is painted first, then overlay 1, etc.
Use this method to manually paint an overlay. For example, to change the order in which the overlays are painted, set the RasterOverlayAttributes.AutoPaint property of the overlay to false then call PaintOverlay(RasterImage,Graphics,Int32,LeadRect,LeadRect,LeadRect,LeadRect,RasterPaintProperties) directly.
To temporarily make an overlay top-most, call PaintOverlay(RasterImage,Graphics,Int32,LeadRect,LeadRect,LeadRect,LeadRect,RasterPaintProperties) after Paint(RasterImage,Graphics,LeadRect,RasterPaintProperties). To permanently make an overlay top-most, change its index and give it the highest defined index.
The overlay image's 1 pixels are painted with the color set in the RasterOverlayAttributes.Color property of the overlay. The overlay image's 0 pixels are considered transparent.
For more information on the overlay attributes, including the RasterOverlayAttributes.AutoPaint property and the RasterOverlayAttributes.Color property, refer to Leadtools.RasterOverlayAttributes.
For more information, refer to Overlay Overview.
For more information refer to RasterImage and GDI/GDI+.
Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)