ImageAndLayout.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. package com.epson.cameracopy.printlayout;
  2. import android.os.Parcel;
  3. import android.os.Parcelable;
  4. import android.support.annotation.NonNull;
  5. import android.support.annotation.VisibleForTesting;
  6. import com.epson.cameracopy.alt.SimpleBmpMerger;
  7. import epson.print.Util.ImageFileUtil;
  8. import epson.print.Util.OpenCvHelper;
  9. import java.io.File;
  10. import java.util.ArrayList;
  11. import java.util.Arrays;
  12. import java.util.LinkedList;
  13. import org.opencv.core.Core;
  14. import org.opencv.core.CvType;
  15. import org.opencv.core.Mat;
  16. import org.opencv.core.MatOfInt;
  17. import org.opencv.core.MatOfPoint2f;
  18. import org.opencv.core.Point;
  19. import org.opencv.core.Scalar;
  20. import org.opencv.core.Size;
  21. import org.opencv.imgcodecs.Imgcodecs;
  22. import org.opencv.imgproc.Imgproc;
  23. public class ImageAndLayout implements Parcelable {
  24. static final /* synthetic */ boolean $assertionsDisabled = false;
  25. public static final Parcelable.Creator<ImageAndLayout> CREATOR = new Parcelable.Creator<ImageAndLayout>() {
  26. public ImageAndLayout createFromParcel(Parcel parcel) {
  27. return new ImageAndLayout(parcel);
  28. }
  29. public ImageAndLayout[] newArray(int i) {
  30. return new ImageAndLayout[i];
  31. }
  32. };
  33. private int mInterpolation;
  34. private boolean mIsPaperLandscape;
  35. private double mOffsetX;
  36. private double mOffsetY;
  37. private int mOpenCvExifRotation;
  38. private boolean mOpenCvExifRotationCancel;
  39. private String mOrgFilename;
  40. private double mPrintTargetHeight;
  41. private double mPrintTargetWidth;
  42. private int mPrintableAreaHeight;
  43. private int mPrintableAreaWidth;
  44. private int mRotation;
  45. public int describeContents() {
  46. return 0;
  47. }
  48. static {
  49. System.loadLibrary("opencv_java3");
  50. }
  51. public ImageAndLayout() {
  52. this.mInterpolation = 2;
  53. this.mIsPaperLandscape = true;
  54. this.mOpenCvExifRotationCancel = true;
  55. }
  56. public void writeToParcel(Parcel parcel, int i) {
  57. parcel.writeInt(this.mPrintableAreaWidth);
  58. parcel.writeInt(this.mPrintableAreaHeight);
  59. parcel.writeString(this.mOrgFilename);
  60. parcel.writeDouble(this.mPrintTargetWidth);
  61. parcel.writeDouble(this.mPrintTargetHeight);
  62. parcel.writeDouble(this.mOffsetX);
  63. parcel.writeDouble(this.mOffsetY);
  64. parcel.writeInt(this.mRotation);
  65. parcel.writeBooleanArray(new boolean[]{this.mIsPaperLandscape});
  66. }
  67. private ImageAndLayout(Parcel parcel) {
  68. this.mInterpolation = 2;
  69. this.mPrintableAreaWidth = parcel.readInt();
  70. this.mPrintableAreaHeight = parcel.readInt();
  71. this.mOrgFilename = parcel.readString();
  72. this.mPrintTargetWidth = parcel.readDouble();
  73. this.mPrintTargetHeight = parcel.readDouble();
  74. this.mOffsetX = parcel.readDouble();
  75. this.mOffsetY = parcel.readDouble();
  76. this.mRotation = parcel.readInt();
  77. boolean[] zArr = new boolean[1];
  78. parcel.readBooleanArray(zArr);
  79. this.mIsPaperLandscape = zArr[0];
  80. this.mOpenCvExifRotationCancel = true;
  81. }
  82. public void setOpenCvExifRotationCancel(boolean z) {
  83. this.mOpenCvExifRotationCancel = z;
  84. }
  85. public void setLayoutAreaSize(int i, int i2) {
  86. this.mPrintableAreaWidth = i;
  87. this.mPrintableAreaHeight = i2;
  88. }
  89. public void setLayout(double d, double d2, double d3, double d4, int i) {
  90. this.mPrintTargetWidth = d;
  91. this.mPrintTargetHeight = d2;
  92. this.mOffsetX = d3;
  93. this.mOffsetY = d4;
  94. this.mRotation = i;
  95. }
  96. public void setPaperIsLandscape(boolean z) {
  97. this.mIsPaperLandscape = z;
  98. }
  99. public boolean isPaperLandscape() {
  100. return this.mIsPaperLandscape;
  101. }
  102. public void setOrgFileName(String str) {
  103. this.mOrgFilename = str;
  104. }
  105. public String getOrgFileName() {
  106. return this.mOrgFilename;
  107. }
  108. private double[] getExRate(int[] iArr) {
  109. int i;
  110. int i2;
  111. double[] dArr = {1.0d, 1.0d};
  112. if (iArr == null || iArr.length < 2 || (i = this.mPrintableAreaWidth) <= 0 || (i2 = this.mPrintableAreaHeight) <= 0) {
  113. return dArr;
  114. }
  115. dArr[0] = ((double) iArr[0]) / ((double) i);
  116. dArr[1] = ((double) iArr[1]) / ((double) i2);
  117. return dArr;
  118. }
  119. static Mat new3x2Mat(double d, double d2, double d3, double d4, double d5, double d6) {
  120. final double d7 = d;
  121. final double d8 = d2;
  122. final double d9 = d3;
  123. final double d10 = d4;
  124. final double d11 = d5;
  125. final double d12 = d6;
  126. return new Mat(2, 3, 6) {
  127. {
  128. put(0, 0, d7, d8, d9);
  129. put(1, 0, d10, d11, d12);
  130. }
  131. };
  132. }
  133. static Mat getTransformMat0(Size size, Size size2, double d, double d2, int i) {
  134. MatOfPoint2f matOfPoint2f;
  135. Size size3 = size;
  136. Size size4 = size2;
  137. double d3 = size3.width;
  138. double d4 = size3.height;
  139. MatOfPoint2f matOfPoint2f2 = new MatOfPoint2f(new Point(0.0d, 0.0d), new Point(0.0d, size4.height), new Point(size4.width, 0.0d));
  140. switch (i & 3) {
  141. case 1:
  142. double d5 = d3 + d;
  143. double d6 = d2 + 0.0d;
  144. matOfPoint2f = new MatOfPoint2f(new Point(d5, d6), new Point(d + 0.0d, d6), new Point(d5, d4 + d2));
  145. break;
  146. case 2:
  147. double d7 = d3 + d;
  148. double d8 = d4 + d2;
  149. matOfPoint2f = new MatOfPoint2f(new Point(d7, d8), new Point(d7, d2 + 0.0d), new Point(d + 0.0d, d8));
  150. break;
  151. case 3:
  152. double d9 = d + 0.0d;
  153. double d10 = d4 + d2;
  154. matOfPoint2f = new MatOfPoint2f(new Point(d9, d10), new Point(d3 + d, d10), new Point(d9, d2 + 0.0d));
  155. break;
  156. default:
  157. double d11 = d + 0.0d;
  158. double d12 = d2 + 0.0d;
  159. matOfPoint2f = new MatOfPoint2f(new Point(d11, d12), new Point(d11, d4 + d2), new Point(d3 + d, d12));
  160. break;
  161. }
  162. Mat affineTransform = Imgproc.getAffineTransform(matOfPoint2f2, matOfPoint2f);
  163. matOfPoint2f2.release();
  164. matOfPoint2f.release();
  165. return affineTransform;
  166. }
  167. static Mat getTransformMat1(Size size, Size size2, double d, double d2, int i) {
  168. MatOfPoint2f matOfPoint2f;
  169. Size size3 = size;
  170. Size size4 = size2;
  171. double d3 = size3.width;
  172. double d4 = size3.height;
  173. double d5 = size3.width;
  174. double d6 = size4.width;
  175. double d7 = size3.height;
  176. double d8 = size4.height;
  177. MatOfPoint2f matOfPoint2f2 = new MatOfPoint2f(new Point(0.0d, 0.0d), new Point(0.0d, size4.height), new Point(size4.width, 0.0d));
  178. switch (i & 3) {
  179. case 1:
  180. double d9 = d3 + d;
  181. double d10 = d2 + 0.0d;
  182. matOfPoint2f = new MatOfPoint2f(new Point(d9, d10), new Point(d + 0.0d, d10), new Point(d9, d4 + d2));
  183. break;
  184. case 2:
  185. double d11 = d3 + d;
  186. double d12 = d4 + d2;
  187. matOfPoint2f = new MatOfPoint2f(new Point(d11, d12), new Point(d11, d2 + 0.0d), new Point(d + 0.0d, d12));
  188. break;
  189. case 3:
  190. double d13 = d + 0.0d;
  191. double d14 = d4 + d2;
  192. matOfPoint2f = new MatOfPoint2f(new Point(d13, d14), new Point(d3 + d, d14), new Point(d13, d2 + 0.0d));
  193. break;
  194. default:
  195. double d15 = d + 0.0d;
  196. double d16 = d2 + 0.0d;
  197. matOfPoint2f = new MatOfPoint2f(new Point(d15, d16), new Point(d15, d4 + d2), new Point(d3 + d, d16));
  198. break;
  199. }
  200. Mat affineTransform = Imgproc.getAffineTransform(matOfPoint2f2, matOfPoint2f);
  201. matOfPoint2f2.release();
  202. matOfPoint2f.release();
  203. return affineTransform;
  204. }
  205. static Mat getTransformMat(Size size, Size size2, double d, double d2, int i) {
  206. double d3;
  207. double d4;
  208. Size size3 = size;
  209. Size size4 = size2;
  210. if ((i & 1) == 0) {
  211. double d5 = size3.width / size4.width;
  212. d4 = size3.height / size4.height;
  213. d3 = d5;
  214. } else {
  215. double d6 = size3.width / size4.height;
  216. d4 = size3.height / size4.width;
  217. d3 = d6;
  218. }
  219. int i2 = (int) (d3 / 2.0d);
  220. int i3 = (int) (d4 / 2.0d);
  221. switch (i & 3) {
  222. case 1:
  223. return new3x2Mat(0.0d, -d3, ((d + size3.width) - ((double) i2)) - 1.0d, d4, 0.0d, d2 + ((double) i3));
  224. case 2:
  225. return new3x2Mat(-d3, 0.0d, ((d + size3.width) - ((double) i2)) - 1.0d, 0.0d, -d4, ((d2 + size3.height) - ((double) i3)) - 1.0d);
  226. case 3:
  227. return new3x2Mat(0.0d, d3, d + ((double) i2), -d4, 0.0d, ((d2 + size3.height) - ((double) i3)) - 1.0d);
  228. default:
  229. return new3x2Mat(d3, 0.0d, d + ((double) i2), 0.0d, d4, d2 + ((double) i3));
  230. }
  231. }
  232. private Size getPrintImageSize(double[] dArr) {
  233. return new Size(this.mPrintTargetWidth * dArr[0], this.mPrintTargetHeight * dArr[1]);
  234. }
  235. private Mat getPrintMat(int[] iArr, int i, Mat mat) {
  236. switch (i & 3) {
  237. case 1:
  238. Mat mat2 = new Mat(2, 3, 6);
  239. mat2.put(0, 0, mat.get(1, 0)[0] * -1.0d);
  240. mat2.put(0, 1, mat.get(1, 1)[0] * -1.0d);
  241. mat2.put(0, 2, (mat.get(1, 2)[0] * -1.0d) + ((double) iArr[0]));
  242. mat2.put(1, 0, mat.get(0, 0)[0]);
  243. mat2.put(1, 1, mat.get(0, 1)[0]);
  244. mat2.put(1, 2, mat.get(0, 2)[0]);
  245. return mat2;
  246. case 2:
  247. Mat mat3 = null;
  248. mat3.put(0, 0, mat.get(0, 0)[0] * -1.0d);
  249. mat3.put(0, 1, mat.get(0, 1)[0] * -1.0d);
  250. mat3.put(0, 2, (mat.get(0, 2)[0] * -1.0d) + ((double) iArr[0]));
  251. mat3.put(1, 0, mat.get(1, 0)[0] * -1.0d);
  252. mat3.put(1, 1, mat.get(1, 1)[0] * -1.0d);
  253. mat3.put(1, 2, (mat.get(1, 2)[0] * -1.0d) + ((double) iArr[1]));
  254. return mat3;
  255. case 3:
  256. Mat mat4 = new Mat(2, 3, 6);
  257. mat4.put(0, 0, mat.get(1, 0)[0]);
  258. mat4.put(0, 1, mat.get(1, 1)[0]);
  259. mat4.put(0, 2, mat.get(1, 2)[0] + ((double) iArr[0]));
  260. mat4.put(1, 0, mat.get(0, 0)[0] * -1.0d);
  261. mat4.put(1, 1, mat.get(0, 1)[0] * -1.0d);
  262. mat4.put(1, 2, mat.get(0, 2)[0] * -1.0d);
  263. return mat4;
  264. default:
  265. return mat.clone();
  266. }
  267. }
  268. public Mat makePrintImageMat(Mat mat, int i, int[] iArr) {
  269. Mat transMat = getTransMat(mat, i, iArr);
  270. Mat mat2 = new Mat(iArr[1], iArr[0], mat.type());
  271. Imgproc.warpAffine(mat, mat2, transMat, mat2.size(), this.mInterpolation, 0, new Scalar(255.0d, 255.0d, 255.0d, 255.0d));
  272. transMat.release();
  273. return mat2;
  274. }
  275. private Mat getTransMat(Mat mat, int i, int[] iArr) {
  276. int[] iArr2 = new int[2];
  277. if ((i & 1) != 0) {
  278. iArr2[0] = iArr[1];
  279. iArr2[1] = iArr[0];
  280. } else {
  281. iArr2[0] = iArr[0];
  282. iArr2[1] = iArr[1];
  283. }
  284. double[] exRate = getExRate(iArr2);
  285. Size printImageSize = getPrintImageSize(exRate);
  286. double d = this.mOffsetX * exRate[0];
  287. double d2 = this.mOffsetY;
  288. int imageRotation = getImageRotation(this.mRotation);
  289. Mat transformMat = getTransformMat(printImageSize, mat.size(), d, exRate[1] * d2, imageRotation);
  290. Mat printMat = getPrintMat(iArr, i, transformMat);
  291. transformMat.release();
  292. return printMat;
  293. }
  294. private boolean affineBand(Mat mat, Mat mat2, int i, int i2, int i3, File file) {
  295. Mat clone = mat2.clone();
  296. Mat mat3 = new Mat();
  297. Size size = new Size((double) i, (double) i2);
  298. clone.put(1, 2, clone.get(1, 2)[0] - ((double) i3));
  299. Mat mat4 = null;
  300. try {
  301. Imgproc.warpAffine(mat, mat3, clone, size, this.mInterpolation, 0, new Scalar(255.0d, 255.0d, 255.0d, 255.0d));
  302. if (mat.type() == CvType.CV_8UC1) {
  303. mat4 = make24BitMatFromGrayMat(mat3);
  304. if (!Imgcodecs.imwrite(file.toString(), mat4)) {
  305. clone.release();
  306. mat3.release();
  307. if (mat4 != null) {
  308. mat4.release();
  309. }
  310. return false;
  311. }
  312. } else if (!Imgcodecs.imwrite(file.toString(), mat3)) {
  313. clone.release();
  314. mat3.release();
  315. return false;
  316. }
  317. clone.release();
  318. mat3.release();
  319. if (mat4 != null) {
  320. mat4.release();
  321. }
  322. return true;
  323. } catch (Exception unused) {
  324. clone.release();
  325. mat3.release();
  326. if (mat4 != null) {
  327. mat4.release();
  328. }
  329. return false;
  330. } catch (Throwable th) {
  331. clone.release();
  332. mat3.release();
  333. if (mat4 != null) {
  334. mat4.release();
  335. }
  336. throw th;
  337. }
  338. }
  339. private boolean makeBandImageFile(Mat mat, int i, int[] iArr, String str, LinkedList<File> linkedList) {
  340. String str2 = str;
  341. LinkedList<File> linkedList2 = linkedList;
  342. Mat transMat = getTransMat(mat, i, iArr);
  343. int i2 = 0;
  344. int i3 = 0;
  345. while (true) {
  346. int i4 = i2 + 512;
  347. if (i4 < iArr[1]) {
  348. File file = new File(str2, "bo" + i3 + ".bmp");
  349. affineBand(mat, transMat, iArr[0], 512, i2, file);
  350. if (!file.exists()) {
  351. return false;
  352. }
  353. linkedList2.addFirst(file);
  354. i3++;
  355. i2 = i4;
  356. } else {
  357. File file2 = new File(str2, "bo" + i3 + ".bmp");
  358. if (!affineBand(mat, transMat, iArr[0], iArr[1] - i2, i2, file2)) {
  359. return false;
  360. }
  361. linkedList2.addFirst(file2);
  362. return true;
  363. }
  364. }
  365. }
  366. private boolean makePrintImageFile(Mat mat, int i, int[] iArr, String str) {
  367. String parent = new File(str).getParent();
  368. LinkedList linkedList = new LinkedList();
  369. if (makeBandImageFile(mat, i, iArr, parent, linkedList) && SimpleBmpMerger.margeBmpFile(str, linkedList.iterator())) {
  370. return true;
  371. }
  372. return false;
  373. }
  374. private Mat make24BitMatFromGrayMat(Mat mat) {
  375. Mat mat2 = new Mat(mat.height(), mat.width(), CvType.CV_8UC3);
  376. Core.mixChannels(Arrays.asList(new Mat[]{mat}), Arrays.asList(new Mat[]{mat2}), new MatOfInt(0, 0, 0, 1, 0, 2));
  377. return mat2;
  378. }
  379. public boolean createPrintData(String str, boolean z, int[] iArr, int i) {
  380. Mat mat = null;
  381. try {
  382. setOpenCvJpegRotation(this.mOrgFilename);
  383. Mat imread = Imgcodecs.imread(this.mOrgFilename, -1);
  384. mat = imread.channels() == 4 ? convertRgbaToRgbTrWhite(imread) : imread;
  385. if (z) {
  386. int channels = mat.channels();
  387. if (channels != 1) {
  388. if (channels != 3) {
  389. if (mat != null) {
  390. mat.release();
  391. }
  392. File file = new File(str);
  393. if (file.exists()) {
  394. file.delete();
  395. }
  396. return false;
  397. }
  398. Imgproc.cvtColor(mat, mat, 7);
  399. Imgproc.cvtColor(mat, mat, 8, 3);
  400. }
  401. }
  402. boolean makePrintImageFile = makePrintImageFile(mat, i, iArr, str);
  403. if (mat != null) {
  404. mat.release();
  405. }
  406. if (!makePrintImageFile) {
  407. File file2 = new File(str);
  408. if (file2.exists()) {
  409. file2.delete();
  410. }
  411. }
  412. return makePrintImageFile;
  413. } catch (OutOfMemoryError unused) {
  414. if (mat != null) {
  415. mat.release();
  416. }
  417. File file3 = new File(str);
  418. if (file3.exists()) {
  419. file3.delete();
  420. }
  421. return false;
  422. } catch (Exception unused2) {
  423. if (mat != null) {
  424. mat.release();
  425. }
  426. File file4 = new File(str);
  427. if (file4.exists()) {
  428. file4.delete();
  429. }
  430. return false;
  431. } catch (Throwable th) {
  432. if (mat != null) {
  433. mat.release();
  434. }
  435. File file5 = new File(str);
  436. if (file5.exists()) {
  437. file5.delete();
  438. }
  439. throw th;
  440. }
  441. }
  442. @VisibleForTesting
  443. static Mat calc255Alpha(Mat mat) {
  444. Mat mat2 = new Mat();
  445. Core.multiply(mat, new Scalar(-255.0d), mat2);
  446. Mat mat3 = new Mat();
  447. Core.add(mat2, new Scalar(255.0d), mat3);
  448. mat2.release();
  449. return mat3;
  450. }
  451. @VisibleForTesting
  452. @NonNull
  453. static Mat convertRgbaToRgbTrWhite(Mat mat) {
  454. ArrayList arrayList = new ArrayList();
  455. Core.split(mat, arrayList);
  456. mat.release();
  457. Mat mat2 = new Mat();
  458. ((Mat) arrayList.get(3)).convertTo(mat2, CvType.CV_32FC1, 0.00392156862745098d);
  459. ((Mat) arrayList.get(3)).release();
  460. arrayList.remove(3);
  461. ArrayList arrayList2 = new ArrayList();
  462. for (int i = 0; i < 3; i++) {
  463. arrayList2.add(mat2);
  464. }
  465. Mat mat3 = new Mat();
  466. Core.merge(arrayList2, mat3);
  467. Mat mat4 = new Mat();
  468. Mat mat5 = new Mat();
  469. Core.merge(arrayList, mat4);
  470. ((Mat) arrayList.get(0)).release();
  471. ((Mat) arrayList.get(1)).release();
  472. ((Mat) arrayList.get(2)).release();
  473. mat4.convertTo(mat5, CvType.CV_32FC1);
  474. mat4.release();
  475. Mat mul = mat5.mul(mat3);
  476. mat5.release();
  477. Mat mat6 = new Mat();
  478. mul.convertTo(mat6, CvType.CV_8UC3);
  479. mul.release();
  480. Mat calc255Alpha = calc255Alpha(mat2);
  481. Mat mat7 = new Mat();
  482. calc255Alpha.convertTo(mat7, CvType.CV_8UC1);
  483. Mat mat8 = new Mat();
  484. Imgproc.cvtColor(mat7, mat8, 8, 3);
  485. Core.add(mat6, mat8, mat6);
  486. return mat6;
  487. }
  488. @NonNull
  489. private static Mat convertRgbaToRgb(Mat mat) {
  490. ArrayList arrayList = new ArrayList();
  491. Core.split(mat, arrayList);
  492. mat.release();
  493. Mat mat2 = new Mat();
  494. ((Mat) arrayList.get(3)).convertTo(mat2, CvType.CV_32FC1, 0.00392156862745098d);
  495. ((Mat) arrayList.get(3)).release();
  496. arrayList.remove(3);
  497. ArrayList arrayList2 = new ArrayList();
  498. for (int i = 0; i < 3; i++) {
  499. arrayList2.add(mat2);
  500. }
  501. Mat mat3 = new Mat();
  502. Core.merge(arrayList2, mat3);
  503. mat2.release();
  504. Mat mat4 = new Mat();
  505. Mat mat5 = new Mat();
  506. Core.merge(arrayList, mat4);
  507. ((Mat) arrayList.get(0)).release();
  508. ((Mat) arrayList.get(1)).release();
  509. ((Mat) arrayList.get(2)).release();
  510. mat4.convertTo(mat5, CvType.CV_32FC1);
  511. mat4.release();
  512. Mat mul = mat5.mul(mat3);
  513. mat5.release();
  514. Mat mat6 = new Mat();
  515. mul.convertTo(mat6, CvType.CV_8UC3);
  516. mul.release();
  517. return mat6;
  518. }
  519. private void setOpenCvJpegRotation(String str) {
  520. this.mOpenCvExifRotation = 0;
  521. if (OpenCvHelper.doseImreadRotateWithExifTag()) {
  522. this.mOpenCvExifRotation = ImageFileUtil.getExifRotationDegree(str);
  523. if (this.mOpenCvExifRotation < 0) {
  524. this.mOpenCvExifRotation = 0;
  525. }
  526. }
  527. }
  528. private int getImageRotation(int i) {
  529. if (this.mOpenCvExifRotationCancel) {
  530. i -= this.mOpenCvExifRotation;
  531. }
  532. if (i < 0) {
  533. i += (((-i) / 4) + 1) * 4;
  534. }
  535. return i % 4;
  536. }
  537. private void setInterpolation(int i) {
  538. this.mInterpolation = i;
  539. }
  540. }