tags:

views:

1322

answers:

3

Hi all, I'm trying to create a color picker for Android that looks like a minimalistic version of Gimp's. So, it has a hue slider and a rectangle with saturation/value variants of a color chosen in hue slider.

Question: what is the best way to create the rectangle?

Right now, I'm creating an 200x200 array of pixels, but it takes ~5sec to create and display rectangle with that array. And I need colors in rectangle to change whenever I change the value in hue slider...

Rectangle is bitmap, btw. Can I use color matrices on that and how? Any examples?

Thanks in advance!

A: 

One possibility is to pre-create the rectangles on your developer PC for each slider position, embed them as resources, and then swap in the right one when the slider changes. This may make for a portly application, but it will be nice and quick.

I have not dealt with the 2D graphics API much, so I don't know if there are other possibilities (e.g., color matrices).

CommonsWare
+1  A: 

OpenIntents has a very nice color picker you can use. It can be installed as an independent app and launched with Intents.

kostmo
+1  A: 

You can create the rectangle with saturation/value variants that change according to the selected hue, by drawing the rectangle with LinearGradients.

You can incorporate the code here: http://code.google.com/p/android-color-picker/ into your application. Seems that this is what you want.

yuku
yuku, your color picker looks great! Looking into using it for DigiClock widget, loving that it doesn't need intents and other apps to be installed, thanks a tonne!!!
DavidG