简体   繁体   English

Android图像处理,像素颜色和阴影

[英]Android Image Processing,Pixel colors and shades

I am working a color pallet application where i have to generate different shades of a color and convert the same into some other color and its shades. 我正在使用一个调色板应用程序,在该应用程序中,我必须生成一种颜色的不同阴影并将其转换为其他颜色及其阴影。 This is code to get all pixels from a bitmap. 这是从位图获取所有像素的代码。

Here mImage is my bitmap. 这里mImage是我的位图。

        int width = mImage.getWidth();
        int height = mImage.getHeight();
        int[] pixels = new int[width * height];
        mImage.getPixels(pixels, 0, width, 0, 0, width, height);

You can further see this links that possibly tell you on how to generate shades. 您可以进一步看到此链接,这些链接可能会告诉您如何生成阴影。

Problem : i am getting all colors in integer values like -34454323 . 问题:我正在使用-34454323之类的整数值获取所有颜色。 And i am very much confused about how to find that given integer code is shade of some pure color or itself a pure color. 我对于如何找到给定的整数代码是某种纯色阴影或本身是纯色感到非常困惑。

Another question: Is there any direct method to change the hue and saturation property of a pixel to some targeted pixel. 另一个问题:是否有任何直接方法可以将像素的色相和饱和度属性更改为某些目标像素。

Like converting a dark blue pixel to light red pixel. 就像将深蓝色像素转换为浅红色像素一样。

您可以使用BitmapShader,这是Romain Guy提供的关于它的不错的教程http://www.curious-creature.org/2012/12/13/android-recipe-2-fun-with-shaders/

The reason you're getting such strange errors is because getPixels returns and array "packed ints" - each one representing a Color object (see full docs here ). 之所以会出现这种奇怪的错误,是因为getPixels返回了数组“ packed ints”-每个数组都代表一个Color对象(请参见此处的完整文档)。 Each 8-bits of the int are B,G,R color respectively. int的每个8位分别是B,G,R颜色。

If you want the exact values for RGB of a pixel you will need to do something like 如果您想要像素的RGB的确切值,则需要执行以下操作

// code untested
int R = (intcolor >> 16) & 0xff;
int G = (intcolor >> 8) & 0xff;
int B = intcolor & 0xff;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM