473,327 Members | 2,069 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,327 software developers and data experts.

Find out how many colors in a Bitmap

I need to know how many colors in the color table are actually used.

Do I need to use Windows API?

I been searching the Bitmap doc and can't find a property that would help.

Is there a way other than Windows API to get that information?

Thanks
PS
If I type: Bitmap1.Entries.
Intelisense gives many options that do not appear as Bitmap.Entries
properties.
I assume those are general array properties and are not specific for
Bitmap.Entries.
Right?
Aug 2 '07 #1
5 3322
I meant Windows Struct not API

>I need to know how many colors in the color table are actually used.

Do I need to use Windows API?

I been searching the Bitmap doc and can't find a property that would help.

Is there a way other than Windows API to get that information?

Thanks
PS
If I type: Bitmap1.Entries.
Intelisense gives many options that do not appear as Bitmap.Entries
properties.
I assume those are general array properties and are not specific for
Bitmap.Entries.
Right?

Aug 2 '07 #2
On 2 Ago, 18:04, " active" <activeNOS...@a-znet.comwrote:
I meant Windows Struct not API
I need to know how many colors in the color table are actually used.
Do I need to use Windows API?
I been searching the Bitmap doc and can't find a property that would help.
Is there a way other than Windows API to get that information?
Thanks
PS
If I type: Bitmap1.Entries.
Intelisense gives many options that do not appear as Bitmap.Entries
properties.
I assume those are general array properties and are not specific for
Bitmap.Entries.
Right?

Have you taken a look at :

System.Drawing.Imaging.PixelFormat
System.Drawing.Imaging.ColorPalette

?

T

Aug 2 '07 #3
System.Drawing.Imaging.PixelFormat
just tells max colors
System.Drawing.Imaging.ColorPalette
ColorPalette only has property Entries that might help but it is simply a
array of maxcolor size, or maybe it's always 256, I forgot. Anyone know?

Seems like it must know the colors used because if it writes a BMP file it
needs to write that value. Maybe it calculates it then? Anyone know?

From other post I've learned that what you see and what gets written may not
agree so maybe it does it calculates it then.

Thanks
"to**************@uniroma1.it" <To**************@gmail.comwrote in message
news:11*********************@x40g2000prg.googlegro ups.com...
On 2 Ago, 18:04, " active" <activeNOS...@a-znet.comwrote:
>I meant Windows Struct not API
>I need to know how many colors in the color table are actually used.
Do I need to use Windows API?
I been searching the Bitmap doc and can't find a property that would
help.
Is there a way other than Windows API to get that information?
Thanks
PS
If I type: Bitmap1.Entries.
Intelisense gives many options that do not appear as Bitmap.Entries
properties.
I assume those are general array properties and are not specific for
Bitmap.Entries.
Right?


Have you taken a look at :

System.Drawing.Imaging.PixelFormat
System.Drawing.Imaging.ColorPalette

?

T

Aug 2 '07 #4
On 2 Ago, 21:42, " active" <activeNOS...@a-znet.comwrote:
System.Drawing.Imaging.PixelFormat
just tells max colors
System.Drawing.Imaging.ColorPalette

ColorPalette only has property Entries that might help but it is simply a
array of maxcolor size, or maybe it's always 256, I forgot. Anyone know?

Seems like it must know the colors used because if it writes a BMP file it
needs to write that value. Maybe it calculates it then? Anyone know?

From other post I've learned that what you see and what gets written may not
agree so maybe it does it calculates it then.

Thanks

"tommaso.gasta...@uniroma1.it" <Tommaso.Gasta...@gmail.comwrote in message

news:11*********************@x40g2000prg.googlegro ups.com...
On 2 Ago, 18:04, " active" <activeNOS...@a-znet.comwrote:
I meant Windows Struct not API
I need to know how many colors in the color table are actually used.
Do I need to use Windows API?
I been searching the Bitmap doc and can't find a property that would
help.
Is there a way other than Windows API to get that information?
Thanks
PS
If I type: Bitmap1.Entries.
Intelisense gives many options that do not appear as Bitmap.Entries
properties.
I assume those are general array properties and are not specific for
Bitmap.Entries.
Right?
Have you taken a look at :
System.Drawing.Imaging.PixelFormat
System.Drawing.Imaging.ColorPalette
?
T- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
If you need the *exact* number, I am afraid you have no choice but to
scan the bitmap (use c# and pointers) and count the distinct colors.
T

Aug 3 '07 #5

>
If you need the *exact* number, I am afraid you have no choice but to
scan the bitmap (use c# and pointers) and count the distinct colors.
T
I was thinking of BITMAPINFOHEADER

do you know the difference between BiClrUsed and BiClrImportant

What I want is, no mater how big the table is, I want to know how many
"useful" colors there are in it.

I've seen 256 color tables with BiCltUsed=16

And everything after the 16th color is junk.

If I have to scan the Bitmap data I can use

If biClrUsed 0 Then

NColor = CInt(biClrUsed)

ElseIf biBitCount < 24 Then

NColor = 1 << biBitCount

Else

NColor = 0

End If

This seems to work.

But can't biBitCount be <24 when biClrUsed >0?

I was hoping for a bitmap "number used" property.



thanks




Aug 5 '07 #6

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

Similar topics

0
by: R.Wieser | last post by:
Hello All, I would like to be able to edit a .BMP-file, while retaining it's color-depth & colors. Actually, I want to cut small pieces outof one .BMP, and store it into another one. Jup,...
0
by: Eric | last post by:
I have written a C# program that creates a new bitmap: Bitmap ChartBitmap = new Bitmap( 780, 360 ); then I create a button which copies that bitmap into the clipboard: ...
3
by: Typpo | last post by:
Hi all, I'm trying to compare a color returned by a Bitmap's GetPixel method to a normal static color of the Color class. My problem: after setting a pixel to a certain color, the color...
0
by: josemarciano | last post by:
Hi. In an ASP.NET page, I am converting from a TIFF picture, that has a palette of 2 colors (1 bit), to a GIF, using the the code below, and it works fine. The problem is that the GIF always...
2
by: fripper | last post by:
I want to generate a graphic in a picture box control where the color of each pixel is determined by particular values calculated for each pixel. These values are manipulated in such a way that I...
0
by: Lars Netzel | last post by:
Hi I have the following code (never mind the actually logic in this, I know it sucks) which is very basic and a first try to create some kind of graph but I'm stuck on the quality it seems like...
2
by: Piotrekk | last post by:
Hi I have a problem. I open bitmap file, load it to memory decrease color palette by proceeding Euclidean distance. As a result i have image reduced to - for example 18 colors. Once i save it -...
14
by: =?Utf-8?B?Sm9lIFRob21wc29u?= | last post by:
I have a Windows form program written in C# 2005. I continually read a stream of data via TCP that comes from a video camera (NTSC). When I have all the data for one frame I update a picturebox...
9
Thekid
by: Thekid | last post by:
I want to take a simple bitmap which has 6 horizontal lines of color in it like this: red blue green red blue green I want to move the lines of colors around like this: red red
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.