I need to create an Image with more then 256 gray scale.
this is my code, i've some problem setting correctly the pixel value.
any idea?
There is another way to create an image with more then 256 gray
Bitmap myBitmap = new
Bitmap(256,256,PixelFormat.Format64bppArgb);
BitmapData bmd = myBitmap.LockBits(new
Rectangle(0,0,256,256),ImageLockMode.ReadWrite,PixelFormat.Format64bppArgb);
unsafe
{
int PixelSize=8;
for(int y=0; y<bmd.Height; y++)
{
byte* row=(byte *)bmd.Scan0+(y*bmd.Stride);
for(int x=0; x<bmd.Width; x++)
{
row[x*PixelSize]=(byte)grayvalue;
}
}
}
myBitmap.UnlockBits(bmd);
thank you all.
michele
Chris Priede - 22 Dec 2005 16:15 GMT
Hi,
> I need to create an Image with more then 256 gray scale.
> this is my code, i've some problem setting correctly the pixel value.
> any idea?
> byte* row=(byte *)bmd.Scan0+(y*bmd.Stride);
> for(int x=0; x<bmd.Width; x++)
> row[x*PixelSize]=(byte)grayvalue;
Without any judgement about the sanity of the rest of it -- if you are
working with 16-bits-per-channel pixels, you almost certainly don't want to
be casting things to bytes. Try a 16-bit type, such as ushort.

Signature
Chris Priede
allanon76@gmail.com - 22 Dec 2005 16:29 GMT
Chris Priede ha scritto:
> Hi,
>
[quoted text clipped - 12 lines]
> --
> Chris Priede
I've an error if I make as you suggest. (i've already tried)
with the format Format64bppArgb i've 2 byte per channel but i don't
know how to set
these 2 byte.
If I use SetPixel i can use Color but i can set only 256 value per
channel and it is very slow
using LockBits and BitmapData i've no idea how to set correctly
pixel's image
I've asked for an alternative to my code if it is a bad code...