how do i convert a 24 bit color image into 8 bit grey scale image
thank you everybody in this group for their help and suggestions.
i need to convert 24 bit image into 8 bit grey scal image .
how can i do it
i dont have any idea about it
i want know how windows stores bmp file in a system completely
can anyone suggest me where can i get complete tutorial about this
thksa in advance...
# 1 Re: how do i convert a 24 bit color image into 8 bit grey scale image
R+B+G/3 = greyscale pixel -- you can either replace all 3 of RGB with that value or use just the value. The first method is to reuse your 24 bit memory / image work if you were already displaying it or the like. The second method truely is greyscale and uses 1/3 the storage space, its the better way to go most of the time.
there are many sites on bmp, just google "bmp file format. BMP can contain compression of sorts and can be a pain to unravel, fortunately good window's IDEs have bmp code built into them...
jonnin at 2007-11-11 20:59:05 >

# 2 Re: how do i convert a 24 bit color image into 8 bit grey scale image
I found the following formula: greypixel = 0.3 * red + 0.59 * green + 0.11 * blue. So here's one implementation of rgb->greyscale conversion. Note that I'm converting 24bit color images to 24bit greyscale which is not the best solution since a greyscale image requires only 8bit/pixel. In addition to 24bit rgb images I also added support for converting indexed bitmaps (4bit, 8bit) which require only manipulation of the corresponding color tables (pixels in the picture remain unchanged).
I wrote this little demo 2-3 years ago and it deals with bitmap trasparency so I just added this very simple conversion. The attached zip contains source files only. Unfortunatly the exe is too large to upload (100kb is the limit)
Ivan** at 2007-11-11 21:00:06 >

# 3 Re: how do i convert a 24 bit color image into 8 bit grey scale image
I uploaded trimage.exe to programmersheaven so here's the link:
http://www.programmersheaven.com/download/51414/download.aspx
Ivan** at 2007-11-11 21:01:10 >

# 5 Re: how do i convert a 24 bit color image into 8 bit grey scale image
so pls help
In BCB it's quite simple:
fisrts create an 8bit bitmap:
Graphics::TBitmap* bmp8bit = new Graphics::TBitmap();
bmp8bit->PixelFormat = pf8bit;
Now simply copy 24 bit greyscale image into 8 bit image discarding the redundant bytes
bmp8bit->Assign(bmp24bit);
That's all it takes
If you're using win32 api then it's probably somewhat harder, but I think iz should involve using CreateBitmap(Indirect) and GetDIBits to get the pixels of an 24 bit image and SetDIBits to transfer those into an 8 bit image
Ivan** at 2007-11-11 21:03:09 >
