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.
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 . 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 ). Each 8-bits of the int are B,G,R color respectively.
If you want the exact values for RGB of a pixel you will need to do something like
// code untested
int R = (intcolor >> 16) & 0xff;
int G = (intcolor >> 8) & 0xff;
int B = intcolor & 0xff;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.