473,414 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

save a Bitmap as grayscale

I'm using bmp.Save() and the bmp is in PixelFormat.Format8bppIndexed.
But when I open the image with Gimp, it tells me that the image is RGB
and not grayscale.

Nov 17 '05 #1
8 11357
Hello

What format are you using for saving? JPEG ?

Some image file formats has a special field in their header, which is set to
1 for grayscale images, for example (or a special flag). In the case you
even don't need to write your palette to the file. So, I suppose, that you
saved your image as an ordinary 8 bpp indexed imaged, with a palette of
grayscale gradients. Yes, your image looks grayscale, but Gimp thinks it's
not, because it seeing a palette and does not analyze it.

I have similar issue with my image processing library. I was loading
grayscale JPEG, but GDI+ was creating just 8 bpp indexed image and there was
no any chance to resolve if the image is grayscale. So, I am analyzing
palette of 8 bpp indexed images, to resolve if it's grayscale or colored.

Hope you will find the way.


--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072
"RicercatoreSbadato" <em***********@yahoo.it> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I'm using bmp.Save() and the bmp is in PixelFormat.Format8bppIndexed.
But when I open the image with Gimp, it tells me that the image is RGB
and not grayscale.

Nov 17 '05 #2
Help me plz. I want to save into BMP format. Which is the flag I have
to modify? Thanks.. ;)

Nov 17 '05 #3
Oh, it's not obvious how to make it using GDI+. I can only suggest, that you
should try to use EncoderParameters class to specify, that you want to save
your image as grayscale. But there is no much documents on using it.

--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072
"RicercatoreSbadato" <em***********@yahoo.it> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Help me plz. I want to save into BMP format. Which is the flag I have
to modify? Thanks.. ;)

Nov 17 '05 #4
But U know another way to do it (whitout GDI+)?
I've seen your code of the Image Processing but neither U had resolved
this problem..

My goal is to transform a lot of image in grayscale, maybe I could use
an external module..

Nov 17 '05 #5
Hi Ricercatore,

You can create a Greayscale bitmap the same size as you original and
then call SetPixel() for each GetPixel() in the source bitmap. Then you
just Save() the greyscale bitmap.

Hope that helps,
Jan

Nov 17 '05 #6

"RicercatoreSbadato" <em***********@yahoo.it> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I'm using bmp.Save() and the bmp is in PixelFormat.Format8bppIndexed.


I haven't actually done this, but...

Doesn't that format mean indexed to a palette, not grayscale? The palette
might happen to have nothing but grays on it, but that's not the same as a
grayscale image.

Nov 17 '05 #7
You are telling me to use the "PixelFormat.Format16bppGrayScale" and
save() ?

Nov 17 '05 #8
It doesn't work.

Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Mark Johnson | last post by:
How can you save all or a portion of the Grafics object to a Image/Bitmap ? I am try to save the Images from Cards.dll to a BitMap file. I can read in the Images to the Grafics, but when I try this...
0
by: leonid | last post by:
Hello, In one of my VC++6 projects I need to save image into BMP file. I have window’s handle (HWND hwnd), device context handle (HDC hDC) and bitmap handle (HBITMAP hbit). What API function...
5
by: Dennis | last post by:
I give up...I have tried all combinations that I can think of and I can't get a bitmap converted to an icon and save it in a filestream or stream; Any help would be appreciated. -- Dennis in...
4
by: Peter Proost | last post by:
Hi group I've got a bitmap with a white background in a picturebox and I do some drawing on this bitmap but when I save the bitmap as .jpg there's some quality loss, nothing you can see if you just...
2
by: zsomi | last post by:
Hi! My problem is that I have a lot of number and I want to make a bitmap from it and after I have my bitmap a want to be able to save it. I`m working under linux. Can anybody tell me how to do...
0
by: sp | last post by:
Hi everyone, Just joined this group. I have a question about saving bitmap images from flash too a .NET site using VBScript. There are several tutorials showing how this can be done using php...
8
by: platinumhimani | last post by:
-How to convert any image(8,16,24,32 or 64-bit) to 8-bit grayscale -i have tried to convert a 24-bit image to grayscale using setpixel and getpixel functions, in vb.net but i am unable to save...
1
by: diwakar09 | last post by:
hi after doing CreateCompatibleBitmap() i have handle to bitmap, but how to save this thing in harddisk. is there any api. that will do this i am using vc++
2
VietPP
by: VietPP | last post by:
Hi everyone, I want to create a form, there will be some textbox where I can enter some information (like: Nam, age, nationality, link to my picture...). And then, there will be a button also,...
1
hi
by: milayaraja | last post by:
How to save bitmap image into postgreSQL this is my id........
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.