Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
How do I detect if an image is black

What I have tried:

The image which I want to detect is completely black
Posted
Updated 5-Feb-20 2:45am
Comments
Member 14589606 5-Feb-20 19:48pm    
Everytime I try to run it the console application shuts down or gives an invalid path format, and with right format it closes, any ideas?

1 solution

Look at the pixels (this may help: Bitmap.GetPixel(Int32, Int32) Method (System.Drawing) | Microsoft Docs[^] ) and compare them to Color.Black

What did you expect us to tell you to do?
 
Share this answer
 
Comments
Richard MacCutchan 5-Feb-20 8:19am    
I was always taught that black is the absence of light, so you cannot actually see it. I guess computers have better eyesight. :)
OriginalGriff 5-Feb-20 8:41am    
I know that it moves at the Speed of Dark, which is faster than the Speed of Light because the dark always manages to get out of the way before the light arrives...
Member 14589606 6-Feb-20 18:49pm    
I try to run this code but it closes immediately

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\temp\mybmp.jpg";

Bitmap image = new Bitmap(path, true);

Console.WriteLine(image.PixelFormat);



}






}



}
Member 14589606 6-Feb-20 18:50pm    
The path is correct, I added the reference

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900