Solved

Detecting a blank or empty bmp file

Posted on 2006-11-21
2
522 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
2 Comments
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
Comment Utility
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
Comment Utility
That is exactly what  I needed.

Thank you for your help in this.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now