当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Samsung Galaxy S6 bitmap rotation artifacting

问题描述:

I am creating a scanning app where the user takes a picture of a label and the app will then parse the image for the string on it. There is an issue ONLY on my Samsung Galaxy S6 running 5.0.2.

Steps that happen are:

  1. Take a picture through the app

  2. Grab a cropped image and rotate it:

    Image artifacting

It is worth noting that the pixelated green and yellow areas are distorted assets that I use in the activity that contains the camera preview.

Every other phone that I have tested with(Nexus 6 running N preview) (HTC 1 running Lollipop) (Nexus 5 running Marshmallow) has shown the correct cropped/rotated image.

This is what it is supposed to look like.

The problem was on this line of code

bitmap = Bitmap.createBitmap(bmp,

xStartPosition,yStartPosition,barCodeViewWidth,barCodeViewHeight,mtx,false);

Where bmp is the source image, and mtx is

Matrix mtx = new Matrix();

mtx.postRotate(90);

The solution for this was to split the call into a crop AND THEN a rotate which produces the correct post image.

bitmap = Bitmap.createBitmap(bmp,

xStartPosition,yStartPosition,barCodeViewWidth,barCodeViewHeight,null,false);

bitmap = Bitmap.createBitmap(bitmap,0,0, bitmap.getWidth(), bitmap.getHeight(),mtx,false);

So I have several questions

  1. Is This an actual known issue with Samsung Galaxy S6 phones? Is this just my phone?

  2. Why is the image artifacting including app assets? Is this a form of buffer over flow?

  3. Why did the crop and rotate in the same step break it so badly? why did splitting it apart fix it?

分享给朋友:
您可能感兴趣的文章:
随机阅读: