Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Monday, February 27, 2006 12:43:39 AM(UTC)


Groups: Registered
Posts: 1

High everybody! [:D]

I'm using C# .NET for processing some 8-bit grayscale images. The appropriate .NET pixel format used was PixelFormat.Format8bppIndexed. I could access separate pixels by locking a bitmap inside unsafe block and then work with pixels directly as an array of bytes.

Then I decided to upgrade my program to process 16-bit grayscale images. Sadly, .NET format PixelFormat.Format16bppGrayScale is not functioning at all. So I gave a try to Leadtools 14.5 Raster Imaging Pro! But it turned out that I need to go back to .NET Bitmap in order to process it pixel-by-pixel [<:o)] like this:

IRasterImage srcImage;




   Bitmap bmpImage = (Bitmap) srcImage.ChangeToGdiPlusImage(ChangeToGdiPlusImageFlags.None);

   BitmapData bmpData = bmpImage.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bmpImage.PixelFormat);



   byte* bmp = (byte *) bmpData.Scan0.ToPointer();


   //   ...




OK then, but it didn't work with 16-bit anyway! For instance, when I load 16-bit grayscale TIFF or PNG into srcImage, I get that my image is NOT GDI+ compatible [U] 

And if I set the conversion flag to ChangeToGdiPlusImageFlags.ForceChange, it results in a 24-bit RGB bmpImage bitmap.

So, the question is:

How to process 16-bit grayscale images in Leadtools .NET pixel-by-pixel ?

I'm looking forward for your replies [B]


Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, February 28, 2006 5:09:16 AM(UTC)


Groups: Manager, Tech Support
Posts: 367

Unlike LEADTOOLS Document Imaging, GDI bitmaps do not support 16 bit
grayscale. However you do NOT need to convert to a GID bitmap to get
the pixel data. There are several ways to do it. The easiest is to use
the Leadtools.IRasterImage.GetPixelData method. Here's a simple code sample:

   Leadtools.IRasterImage rasterImage = codecs.Load("16bitGrayscale.tif");
   int x=50, y=60;
   long pixelValue;
   byte[] Data = rasterImage.GetPixelData(y, x);
   pixelValue = Data[0] + Data[1] * 0x100;

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.057 seconds.