Giter Site home page Giter Site logo

Comments (7)

matbird avatar matbird commented on June 20, 2024

mCameraView.addCallback(new CameraView.Callback() {
@OverRide
public void onPictureTaken(CameraView cameraView, byte[] data) {
super.onPictureTaken(cameraView, data);
// 发现这个地方的data出来就已经旋转了
image2.setImageBitmap(BitmapFactory.decodeByteArray(data, 0, data.length));
mCameraView.cropImage(data, new SmartCameraView.CropCallback() {
@OverRide
public void onCropped(Bitmap bitmap) {
if(bitmap != null){
// testImageView.setImageBitmap(bitmap);
mPreview.setImageBitmap(bitmap);
String saveString = Utils.saveBitmap(bitmap);
showTip(saveString);
mCameraView.stopScan();
}
}
});
}
});

from smartcamera.

matbird avatar matbird commented on June 20, 2024

google/cameraview#22

from smartcamera.

pqpo avatar pqpo commented on June 20, 2024

下个版本我更新一下,如果你解决了也可以给我提个 merge。

from smartcamera.

pqpo avatar pqpo commented on June 20, 2024

#8

from smartcamera.

jinke1984 avatar jinke1984 commented on June 20, 2024

在三星的手机里面也发现了这种情况,我修改了下cropImage这个方法就可以了
public void cropImage(final byte[] data, final CropCallback cropCallback) {
new Thread() {
@OverRide
public void run() {
super.run();
int degress = 0;
Rect revisedMaskRect = getAdjustPictureMaskRect();
try{
final ExifInterface exifInterface = new ExifInterface(FormatTools.getInstance().Byte2InputStream(data));
final int attributeInt = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_UNDEFINED);
switch (attributeInt) {
case ExifInterface.ORIENTATION_ROTATE_90:
Log.e("jinke","90");
degress = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
Log.e("jinke","180");
degress = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
Log.e("jinke","270");
degress = 270;
break;
default:
break;
}
}catch (IOException e){
e.printStackTrace();
}
final Matrix matrix = new Matrix();
matrix.setRotate(degress);
Bitmap tempBit = BitmapFactory.decodeByteArray(data, 0, data.length);
Bitmap bitmapSrc = Bitmap.createBitmap(tempBit, 0, 0, tempBit.getWidth(), tempBit.getHeight(), matrix, true);
if (revisedMaskRect != null) {
final Bitmap bitmap = Bitmap.createBitmap(bitmapSrc, revisedMaskRect.left,
revisedMaskRect.top, revisedMaskRect.width(), revisedMaskRect.height());
bitmapSrc.recycle();
tempBit.recycle();
post(new Runnable() {
@OverRide
public void run() {
cropCallback.onCropped(bitmap);
}
});
return;
}
post(new Runnable() {
@OverRide
public void run() {
cropCallback.onCropped(null);
}
});
}
}.start();
}

from smartcamera.

pqpo avatar pqpo commented on June 20, 2024

使用的是 com.android.support:exifinterface ?

from smartcamera.

pqpo avatar pqpo commented on June 20, 2024

v1.3.0 版本已解决

from smartcamera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.