?
Solved

Detecting a blank or empty bmp file

Posted on 2006-11-21
2
Medium Priority
?
566 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 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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 this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 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