开发者

8 bit PictureBox Display Resolution

开发者 https://www.devze.com 2023-03-17 06:48 出处:网络
I want to create a 8 bit pixel image. I used to draw the image in a picture box. Bitmap b = new Bitmap(8,8);

I want to create a 8 bit pixel image. I used to draw the image in a picture box.

Bitmap b = new Bitmap(8,8);
Graphics g = Graphics.FromImage(b);
PictureBox8Bit.Image = b;

So, that code supposed to create an 8 bit pixel image. When i output the image on picture box, i cant see it clearly because its too small. What i want is how开发者_JAVA百科 to make the picture box resolution to 8 bit, or the image size. So i can see the preview in the picture box.

But when i use the code, the picturebox just show a small dot. Rather than resized to 8 bit for best view.

Thanks.


You need to differ between the bitmap dimension describing the size of the bitmap in pixels wide and pixels high, and the bitmap resolution describing the number of possible colors.

To create a 8-bit Bitmap first read the msdn documentation. There you'll find the constructor used in this snippet.

var bitmap = new Bitmap(w, h, Format8bppIndexed);

Where w and h are the width and height of the image.

Using 8-bit images uses a ColorPalette making them a bit more complicated to use.

0

精彩评论

暂无评论...
验证码 换一张
取 消