简体   繁体   中英

How do you get pixel information from an Image object in windows?

I have an Image object from the Windows Image Class and I want to get information on specific pixels.

Like, for example, if I have:

Image* myImage = Image::FromFile(L"example.jpg");

I would like to call something like:

myImage->GetPixel(400,400).red;

that should tell me the value of red for the pixel at coordinates 400x400.

But there is no such method, or at least I'm unable to find it. There's only a method for getting the pixel format, which doesn't help me.

How can I go about getting information on specific pixels?

More info on the class: http://msdn.microsoft.com/en-us/library/windows/desktop/ms534462(v=vs.85).aspx

Use the file or stream to create a Bitmap object instead:

Bitmap *myBitmap = new Bitmap("example.jpg");
Color pixelColor;
myBitmap->GetPixel(400, 400, &pixelColor);
cout<<(int)pixelColor.GetRed()<<endl;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM