I am using getpixels() and setpixels() api. From Bitmap using getpixel api getting one by one pixel and doing some modification and setting the pixel, doing this operation for all pixels in a loop. I could see same alpha value for all pixels not able to find the reason. Please suggest a solution.
int width, height;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
int[] pix = new int[width * height];
bmpOriginal.getPixels(pix, 0, width, 0, 0, width, height);
int R, G, B, A;
float[] hsv = new float[3];
float[] hsv2 = new float[3];
float[] hsv3 = new float[3];
for (int y = 0; y < height; y++){
for (int x = 0; x < width; x++)
{
int index = y * width + x;
R = (pix[index] >> 16) & 0xff; //bitwise shifting
G = (pix[index] >> 8) & 0xff;
B = pix[index] & 0xff;
Color.RGBToHSV(R, G, B, hsv);
int value = tempBitmap.getPixel(x, y);
Color.colorToHSV(value, hsv2);
int x = Color.HSVToColor(hsv3);
pix[index] = x;
}
}
bmpOriginal.setPixels(pix, 0, width, 0, 0, width, height);
Use setAntiAlias(true)
api on your paint object to turn on anti aliasing.
Also try setFilterBitmap(true)
on paint.
Make a BitmapDrawable
out of your bitmap. Then, call mBmpdrawable.setAntiAlias(true);
before using it. Also try calling mBmpdrawable.setFilterBitmap(true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With