我成功地实现了通过来自用户SeekBars选择的值来调整ImageView的对比度和/或亮度的功能。对于对比度,它看起来像这样(亮度类似):
// Contrast
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.set(new float[] {
scale, 0, 0, 0, translate, // Red
0, scale, 0, 0, translate, // Green
0, 0, scale, 0, translate, // Blue
0, 0, 0, 1, 0 }); // Alpha
imageView.setColorFilter(new ColorMatrixColorFilter(colorMatrix);因此,我可以通过缩放(乘法)或平移(加法) RGB值来调整对比度和/或亮度。
我如何做同样的事情(使用矩阵)来调整图像的色温?
发布于 2014-08-16 15:41:32
我刚刚为我的应用程序创建了一个这样的Matrix来调整色温。
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.set(new float[] {
RED/255.0f, 0, 0, 0, 0,
0, GREEN/255.0f, 0, 0, 0
0, 0, BLUE/255.0f, 0, 0,
0, 0, 0, 1, 0});
imageView.setColorFilter(new ColorMatrixColorFilter(colorMatrix);红色、绿色和蓝色的值可以从这里获得:http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
它的效果非常好,即使是色温非常强的图像也可以相应地进行调整:)
发布于 2018-06-06 08:44:35
我关注了destiny answer,但不得不做一些调整,下面是我是如何做到的:
let amount = 255;
let value = 0;
(1.0000* amount)/255.0, 0, 0, 0, 0,
0, ((1.0000+value)* amount)/255.0, 0, 0, 0,
0, 0, ((1.0000+value)* amount)/255.0, 0, 0,
0, 0, 0, 1, 0https://stackoverflow.com/questions/21480250
复制相似问题