Solved

Detecting a blank or empty bmp file

Posted on 2006-11-21
2
556 Views
Last Modified: 2008-03-10
I would like to know if there is a way to detect a blank bmp file.

Through various ways found on internet, I am able to convert a image to grayscale as well as invert the images but I would like to know if there is a way to see this bmp consists black and white color in it.

In other words, if I have a empty bmp. I can invert the image to black. So my output now is all black. If I detect all black in bmp and no white that means it is empty since it has only one color. If it were not empty, it would have white somewhere.

How can I detect this colors (in my case, only black or white) in a bmp file programmatically.

I am using C# and this is all about windows application.

Thank you in advance,
0
Comment
Question by:sovroc81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 17991434
When you say "emtpy" I assume you mean every pixel is of the same color, yes ?

bool IsBlank(Bitmap b){
      Color c = b.GetPixel(0,0);
      for (int x = 0; x < b.Width; x++){
            for (int y = 0; y < b.Height; y++){
                  if (c == b.GetPixel(x,y)){
                        return false;
                  }
            }
      }
      return true;
}
0
 

Author Comment

by:sovroc81
ID: 17991847
That is exactly what  I needed.

Thank you for your help in this.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question