←Select platform

BitsPerPixel Property

Summary
Gets the number of bits per pixel of this RasterImage.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int BitsPerPixel { get; } 
@property (nonatomic, assign, readonly) NSInteger bitsPerPixel 
public int getBitsPerPixel(); 
public: 
property int BitsPerPixel { 
   int get(); 
} 
BitsPerPixel # get  (RasterImage) 

Property Value

Number of bits per pixel of this RasterImage.

Remarks

The RasterImage object supports image data of 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48 and 64 bits per pixel

A 16-bpp image may be color or grayscale. If you are working with a 16-bit grayscale image, then use RasterByteOrder.Gray when creating the image. By default, the Order for a 16-bit image will be set to RasterByteOrder.Bgr.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using Leadtools.Svg; 
 
 
public void RasterImageExample() 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
 
	string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
	string destFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RasterImage1.bmp"); 
	string destFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RasterImage2.bmp"); 
 
	// Load the image 
	RasterImage srcImage = codecs.Load(srcFileName); 
 
	// Creates a new image in memory with same dimensions as the source image 
	RasterImage destImage = new RasterImage( 
	   RasterMemoryFlags.Conventional, 
	   srcImage.Width, 
	   srcImage.Height, 
	   srcImage.BitsPerPixel, 
	   srcImage.Order, 
	   srcImage.ViewPerspective, 
	   srcImage.GetPalette(), 
	   IntPtr.Zero, 
	   0); 
 
	// Copy the data from the source image to the destination image 
	srcImage.Access(); 
	destImage.Access(); 
 
	byte[] buffer = new byte[srcImage.BytesPerLine]; 
 
	for (int y = 0; y < srcImage.Height; y++) 
	{ 
		srcImage.GetRow(y, buffer, 0, buffer.Length); 
		destImage.SetRow(y, buffer, 0, buffer.Length); 
	} 
 
	destImage.Release(); 
	srcImage.Release(); 
 
	// We do not need the source image anymore 
	srcImage.Dispose(); 
 
	// save the destination image 
	codecs.Save(destImage, destFileName1, RasterImageFormat.Bmp, 24); 
 
	// perform image processing on the image 
 
	FlipCommand flipCmd = new FlipCommand(); 
	flipCmd.Horizontal = false; 
	flipCmd.Run(destImage); 
 
	// save it 
	codecs.Save(destImage, destFileName2, RasterImageFormat.Bmp, 24); 
 
	// Clean up 
	destImage.Dispose(); 
	codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools Assembly

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