Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Detecting a blank or empty bmp file

Posted on 2006-11-21
2
Medium Priority
?
570 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 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