i am developing an app which allows user to color the images. i have the color matrix of the color i want to apply,but the problem is instead of changing color of x y coordinates whole image gets colored. i don't know how to apply the colormatix to开发者_开发知识库 specified coordinates of the image. i am using
matrix = new float[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, };
imageview.setColorFilter(new ColorMatrixColorFilter(matrix));
i am looking for something like imageview.SetPixelColorMatrix(x,y,matrix);
can anyone help me?
You can't manipulate an imageView by pixels. You need to to create a bitmap first (with BitmapFactory e.g.), then you can use it's getPixel(x,y) method to get the color of the selected pixel. It will return the color in a form of int. Get the color components then with Color.alpha(int), Color.red(int)... Do your calculations, then change the pixel with setPixel(int x, int y, int color). And set the bimtap as the content of your imageview with it's setImageBitmap() method.
精彩评论