开发者

Android color picker - updating color array

I'm trying to create a color picker for Android that looks like a minimalist开发者_运维知识库ic 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!


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.


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

  • Code: http://code.google.com/p/openintents/source/browse/#svn/trunk/ColorPicker
  • Screenshots/download: http://www.openintents.org/en/colorpicker
  • Intent specification: http://www.openintents.org/en/node/670


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).


Can this be applied to an image color picker as well?

Use case:

  1. Select a particular pixel on an image.
  2. The pixel selected generates a color on a rectangle shape.
  3. Perhaps generating color codes for the pixel selected?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜