I have a class that extends View. The class is created in a fragment that contains a seekbar. Using the code below, I pass the seekbar value to the view class via seekbar.setSatVal(value)
.
我有一个扩展View的类。该类在包含搜索条的片段中创建。使用下面的代码,我通过seekbar.setSatVal(value)将搜索栏值传递给视图类。
public void setSatValue(float value){
mValue = value/100; //seekbar goes from 0 to 100
setVal(mValue);
}
I then get the RGB values from the bitmap I passed (not shown in code) and convert them to HSV values.
然后我从我传递的位图中获取RGB值(未在代码中显示)并将它们转换为HSV值。
int mPixel = mBitmap.getPixel(1,1);
hsv = new float[3];
r = Color.red(mPixel);
g = Color.blue(mPixel);
b = Color.green(mPixel);
Color.RGBToHSV(r, g, b, hsv);
I know that I have to use Color.HSVToColor
to convert HSV values back to color.
我知道我必须使用Color.HSVToColor将HSV值转换回颜色。
How do I modify the HSV values? hue: hsv[0], saturation: hsv1, value: hsv[2] I have read through the color documentation and know the values each takes.
如何修改HSV值? hue:hsv [0],饱和度:hsv1,值:hsv [2]我已阅读了颜色文档并了解了每个值。
1 个解决方案
#1
As suggested, this should work as I have implemented the same in Android -
正如所建议的那样,这应该可行,因为我在Android中实现了相同的功能 -
float[] hsv = new float[3];
Color.RGBToHSV(red,green,blue,hsv);
hsv[0]=hue; //hue
hsv[1]=sat; //saturation
hsv[2]=val; //brightness
hue
sat
and val
can be any user defined or calculated values.
hue sat和val可以是任何用户定义或计算的值。
#1
As suggested, this should work as I have implemented the same in Android -
正如所建议的那样,这应该可行,因为我在Android中实现了相同的功能 -
float[] hsv = new float[3];
Color.RGBToHSV(red,green,blue,hsv);
hsv[0]=hue; //hue
hsv[1]=sat; //saturation
hsv[2]=val; //brightness
hue
sat
and val
can be any user defined or calculated values.
hue sat和val可以是任何用户定义或计算的值。