PDA

View Full Version : Wrong Gray Scale



Unregistered
June 6, 2005, 10:23:26
Hello

I use format ICY8 for images monochromatic.
Save a copy of the image on disc, when the callback from disc I visualize it in "picture box",
all works correctly.
If not save on disc, convert the image in "bitmap", when visualize in box the image.
it is false colors, is not gray scale.
Where mistake ?

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

...
ImagingControl1.MemorySaveImage("C:img3fimg1.bmp");
PictureBox1.Image = System.Drawing.Image.FromFile("C:img3fimg1.bmp");

********* GRAY SCALE OK
.....

Bitmap bmp1 = ImagingControl1.ImageActiveBuffer.Bitmap;
PictureBox1.Image = bmp1;


************ WRONG COULOR ScALE

Best regards

Stefan Geissler
June 6, 2005, 12:08:20
Hello

You need to create a temporary color palette, that must be passed to the Bitmap object.


Bitmap bmp1 = IcImagingControl1.ImageActiveBuffer.Bitmap;
System.Drawing.Imaging.ColorPalette tmpPal = bmp1.Palette;
for( int i = 0; i < 256; i++ )
{
tmpPal.Entries[i] = Color.FromArgb(i,i,i);
}
bmp1.Palette = tmpPal;
PictureBox1.Image = bmp1;

For some unknown reasons, this works only in a copy of the color palette.