←Select platform

BOffset Property

Summary
Gets or sets the B component offset.
Syntax
C#
C++/CLI
Python
public int BOffset { get; set; } 
public: 
property int BOffset { 
   int get(); 
   void set (    int ); 
} 
BOffset # get and set (ConversionLabParameters) 

Property Value

The B component offset.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ColorConversion; 
 
using Leadtools.ImageProcessing; 
 
public string outputFile = Path.Combine(LEAD_VARS.ImagesDir, "LabToBgr.bmp"); 
 
public void ConvertDirectToImageExample() 
{ 
   // Start up the ColorConversion. 
   RasterColorConverterEngine.Startup(); 
 
   // Input file name 
   string inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
 
   // Load the input image as BGR 
   using (RasterCodecs codecs = new RasterCodecs()) 
   using (RasterImage bgrImage = codecs.Load(inputFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1)) 
   { 
      // Get the input image buffer array 
      byte[] bgrBuffer = new byte[bgrImage.BytesPerLine * bgrImage.Height]; 
      bgrImage.Access(); 
      bgrImage.GetRow(0, bgrBuffer, 0, bgrImage.BytesPerLine * bgrImage.Height); 
      bgrImage.Release(); 
 
      // Create the destination CIELab buffer 
      byte[] labBuffer = new byte[bgrBuffer.Length]; 
 
      // Initialize a new Converter object 
      using (RasterColorConverterEngine colorConverterEngine = new RasterColorConverterEngine()) 
      { 
         // Conversion parameters 
         ConversionParameters convParams = new ConversionParameters(); 
         convParams.Method = ConversionMethodFlags.ChangeLab; 
         // CIELab conversion parameters 
         ConversionLabParameters labParameters = ConversionLabParameters.Empty; 
         labParameters.AOffset = 128; 
         labParameters.ARange = 170; 
         labParameters.BOffset = 96; 
         labParameters.BRange = 200; 
         labParameters.LOffset = 0; 
         labParameters.LRange = 100; 
         labParameters.Mask = ConversionLabMaskFlags.AOffset | 
            ConversionLabMaskFlags.ARange | 
            ConversionLabMaskFlags.BOffset | 
            ConversionLabMaskFlags.BRange | 
            ConversionLabMaskFlags.LOffset | 
            ConversionLabMaskFlags.LRange; 
         convParams.LabParameters = labParameters; 
 
         // Convert BGR to CIELab buffer using the previous parameters 
         colorConverterEngine.Start(ConversionColorFormat.Bgr, ConversionColorFormat.Lab, null); 
         colorConverterEngine.SetParameters(convParams); 
         colorConverterEngine.Convert(bgrBuffer, // input buffer 
            0, // offset from the beginning of the source buffer 
            labBuffer, // output buffer 
            0, // offset from the beginning of the destination buffer 
            bgrImage.Width, // pixels width 
            bgrImage.Height, // pixels height 
            bgrImage.BytesPerLine - (bgrImage.Width * (bgrImage.BitsPerPixel / 8)), // Scanline alignment for input buffer 
            0); // Scanline alignment for output buffer 
         colorConverterEngine.Stop(); 
 
         // To view the image after converison, convert the now CIELab buffer to a BGR image 
         RasterImage dstImage = new RasterImage(RasterMemoryFlags.Conventional, bgrImage.Width, bgrImage.Height, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0); 
         RasterColorConverterEngine.ConvertDirectToImage( 
            ConversionColorFormat.Lab, 
            ConversionColorFormat.Bgr, 
            labBuffer, // Source buffer 
            0, // Offset from the beginning of the source buffer 
            dstImage, // Destination Image 
            bgrImage.Width, // Pixels width 
            bgrImage.Height, // Pixels height 
            0, // Scanline alignment for input buffer 
            bgrImage.BytesPerLine - (bgrImage.Width * (bgrImage.BitsPerPixel / 8))); // Scanline alignment for output buffer 
 
         // Save the converted RGB Image  
         codecs.Save(dstImage, outputFile, RasterImageFormat.Bmp, 24); 
      } 
   } 
 
   // Shutdown the ColorConversion. 
   RasterColorConverterEngine.Shutdown(); 
} 
 
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.ColorConversion Assembly

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