BENZG55 BENZG55 - 11 months ago 54
Android Question

White line bug using Colormatrix

So I have a HUGE problem. I can't solve it for years so please anybody who can help - it would be amazing.
So the problem is with ColorMatrix. As you can see in the picture when I add the effect on the photo and save it to my memory I get that kind of picture with a little white line in the left. The funny fact is that when I increase contrast for example to 7 this line became more and more bigger. So the problem as I guess is with contrast and brightness. Anyway it works great and with anything else I'm satisfied...just only this one bug which will kill me someday I guess. Any help?
My code:

public void effect(View view) {
float contrast = 1;
float brightness = 0;

Bitmap.Config config = bmp.getConfig();
if (config == null) {
config = Bitmap.Config.ARGB_8888;

operation = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), config);

ColorMatrix cm = new ColorMatrix(new float[]
contrast, 0, 0, 0, brightness,
0, contrast, 0, 0, brightness,
0, 0, contrast, 0, brightness,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1
Canvas canvas = new Canvas(operation);

Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(cm));
canvas.drawBitmap(bmp, contrast, brightness, paint);



IMAGE OF BUG. The white line in the left

Anyone who will help with this. THANK YOU!


So I want to post the answer to my problem. I was so dumb..- x and y have to be 0 0 instead of writing contrast and brightness.

Solved line:

canvas.drawBitmap(bmp, 0, 0, paint);