0

I have some picture, example: enter image description here

and i want to get color of area in picture. example enter image description here

but i don't know how to do that.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Hello Sun
  • 133
  • 1
  • 4
  • 16
  • **No, Thank You!!** Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). Also, I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Nov 28 '12 at 03:54
  • hope this [link][1] helps you to find out the color of an area [1]: http://stackoverflow.com/a/684700/1858508 – Deepak Raj Nov 28 '12 at 04:02

3 Answers3

2

First, you cannot "generally" get the color of an area (unless you average the color of the area or some other manipulation). You will be looking for the color of a specific pixel.

From your Bitmap, call GetPixel with the X,Y coordinates of the picture where you want to get the color. See documentation here.

Edit: from the comments, see this thread to invert the color, this should be pretty straight forward from the Color returned by GetPixel

Community
  • 1
  • 1
emartel
  • 7,712
  • 1
  • 30
  • 58
  • thanks for your comment. i've read that documentation. But GetPixel method is slowly. And after i get the color, i must be analyze color to add text on this area. – Hello Sun Nov 28 '12 at 03:56
  • @HelloSun is it "too slow" for your usage? What do you mean by analyze? – emartel Nov 28 '12 at 04:02
  • i mean, i need find color of image and reverse that color for the text will be added on it. – Hello Sun Nov 28 '12 at 04:08
1

Take a look at the Bitmap.GetPixel method and see if that's appropriate; to get an entire region's colour you'll just have to write a loop that goes from the top left to bottom right pixel and does the operation.

Anything more specific we'd have to know if you're using Winforms or WPF or if you're just loading a straight bitmap from disk.

ravuya
  • 8,586
  • 4
  • 30
  • 33
  • Oh no, i using console program to load image from disk, then add text to some picture. i need find color of image and reverse that color for the text. – Hello Sun Nov 28 '12 at 04:05
0

This one has an example to get the color at a point an image

Typist
  • 1,464
  • 9
  • 14