Oliver Dixon
Oliver Dixon

Reputation: 7405

How to get RGB values from the Paint object

I have the following:

mPaintRefernce.getColor()

How would I retrieve the RGB values in the range of 0-255, so Red = 200, Blue = 120 etc?

Upvotes: 0

Views: 1737

Answers (1)

Glenn
Glenn

Reputation: 12809

That's possible, use the android.graphics.Color class provided by android framework

  1. Color.red(int color); to get the red integer value from color
  2. Color.green(int color); to get the green integer value from color
  3. Color.blue(int color); to get the blue integer value from color

For example, to get the red color.

int red = Color.red(mPaintRefernce.getColor());

Upvotes: 4

Related Questions