package epson.print; import android.graphics.Bitmap; import android.graphics.Matrix; import android.media.ExifInterface; import java.io.IOException; public class EPImageUtil { public static final String CANCEL_FILE_BASE_NAME = "cancel.dat"; public static final int RETURN_CODE_CANCLE = -257; public static native int jpegTo1BitBmpPixelRoundDown(String str, String str2, int i); public native int bmp2jpg(String str, String str2, int i); public native int color2grayscale(String str, String str2); public native int getBitCount(String str); public native int jpg2bmp(String str, String str2, int i); public native int resizeImage(String str, String str2, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10); public native int rotate180Image(String str, String str2); public native int rotateR270Image(String str, String str2); public native int rotateR90Image(String str, String str2); public native int tiff2bmp(String str, String str2); public native int writeDate(String str, String str2, int i, int i2); static { try { System.loadLibrary("epsimage"); } catch (Exception e) { e.printStackTrace(); } } public int rotateImage(String str, String str2, int i) { if (i == 90) { return rotateR90Image(str, str2); } if (i == 180) { return rotate180Image(str, str2); } if (i != 270) { return 0; } return rotateR270Image(str, str2); } public Bitmap check_rotate(String str, Bitmap bitmap) { try { int attributeInt = new ExifInterface(str).getAttributeInt(android.support.media.ExifInterface.TAG_ORIENTATION, 0); if (attributeInt != 6 && attributeInt != 3 && attributeInt != 8) { return bitmap; } Matrix matrix = new Matrix(); if (attributeInt == 3) { matrix.setRotate(180.0f); } else if (attributeInt == 6) { matrix.setRotate(90.0f); } else if (attributeInt != 8) { matrix.setRotate(0.0f); } else { matrix.setRotate(270.0f); } return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); } catch (IOException e) { e.printStackTrace(); return bitmap; } } }