←Select platform

PlaneCount Property

Summary
Indicates whether the image data should be interleaved or planar.
Syntax
C#
C++/CLI
Python
public int PlaneCount { get; set; } 
public: 
property int PlaneCount { 
   int get(); 
   void set (    int ); 
} 
PlaneCount # get and set (RasterPaintDibInfo) 

Property Value

This is usually 1. If the image data is supposed to be planar, it can be the number of planes. It should be positive in any case.

Remarks

This value will most likely be 1, indicating that the image data is interleaved. This is how all the know cards expect the image data. But, if another card will expect the data to be planar, you should set this to the number of planes (3 for 24/48-bit data, 4 for 32/64-bit data). LEADTOOLS does not have built-in support for converting to planar data, so you would have to do the color conversion yourself using the RasterImagePaintCallbackFunction.ConvertLineCallback callback.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
 
 
 
public void RasterPaintPropertiesExample() 
{ 
    // Create the form  
    RasterPaintDibInfo_Example f = new RasterPaintDibInfo_Example(); 
    f.ShowDialog(); 
} 
 
public void AddCallBack() 
{ 
    // Load the image 
    RasterCodecs codecs = new RasterCodecs(); 
    string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"); 
    image = codecs.Load(srcFileName); 
 
    // Whenever the Leadtools.RasterImage object needs to paint, 
    // it searches through the RasterPaintProperties.PaintCallbacks list until it finds 
    // a compatible RasterPaintCallbacks object. If the list is empty or there is no compatible 
    // RasterPaintCallbacks object, the default paint functions are used. 
    RasterPaintCallbacks cb = new RasterPaintCallbacks(); 
    cb.SetCallback(RasterImagePaintCallbackFunction.GetDibInfoCallback, DibFunctionDelegate); 
    props = RasterPaintProperties.Default; 
    props.PaintDisplayMode = RasterPaintDisplayModeFlags.FastPaint; 
    props.PaintCallbacks.Add(cb); 
    props.PaintEngine = RasterPaintEngine.GdiPlus; 
}        
 
private object DibFunctionDelegate(RasterImage image, object[] args) 
{ 
    // Describe the image data expected by the custom paint callback: 
    // RasterImagePaintCallbackFunction.GetDibInfoCallback. 
    // 
    // Set and use as needed in application, in this case the values are taken from image. 
    // Then return the updated RasterPaintDibInfo  
 
    rasterPaintDibInfo.BitsPerPixel = image.BitsPerPixel; 
    rasterPaintDibInfo.BytesPerLine =  Convert.ToUInt32(image.BytesPerLine); 
    rasterPaintDibInfo.Flags = RasterPaintDibInfoFlags.LowHighBitValid | RasterPaintDibInfoFlags.IgnoreLut; 
    rasterPaintDibInfo.Order = RasterByteOrder.Bgr; 
    rasterPaintDibInfo.ViewPerspective = RasterViewPerspective.RightTop; 
    return rasterPaintDibInfo; 
} 
 
public void RasterImagePainterPaint(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); 
} 
 
protected override void OnPaint(PaintEventArgs e) 
{ 
    RasterImagePainterPaint(e); 
 
    base.OnPaint(e); 
} 
 
protected override void OnDoubleClick(EventArgs e) 
{ 
 
    if ((props.PaintDisplayMode & RasterPaintDisplayModeFlags.ScaleToGray) == RasterPaintDisplayModeFlags.ScaleToGray) 
    { 
        Text = "Normal - doubleclick to change."; 
        props.PaintDisplayMode &= ~RasterPaintDisplayModeFlags.ScaleToGray; 
    } 
    else 
    { 
        Text = "ScaleToGray - doubleclick to change."; 
        props.PaintDisplayMode |= RasterPaintDisplayModeFlags.ScaleToGray; 
    } 
 
    Invalidate(); 
 
    base.OnDoubleClick(e); 
} 
 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

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