EPImageCreator.java 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812
  1. package epson.print;
  2. import android.content.Context;
  3. import android.graphics.Bitmap;
  4. import android.graphics.BitmapFactory;
  5. import android.graphics.Canvas;
  6. import android.graphics.Color;
  7. import android.graphics.Paint;
  8. import android.graphics.Rect;
  9. import android.media.ExifInterface;
  10. import android.support.p000v4.view.ViewCompat;
  11. import com.epson.cameracopy.printlayout.ImageAndLayout;
  12. import org.opencv.core.Core;
  13. import org.opencv.core.CvType;
  14. import org.opencv.core.Mat;
  15. import org.opencv.core.Scalar;
  16. import org.opencv.imgcodecs.Imgcodecs;
  17. import java.io.File;
  18. import java.io.IOException;
  19. import java.util.ArrayList;
  20. import epson.common.BMPFile;
  21. import epson.common.ExternalFileUtils;
  22. import epson.common.ImageUtil;
  23. import epson.common.Info_paper;
  24. import epson.image.epsonImage;
  25. import epson.print.Util.EPLog;
  26. import epson.print.Util.ImageFormatIdentifier;
  27. import epson.print.Util.Photo;
  28. import epson.print.Util.Utils;
  29. import epson.print.phlayout.BorderedLayoutPosition;
  30. public class EPImageCreator implements CommonDefine {
  31. private static String CANCEL_FILE_NAME = null;
  32. private static final int EPS_ERR_NONE = 0;
  33. private static final Object lockObject = new Object();
  34. private Rect dst = new Rect(0, 0, 0, 0);
  35. private Context mContext = null;
  36. private epsonImage mEpsonImage = new epsonImage();
  37. private volatile boolean mStopREquested;
  38. private Rect src = new Rect(0, 0, 0, 0);
  39. EPImageUtil util = new EPImageUtil();
  40. Utils utilFolder = new Utils();
  41. private int getFontSize(int i) {
  42. if (i == 4) {
  43. return 16;
  44. }
  45. if (i != 8) {
  46. return i != 16 ? 40 : 66;
  47. }
  48. return 33;
  49. }
  50. public static int getPrintAreaResolution(int i, int i2) {
  51. switch (i) {
  52. case 0:
  53. case 1:
  54. return 1;
  55. default:
  56. if (i2 == 4) {
  57. return 16;
  58. }
  59. switch (i2) {
  60. case 1:
  61. return 4;
  62. case 2:
  63. return 8;
  64. default:
  65. return 1;
  66. }
  67. }
  68. }
  69. static {
  70. System.loadLibrary("opencv_java3");
  71. }
  72. public EPImageCreator(Context context) {
  73. mContext = context;
  74. CANCEL_FILE_NAME = new File(ExternalFileUtils.getInstance(mContext).getTempViewDir(), EPImageUtil.CANCEL_FILE_BASE_NAME).getPath();
  75. deleteCancelFile();
  76. }
  77. EPImageCreator() {
  78. }
  79. protected void finalize() throws Throwable {
  80. deleteCancelFile();
  81. }
  82. public synchronized void requestStop() {
  83. mStopREquested = true;
  84. makeCancelFile();
  85. }
  86. public synchronized boolean stopRequested() {
  87. return mStopREquested;
  88. }
  89. private String LoadJpegFile(EPImage ePImage, int i) {
  90. String str;
  91. if (stopRequested()) {
  92. deleteCancelFile();
  93. ePImage.loadImageFileName = null;
  94. return null;
  95. } else if (ePImage.loadImageFileName == null) {
  96. EPLog.m318w("EPImageCreator", "loadImageFileName is null");
  97. return null;
  98. } else {
  99. try {
  100. switch (ImageFormatIdentifier.identifyImageFormat(ePImage.loadImageFileName)) {
  101. case 1:
  102. ePImage.decodeImageFileName = ePImage.loadImageFileName;
  103. break;
  104. case 2:
  105. String png2jpeg = ImageUtil.png2jpeg(mContext, ePImage.loadImageFileName, i);
  106. if (stopRequested()) {
  107. deleteCancelFile();
  108. return null;
  109. }
  110. String path = new File(ExternalFileUtils.getInstance(mContext).getTempViewDir(), png2jpeg).getPath();
  111. String tempViewDir = ExternalFileUtils.getInstance(mContext).getTempViewDir();
  112. ePImage.decodeImageFileName = new File(tempViewDir, "decode_" + (ePImage.index + 1) + ".bmp").getPath();
  113. if (this.util.jpg2bmp(path, ePImage.decodeImageFileName, 1) != 0) {
  114. if (stopRequested()) {
  115. deleteCancelFile();
  116. return null;
  117. }
  118. ePImage.decodeImageFileName = null;
  119. throw new IllegalStateException();
  120. }
  121. break;
  122. case 3:
  123. String tempViewDir2 = ExternalFileUtils.getInstance(mContext).getTempViewDir();
  124. ePImage.decodeImageFileName = new File(tempViewDir2, "decode_" + (ePImage.index + 1) + ".bmp").getPath();
  125. if (this.util.jpg2bmp(ePImage.loadImageFileName, ePImage.decodeImageFileName, i) == 0) {
  126. int attributeInt = new ExifInterface(ePImage.loadImageFileName).getAttributeInt(android.support.media.ExifInterface.TAG_ORIENTATION, 0);
  127. String str2 = ePImage.decodeImageFileName;
  128. if (attributeInt == 3) {
  129. String tempViewDir3 = ExternalFileUtils.getInstance(mContext).getTempViewDir();
  130. str = new File(tempViewDir3, "decode_" + (ePImage.index + 1) + "_180.bmp").getPath();
  131. util.rotate180Image(str2, str);
  132. } else if (attributeInt == 6) {
  133. String tempViewDir4 = ExternalFileUtils.getInstance(mContext).getTempViewDir();
  134. str = new File(tempViewDir4, "decode_" + (ePImage.index + 1) + "_90.bmp").getPath();
  135. util.rotateR90Image(str2, str);
  136. } else if (attributeInt != 8) {
  137. str = str2;
  138. } else {
  139. String tempViewDir5 = ExternalFileUtils.getInstance(mContext).getTempViewDir();
  140. str = new File(tempViewDir5, "decode_" + (ePImage.index + 1) + "_270.bmp").getPath();
  141. util.rotateR270Image(str2, str);
  142. }
  143. if (attributeInt == 3 || attributeInt == 6 || attributeInt == 8) {
  144. if (str2.startsWith(ExternalFileUtils.getInstance(mContext).getTempViewDir())) {
  145. EPLog.m313i("createPrintImage", "Delete decorded image : " + str2);
  146. new File(str2).delete();
  147. }
  148. }
  149. ePImage.decodeImageFileName = str;
  150. break;
  151. } else if (stopRequested()) {
  152. EPLog.m307e("EPImageCreator", "EPImageCreator::LoadJpegFile() jpg2bmp stoped.");
  153. return null;
  154. } else {
  155. ePImage.decodeImageFileName = null;
  156. throw new IllegalStateException();
  157. }
  158. default:
  159. return null;
  160. }
  161. BitmapFactory.Options options = new BitmapFactory.Options();
  162. options.inJustDecodeBounds = true;
  163. BitmapFactory.decodeFile(ePImage.decodeImageFileName, options);
  164. if (options.outWidth <= 0 || options.outHeight <= 0) {
  165. if (mEpsonImage == null) {
  166. mEpsonImage = new epsonImage();
  167. }
  168. if (mEpsonImage != null) {
  169. int[] iArr = new int[2];
  170. mEpsonImage.epsmpGetImageSize2(ePImage.decodeImageFileName, iArr);
  171. ePImage.decodeWidth = iArr[0];
  172. ePImage.decodeHeight = iArr[1];
  173. }
  174. return ePImage.loadImageFileName;
  175. }
  176. ePImage.decodeWidth = options.outWidth;
  177. ePImage.decodeHeight = options.outHeight;
  178. return ePImage.loadImageFileName;
  179. } catch (Exception e) {
  180. e.printStackTrace();
  181. ePImage.loadImageFileName = null;
  182. }
  183. }
  184. }
  185. /* JADX WARNING: Removed duplicated region for block: B:24:0x0031 A[Catch:{ Exception -> 0x00fa }] */
  186. /* JADX WARNING: Removed duplicated region for block: B:27:0x003b A[Catch:{ Exception -> 0x00fa }] */
  187. /* JADX WARNING: Removed duplicated region for block: B:31:0x0040 A[SYNTHETIC, Splitter:B:31:0x0040] */
  188. /* Code decompiled incorrectly, please refer to instructions dump. */
  189. public String createThumbnailImage(EPImage r21, int r22, int r23) {
  190. /*
  191. r20 = this;
  192. r1 = r20
  193. r2 = r21
  194. r0 = r22
  195. r3 = r23
  196. java.lang.Object r4 = lockObject
  197. monitor-enter(r4)
  198. java.lang.String r5 = "EPImageCreator"
  199. java.lang.String r6 = "Lcok function by createThumbnailImage()."
  200. epson.print.Util.EPLog.m305d(r5, r6) // Catch:{ all -> 0x0104 }
  201. r5 = 0
  202. java.lang.String r6 = r2.thumbnailImageFileName // Catch:{ Exception -> 0x00fa }
  203. if (r6 == 0) goto L_0x001b
  204. java.lang.String r0 = r2.thumbnailImageFileName // Catch:{ Exception -> 0x00fa }
  205. monitor-exit(r4) // Catch:{ all -> 0x0104 }
  206. return r0
  207. L_0x001b:
  208. r6 = 1
  209. if (r0 <= r3) goto L_0x0026
  210. int r7 = r2.srcWidth // Catch:{ Exception -> 0x00fa }
  211. if (r7 <= r0) goto L_0x002e
  212. int r7 = r2.srcWidth // Catch:{ Exception -> 0x00fa }
  213. int r7 = r7 / r0
  214. goto L_0x002f
  215. L_0x0026:
  216. int r7 = r2.srcHeight // Catch:{ Exception -> 0x00fa }
  217. if (r7 <= r3) goto L_0x002e
  218. int r7 = r2.srcHeight // Catch:{ Exception -> 0x00fa }
  219. int r7 = r7 / r3
  220. goto L_0x002f
  221. L_0x002e:
  222. r7 = 1
  223. L_0x002f:
  224. if (r7 >= r6) goto L_0x0032
  225. r7 = 1
  226. L_0x0032:
  227. r1.LoadJpegFile(r2, r7) // Catch:{ Exception -> 0x00fa }
  228. boolean r7 = r20.stopRequested() // Catch:{ Exception -> 0x00fa }
  229. if (r7 == 0) goto L_0x0040
  230. r20.deleteCancelFile() // Catch:{ Exception -> 0x00fa }
  231. monitor-exit(r4) // Catch:{ all -> 0x0104 }
  232. return r5
  233. L_0x0040:
  234. java.lang.String r7 = r2.decodeImageFileName // Catch:{ Exception -> 0x00fa }
  235. if (r7 == 0) goto L_0x00f4
  236. int r7 = r2.decodeWidth // Catch:{ Exception -> 0x00fa }
  237. int r8 = r2.decodeHeight // Catch:{ Exception -> 0x00fa }
  238. if (r7 <= r8) goto L_0x005f
  239. int r7 = r2.decodeWidth // Catch:{ Exception -> 0x00fa }
  240. int r7 = r7 * r3
  241. int r8 = r2.decodeHeight // Catch:{ Exception -> 0x00fa }
  242. int r7 = r7 / r8
  243. if (r7 >= r0) goto L_0x005b
  244. int r3 = r2.decodeHeight // Catch:{ Exception -> 0x00fa }
  245. int r3 = r3 * r0
  246. int r7 = r2.decodeWidth // Catch:{ Exception -> 0x00fa }
  247. int r3 = r3 / r7
  248. goto L_0x005c
  249. L_0x005b:
  250. r0 = r7
  251. L_0x005c:
  252. r10 = r0
  253. r11 = r3
  254. goto L_0x0074
  255. L_0x005f:
  256. int r7 = r2.decodeHeight // Catch:{ Exception -> 0x00fa }
  257. int r7 = r7 * r0
  258. int r8 = r2.decodeWidth // Catch:{ Exception -> 0x00fa }
  259. int r7 = r7 / r8
  260. if (r7 >= r3) goto L_0x0072
  261. int r0 = r2.decodeWidth // Catch:{ Exception -> 0x00fa }
  262. int r0 = r0 * r3
  263. int r7 = r2.decodeHeight // Catch:{ Exception -> 0x00fa }
  264. int r0 = r0 / r7
  265. r10 = r0
  266. r11 = r3
  267. goto L_0x0074
  268. L_0x0072:
  269. r10 = r0
  270. r11 = r7
  271. L_0x0074:
  272. java.io.File r0 = new java.io.File // Catch:{ Exception -> 0x00fa }
  273. android.content.Context r3 = r1.mContext // Catch:{ Exception -> 0x00fa }
  274. epson.common.ExternalFileUtils r3 = epson.common.ExternalFileUtils.getInstance(r3) // Catch:{ Exception -> 0x00fa }
  275. java.lang.String r3 = r3.getTempViewDir() // Catch:{ Exception -> 0x00fa }
  276. java.lang.StringBuilder r7 = new java.lang.StringBuilder // Catch:{ Exception -> 0x00fa }
  277. r7.<init>() // Catch:{ Exception -> 0x00fa }
  278. java.lang.String r8 = "thumbnail_"
  279. r7.append(r8) // Catch:{ Exception -> 0x00fa }
  280. int r8 = r2.index // Catch:{ Exception -> 0x00fa }
  281. int r8 = r8 + r6
  282. r7.append(r8) // Catch:{ Exception -> 0x00fa }
  283. java.lang.String r8 = ".bmp"
  284. r7.append(r8) // Catch:{ Exception -> 0x00fa }
  285. java.lang.String r7 = r7.toString() // Catch:{ Exception -> 0x00fa }
  286. r0.<init>(r3, r7) // Catch:{ Exception -> 0x00fa }
  287. java.lang.String r0 = r0.getPath() // Catch:{ Exception -> 0x00fa }
  288. r2.thumbnailImageFileName = r0 // Catch:{ Exception -> 0x00fa }
  289. epson.print.EPImageUtil r7 = r1.util // Catch:{ Exception -> 0x00fa }
  290. java.lang.String r8 = r2.decodeImageFileName // Catch:{ Exception -> 0x00fa }
  291. java.lang.String r9 = r2.thumbnailImageFileName // Catch:{ Exception -> 0x00fa }
  292. r12 = 0
  293. r13 = 0
  294. int r0 = r2.decodeWidth // Catch:{ Exception -> 0x00fa }
  295. int r14 = r0 + -1
  296. int r0 = r2.decodeHeight // Catch:{ Exception -> 0x00fa }
  297. int r15 = r0 + -1
  298. r16 = 0
  299. r17 = 0
  300. int r18 = r10 + -1
  301. int r19 = r11 + -1
  302. r7.resizeImage(r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19) // Catch:{ Exception -> 0x00fa }
  303. java.lang.String r0 = r2.decodeImageFileName // Catch:{ Exception -> 0x00fa }
  304. android.content.Context r3 = r1.mContext // Catch:{ Exception -> 0x00fa }
  305. epson.common.ExternalFileUtils r3 = epson.common.ExternalFileUtils.getInstance(r3) // Catch:{ Exception -> 0x00fa }
  306. java.lang.String r3 = r3.getTempViewDir() // Catch:{ Exception -> 0x00fa }
  307. boolean r0 = r0.startsWith(r3) // Catch:{ Exception -> 0x00fa }
  308. if (r0 == 0) goto L_0x0100
  309. java.lang.String r0 = "createPrintImage"
  310. java.lang.StringBuilder r3 = new java.lang.StringBuilder // Catch:{ Exception -> 0x00fa }
  311. r3.<init>() // Catch:{ Exception -> 0x00fa }
  312. java.lang.String r6 = "Delete decorded image : "
  313. r3.append(r6) // Catch:{ Exception -> 0x00fa }
  314. java.lang.String r6 = r2.decodeImageFileName // Catch:{ Exception -> 0x00fa }
  315. r3.append(r6) // Catch:{ Exception -> 0x00fa }
  316. java.lang.String r3 = r3.toString() // Catch:{ Exception -> 0x00fa }
  317. epson.print.Util.EPLog.m313i(r0, r3) // Catch:{ Exception -> 0x00fa }
  318. java.io.File r0 = new java.io.File // Catch:{ Exception -> 0x00fa }
  319. java.lang.String r3 = r2.decodeImageFileName // Catch:{ Exception -> 0x00fa }
  320. r0.<init>(r3) // Catch:{ Exception -> 0x00fa }
  321. r0.delete() // Catch:{ Exception -> 0x00fa }
  322. r2.decodeImageFileName = r5 // Catch:{ Exception -> 0x00fa }
  323. goto L_0x0100
  324. L_0x00f4:
  325. java.lang.IllegalStateException r0 = new java.lang.IllegalStateException // Catch:{ Exception -> 0x00fa }
  326. r0.<init>() // Catch:{ Exception -> 0x00fa }
  327. throw r0 // Catch:{ Exception -> 0x00fa }
  328. L_0x00fa:
  329. r0 = move-exception
  330. r0.printStackTrace() // Catch:{ all -> 0x0104 }
  331. r2.thumbnailImageFileName = r5 // Catch:{ all -> 0x0104 }
  332. L_0x0100:
  333. java.lang.String r0 = r2.thumbnailImageFileName // Catch:{ all -> 0x0104 }
  334. monitor-exit(r4) // Catch:{ all -> 0x0104 }
  335. return r0
  336. L_0x0104:
  337. r0 = move-exception
  338. monitor-exit(r4) // Catch:{ all -> 0x0104 }
  339. throw r0
  340. */
  341. throw new UnsupportedOperationException("Method not decompiled: epson.print.EPImageCreator.createThumbnailImage(epson.print.EPImage, int, int):java.lang.String");
  342. }
  343. /* JADX WARNING: Removed duplicated region for block: B:26:0x0036 A[Catch:{ Exception -> 0x001d }] */
  344. /* JADX WARNING: Removed duplicated region for block: B:29:0x0040 A[Catch:{ Exception -> 0x001d }] */
  345. /* JADX WARNING: Removed duplicated region for block: B:33:0x0045 A[SYNTHETIC, Splitter:B:33:0x0045] */
  346. /* Code decompiled incorrectly, please refer to instructions dump. */
  347. public String createPreviewImage(EPImage r21, int r22, int r23, int r24, boolean r25) {
  348. /*
  349. r20 = this;
  350. r1 = r20
  351. r2 = r21
  352. r0 = r22
  353. r3 = r23
  354. java.lang.Object r4 = lockObject
  355. monitor-enter(r4)
  356. java.lang.String r5 = "EPImageCreator"
  357. java.lang.String r6 = "Lcok function by createPreviewImage()."
  358. epson.print.Util.EPLog.m305d(r5, r6) // Catch:{ all -> 0x017a }
  359. r5 = 0
  360. if (r25 != 0) goto L_0x0020
  361. java.lang.String r6 = r2.previewImageFileName // Catch:{ Exception -> 0x001d }
  362. if (r6 == 0) goto L_0x0020
  363. java.lang.String r0 = r2.previewImageFileName // Catch:{ Exception -> 0x001d }
  364. monitor-exit(r4) // Catch:{ all -> 0x017a }
  365. return r0
  366. L_0x001d:
  367. r0 = move-exception
  368. goto L_0x0171
  369. L_0x0020:
  370. r6 = 1
  371. if (r0 <= r3) goto L_0x002b
  372. int r7 = r2.srcWidth // Catch:{ Exception -> 0x001d }
  373. if (r7 <= r0) goto L_0x0033
  374. int r7 = r2.srcWidth // Catch:{ Exception -> 0x001d }
  375. int r7 = r7 / r0
  376. goto L_0x0034
  377. L_0x002b:
  378. int r7 = r2.srcHeight // Catch:{ Exception -> 0x001d }
  379. if (r7 <= r3) goto L_0x0033
  380. int r7 = r2.srcHeight // Catch:{ Exception -> 0x001d }
  381. int r7 = r7 / r3
  382. goto L_0x0034
  383. L_0x0033:
  384. r7 = 1
  385. L_0x0034:
  386. if (r7 >= r6) goto L_0x0037
  387. r7 = 1
  388. L_0x0037:
  389. r1.LoadJpegFile(r2, r7) // Catch:{ Exception -> 0x001d }
  390. boolean r7 = r20.stopRequested() // Catch:{ Exception -> 0x001d }
  391. if (r7 == 0) goto L_0x0045
  392. r20.deleteCancelFile() // Catch:{ Exception -> 0x001d }
  393. monitor-exit(r4) // Catch:{ all -> 0x017a }
  394. return r5
  395. L_0x0045:
  396. java.lang.String r7 = r2.decodeImageFileName // Catch:{ Exception -> 0x001d }
  397. if (r7 == 0) goto L_0x016b
  398. int r7 = r2.decodeWidth // Catch:{ Exception -> 0x001d }
  399. int r8 = r2.decodeHeight // Catch:{ Exception -> 0x001d }
  400. if (r7 <= r8) goto L_0x0066
  401. int r7 = r2.decodeWidth // Catch:{ Exception -> 0x001d }
  402. int r7 = r7 * r3
  403. int r8 = r2.decodeHeight // Catch:{ Exception -> 0x001d }
  404. int r7 = r7 / r8
  405. if (r7 >= r0) goto L_0x0060
  406. int r3 = r2.decodeHeight // Catch:{ Exception -> 0x001d }
  407. int r3 = r3 * r0
  408. int r7 = r2.decodeWidth // Catch:{ Exception -> 0x001d }
  409. int r3 = r3 / r7
  410. goto L_0x0061
  411. L_0x0060:
  412. r0 = r7
  413. L_0x0061:
  414. r15 = r3
  415. r3 = r0
  416. r0 = r24
  417. goto L_0x007f
  418. L_0x0066:
  419. int r7 = r2.decodeHeight // Catch:{ Exception -> 0x001d }
  420. int r7 = r7 * r0
  421. int r8 = r2.decodeWidth // Catch:{ Exception -> 0x001d }
  422. int r7 = r7 / r8
  423. if (r7 >= r3) goto L_0x007b
  424. int r0 = r2.decodeWidth // Catch:{ Exception -> 0x001d }
  425. int r0 = r0 * r3
  426. int r7 = r2.decodeHeight // Catch:{ Exception -> 0x001d }
  427. int r0 = r0 / r7
  428. r15 = r3
  429. r3 = r0
  430. r0 = r24
  431. goto L_0x007f
  432. L_0x007b:
  433. r3 = r0
  434. r15 = r7
  435. r0 = r24
  436. L_0x007f:
  437. if (r0 != r6) goto L_0x00e4
  438. java.lang.String r0 = r2.decodeImageFileName // Catch:{ Exception -> 0x001d }
  439. java.io.File r7 = new java.io.File // Catch:{ Exception -> 0x001d }
  440. android.content.Context r8 = r1.mContext // Catch:{ Exception -> 0x001d }
  441. epson.common.ExternalFileUtils r8 = epson.common.ExternalFileUtils.getInstance(r8) // Catch:{ Exception -> 0x001d }
  442. java.lang.String r8 = r8.getTempViewDir() // Catch:{ Exception -> 0x001d }
  443. java.lang.StringBuilder r9 = new java.lang.StringBuilder // Catch:{ Exception -> 0x001d }
  444. r9.<init>() // Catch:{ Exception -> 0x001d }
  445. java.lang.String r10 = "preview_"
  446. r9.append(r10) // Catch:{ Exception -> 0x001d }
  447. int r10 = r2.index // Catch:{ Exception -> 0x001d }
  448. int r10 = r10 + r6
  449. r9.append(r10) // Catch:{ Exception -> 0x001d }
  450. java.lang.String r10 = "_gray.bmp"
  451. r9.append(r10) // Catch:{ Exception -> 0x001d }
  452. java.lang.String r9 = r9.toString() // Catch:{ Exception -> 0x001d }
  453. r7.<init>(r8, r9) // Catch:{ Exception -> 0x001d }
  454. java.lang.String r7 = r7.getPath() // Catch:{ Exception -> 0x001d }
  455. epson.print.EPImageUtil r8 = r1.util // Catch:{ Exception -> 0x001d }
  456. r8.color2grayscale(r0, r7) // Catch:{ Exception -> 0x001d }
  457. android.content.Context r8 = r1.mContext // Catch:{ Exception -> 0x001d }
  458. epson.common.ExternalFileUtils r8 = epson.common.ExternalFileUtils.getInstance(r8) // Catch:{ Exception -> 0x001d }
  459. java.lang.String r8 = r8.getTempViewDir() // Catch:{ Exception -> 0x001d }
  460. boolean r8 = r0.startsWith(r8) // Catch:{ Exception -> 0x001d }
  461. if (r8 == 0) goto L_0x00e2
  462. java.lang.String r8 = "createPrintImage"
  463. java.lang.StringBuilder r9 = new java.lang.StringBuilder // Catch:{ Exception -> 0x001d }
  464. r9.<init>() // Catch:{ Exception -> 0x001d }
  465. java.lang.String r10 = "Delete decorded image : "
  466. r9.append(r10) // Catch:{ Exception -> 0x001d }
  467. r9.append(r0) // Catch:{ Exception -> 0x001d }
  468. java.lang.String r9 = r9.toString() // Catch:{ Exception -> 0x001d }
  469. epson.print.Util.EPLog.m313i(r8, r9) // Catch:{ Exception -> 0x001d }
  470. java.io.File r8 = new java.io.File // Catch:{ Exception -> 0x001d }
  471. r8.<init>(r0) // Catch:{ Exception -> 0x001d }
  472. r8.delete() // Catch:{ Exception -> 0x001d }
  473. L_0x00e2:
  474. r2.decodeImageFileName = r7 // Catch:{ Exception -> 0x001d }
  475. L_0x00e4:
  476. java.io.File r0 = new java.io.File // Catch:{ Exception -> 0x001d }
  477. android.content.Context r7 = r1.mContext // Catch:{ Exception -> 0x001d }
  478. epson.common.ExternalFileUtils r7 = epson.common.ExternalFileUtils.getInstance(r7) // Catch:{ Exception -> 0x001d }
  479. java.lang.String r7 = r7.getTempViewDir() // Catch:{ Exception -> 0x001d }
  480. java.lang.StringBuilder r8 = new java.lang.StringBuilder // Catch:{ Exception -> 0x001d }
  481. r8.<init>() // Catch:{ Exception -> 0x001d }
  482. java.lang.String r9 = "preview_"
  483. r8.append(r9) // Catch:{ Exception -> 0x001d }
  484. int r9 = r2.index // Catch:{ Exception -> 0x001d }
  485. int r9 = r9 + r6
  486. r8.append(r9) // Catch:{ Exception -> 0x001d }
  487. java.lang.String r9 = ".bmp"
  488. r8.append(r9) // Catch:{ Exception -> 0x001d }
  489. java.lang.String r8 = r8.toString() // Catch:{ Exception -> 0x001d }
  490. r0.<init>(r7, r8) // Catch:{ Exception -> 0x001d }
  491. java.lang.String r0 = r0.getPath() // Catch:{ Exception -> 0x001d }
  492. r2.previewImageFileName = r0 // Catch:{ Exception -> 0x001d }
  493. epson.print.EPImageUtil r7 = r1.util // Catch:{ Exception -> 0x001d }
  494. java.lang.String r8 = r2.decodeImageFileName // Catch:{ Exception -> 0x001d }
  495. java.lang.String r9 = r2.previewImageFileName // Catch:{ Exception -> 0x001d }
  496. r12 = 0
  497. r13 = 0
  498. int r0 = r2.decodeWidth // Catch:{ Exception -> 0x001d }
  499. int r14 = r0 + -1
  500. int r0 = r2.decodeHeight // Catch:{ Exception -> 0x001d }
  501. int r0 = r0 - r6
  502. r16 = 0
  503. r17 = 0
  504. int r18 = r3 + -1
  505. int r19 = r15 + -1
  506. r10 = r3
  507. r11 = r15
  508. r6 = r15
  509. r15 = r0
  510. r7.resizeImage(r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19) // Catch:{ Exception -> 0x001d }
  511. java.lang.String r0 = r2.decodeImageFileName // Catch:{ Exception -> 0x001d }
  512. android.content.Context r7 = r1.mContext // Catch:{ Exception -> 0x001d }
  513. epson.common.ExternalFileUtils r7 = epson.common.ExternalFileUtils.getInstance(r7) // Catch:{ Exception -> 0x001d }
  514. java.lang.String r7 = r7.getTempViewDir() // Catch:{ Exception -> 0x001d }
  515. boolean r0 = r0.startsWith(r7) // Catch:{ Exception -> 0x001d }
  516. if (r0 == 0) goto L_0x0166
  517. java.lang.String r0 = "createPrintImage"
  518. java.lang.StringBuilder r7 = new java.lang.StringBuilder // Catch:{ Exception -> 0x001d }
  519. r7.<init>() // Catch:{ Exception -> 0x001d }
  520. java.lang.String r8 = "Delete decorded image : "
  521. r7.append(r8) // Catch:{ Exception -> 0x001d }
  522. java.lang.String r8 = r2.decodeImageFileName // Catch:{ Exception -> 0x001d }
  523. r7.append(r8) // Catch:{ Exception -> 0x001d }
  524. java.lang.String r7 = r7.toString() // Catch:{ Exception -> 0x001d }
  525. epson.print.Util.EPLog.m313i(r0, r7) // Catch:{ Exception -> 0x001d }
  526. java.io.File r0 = new java.io.File // Catch:{ Exception -> 0x001d }
  527. java.lang.String r7 = r2.decodeImageFileName // Catch:{ Exception -> 0x001d }
  528. r0.<init>(r7) // Catch:{ Exception -> 0x001d }
  529. r0.delete() // Catch:{ Exception -> 0x001d }
  530. r2.decodeImageFileName = r5 // Catch:{ Exception -> 0x001d }
  531. L_0x0166:
  532. r2.previewWidth = r3 // Catch:{ Exception -> 0x001d }
  533. r2.previewHeight = r6 // Catch:{ Exception -> 0x001d }
  534. goto L_0x0176
  535. L_0x016b:
  536. java.lang.IllegalStateException r0 = new java.lang.IllegalStateException // Catch:{ Exception -> 0x001d }
  537. r0.<init>() // Catch:{ Exception -> 0x001d }
  538. throw r0 // Catch:{ Exception -> 0x001d }
  539. L_0x0171:
  540. r0.printStackTrace() // Catch:{ all -> 0x017a }
  541. r2.previewImageFileName = r5 // Catch:{ all -> 0x017a }
  542. L_0x0176:
  543. java.lang.String r0 = r2.previewImageFileName // Catch:{ all -> 0x017a }
  544. monitor-exit(r4) // Catch:{ all -> 0x017a }
  545. return r0
  546. L_0x017a:
  547. r0 = move-exception
  548. monitor-exit(r4) // Catch:{ all -> 0x017a }
  549. throw r0
  550. */
  551. throw new UnsupportedOperationException("Method not decompiled: epson.print.EPImageCreator.createPreviewImage(epson.print.EPImage, int, int, int, boolean):java.lang.String");
  552. }
  553. public String createPrintImage(Context context, EPImage ePImage, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, boolean z, boolean z2) {
  554. int[] iArr;
  555. EPImage ePImage2 = ePImage;
  556. int i9 = i5;
  557. int i10 = i8;
  558. int convertRotationValue = convertRotationValue(ePImage2.rotate);
  559. if (i9 == 4) {
  560. iArr = new int[]{i2, i3};
  561. } else {
  562. iArr = getPrintAreaSize(mContext, i4, i9, i6);
  563. if (z2) {
  564. int i11 = iArr[0];
  565. iArr[0] = iArr[1];
  566. iArr[1] = i11;
  567. }
  568. }
  569. double printParPreviewRate = getPrintParPreviewRate(ePImage2, convertRotationValue, iArr);
  570. ImageAndLayout imageAndLayout = new ImageAndLayout();
  571. imageAndLayout.setLayoutAreaSize(iArr[0], iArr[1]);
  572. double[] layoutValues = getLayoutValues(convertRotationValue, ePImage2, printParPreviewRate);
  573. ImageAndLayout imageAndLayout2 = imageAndLayout;
  574. imageAndLayout.setLayout(layoutValues[0], layoutValues[1], layoutValues[2], layoutValues[3], convertRotationValue);
  575. imageAndLayout2.setOrgFileName(ePImage2.loadImageFileName);
  576. String printFilename = getPrintFilename(mContext, ePImage2.index);
  577. imageAndLayout2.setOpenCvExifRotationCancel(false);
  578. boolean z3 = true;
  579. imageAndLayout2.createPrintData(printFilename, i7 == 1, new int[]{i2, i3}, 0);
  580. ePImage2.decodeImageFileName = printFilename;
  581. if (i10 != 0) {
  582. String dateTimeSystem = Photo.getDateTimeSystem(ePImage.getOriginalFileName(), i10);
  583. if (i9 != 1) {
  584. z3 = false;
  585. }
  586. writeDate(ePImage, i2, i3, dateTimeSystem, i, z3);
  587. }
  588. return printFilename;
  589. }
  590. private double getPrintParPreviewRate(EPImage ePImage, int i, int[] iArr) {
  591. return (((i & 1) == 1 ? iArr[0] : iArr[1])) / ((ePImage.previewPaperRectBottom - ePImage.previewPaperRectTop));
  592. }
  593. private int convertRotationValue(int i) {
  594. return (i / 90) & 3;
  595. }
  596. private double[] getLayoutValues(int i, EPImage ePImage, double d) {
  597. double[] dArr = new double[4];
  598. if (i == 0 || i == 2) {
  599. dArr[0] = ((ePImage.previewImageRectRight - ePImage.previewImageRectLeft)) * d;
  600. dArr[1] = ((ePImage.previewImageRectBottom - ePImage.previewImageRectTop)) * d;
  601. } else {
  602. dArr[0] = ((ePImage.previewImageRectBottom - ePImage.previewImageRectTop)) * d;
  603. dArr[1] = ((ePImage.previewImageRectRight - ePImage.previewImageRectLeft)) * d;
  604. }
  605. switch (i) {
  606. case 1:
  607. dArr[2] = (((-ePImage.previewImageRectBottom) + ((float) ePImage.previewPaperRectBottom))) * d;
  608. dArr[3] = ((ePImage.previewImageRectLeft - ((float) ePImage.previewPaperRectLeft))) * d;
  609. break;
  610. case 2:
  611. dArr[2] = (((-ePImage.previewImageRectRight) + ((float) ePImage.previewPaperRectRight))) * d;
  612. dArr[3] = (((-ePImage.previewImageRectBottom) + ((float) ePImage.previewPaperRectBottom))) * d;
  613. break;
  614. case 3:
  615. dArr[2] = ((ePImage.previewImageRectTop - ((float) ePImage.previewPaperRectTop))) * d;
  616. dArr[3] = (((-ePImage.previewImageRectRight) + ((float) ePImage.previewPaperRectRight))) * d;
  617. break;
  618. default:
  619. dArr[2] = ((ePImage.previewImageRectLeft - ((float) ePImage.previewPaperRectLeft))) * d;
  620. dArr[3] = ((ePImage.previewImageRectTop - ((float) ePImage.previewPaperRectTop))) * d;
  621. break;
  622. }
  623. return dArr;
  624. }
  625. private int[] getPrintAreaSize(Context context, int i, int i2, int i3) {
  626. if (i2 != 1) {
  627. return new BorderedLayoutPosition().getPrintSize(context, i, i3);
  628. }
  629. Info_paper infoPaper = Info_paper.getInfoPaper(context, i);
  630. return new int[]{infoPaper.getPaper_width_boderless(), infoPaper.getPaper_height_boderless()};
  631. }
  632. private String getPrintFilename(Context context, int i) {
  633. String printDir = ExternalFileUtils.getInstance(context).getPrintDir();
  634. return new File(printDir, (i + 1) + ".bmp").getPath();
  635. }
  636. public String createMultiPrintImage(Context context, int i, int i2, EPImageList ePImageList, int i3, int i4, int i5, int i6, int i7, int i8, int i9, boolean z) {
  637. Rect rect;
  638. int i10;
  639. int i11;
  640. Mat mat;
  641. EPImage ePImage;
  642. boolean z2;
  643. boolean z3;
  644. int i12 = i;
  645. int i13 = i2;
  646. EPImageList ePImageList2 = ePImageList;
  647. int i14 = i3;
  648. int i15 = i4;
  649. int i16 = i5;
  650. int i17 = i9;
  651. new ArrayList();
  652. boolean z4 = ePImageList2.get(0).isPaperLandScape;
  653. Mat mat2 = new Mat(i16, i15, CvType.CV_8UC3, Scalar.all(255.0d));
  654. boolean z5 = i15 > i16;
  655. if (i12 == 65536) {
  656. i10 = i14 * 2;
  657. rect = Info_paper.getRect_2in1(i15, i16, i13, true);
  658. } else if (i12 == 131072 || i12 == 262144) {
  659. i10 = i14 * 4;
  660. rect = Info_paper.getRect_4in1(i15, i16, i13, true);
  661. } else {
  662. rect = null;
  663. i10 = 0;
  664. }
  665. boolean z6 = rect.width() > rect.height();
  666. while (true) {
  667. try {
  668. EPImage ePImage2 = ePImageList2.get(i10);
  669. if (ePImage2 == null) {
  670. mat = mat2;
  671. i11 = i14;
  672. } else {
  673. if (ePImage2.isPaperLandScape != z6) {
  674. if (z5) {
  675. ePImage2.rotate += EPImage.EPS_ROTATE_270;
  676. } else {
  677. ePImage2.rotate += 90;
  678. }
  679. }
  680. int i18 = i10;
  681. boolean z7 = z6;
  682. boolean z8 = z5;
  683. Mat mat3 = mat2;
  684. boolean z9 = z4;
  685. i11 = i14;
  686. String createPrintImage = createPrintImage(context, ePImage2, i2, rect.width(), rect.height(), i6, 2, i, i7, i8, false, z);
  687. if (createPrintImage == null) {
  688. mat = mat3;
  689. } else {
  690. if (i12 != 65536) {
  691. if (i12 != 131072) {
  692. if (i12 != 262144) {
  693. z2 = z8;
  694. mat = mat3;
  695. z3 = z9;
  696. }
  697. }
  698. int i19 = i18 % 4;
  699. z2 = z8;
  700. z3 = z9;
  701. mat = mat3;
  702. MakeMultiPrintImage.layoutPrintImage(mat, createPrintImage, MakeMultiPrintImage.calcLayout4in1(i12, z2, z3, i19));
  703. if (i19 == 3) {
  704. }
  705. } else {
  706. z2 = z8;
  707. mat = mat3;
  708. z3 = z9;
  709. switch (i18 % 2) {
  710. case 0:
  711. MakeMultiPrintImage.layoutPrintImage(mat, createPrintImage, 0);
  712. continue;
  713. case 1:
  714. MakeMultiPrintImage.layoutPrintImage(mat, createPrintImage, 3);
  715. break;
  716. default:
  717. continue;
  718. }
  719. }
  720. i10 = i18 + 1;
  721. z4 = z3;
  722. z5 = z2;
  723. mat2 = mat;
  724. i14 = i11;
  725. z6 = z7;
  726. int i20 = i9;
  727. int i21 = i5;
  728. int i22 = i4;
  729. int i23 = i2;
  730. }
  731. }
  732. } catch (IndexOutOfBoundsException unused) {
  733. mat = mat2;
  734. i11 = i14;
  735. } catch (Throwable unused2) {
  736. mat = mat2;
  737. i11 = i14;
  738. }
  739. }
  740. String path = new File(ExternalFileUtils.getInstance(context).getPrintDir(), "multi_" + (i11 + 1) + ".bmp").getPath();
  741. Imgcodecs.imwrite(path, mat);
  742. mat.release();
  743. int i24 = i9;
  744. if (i24 % 360 == 0) {
  745. ePImage = new EPImage();
  746. ePImage.decodeImageFileName = path;
  747. } else {
  748. EPImage ePImage3 = new EPImage(path, i11);
  749. ePImage3.rotate = i24;
  750. ePImage3.decodeImageFileName = path;
  751. rotate(ePImage3, i4, i5);
  752. ePImage = ePImage3;
  753. }
  754. return ePImage.decodeImageFileName;
  755. }
  756. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v15, resolved type: int} */
  757. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v18, resolved type: int} */
  758. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v19, resolved type: int} */
  759. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v42, resolved type: int} */
  760. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v60, resolved type: int} */
  761. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v63, resolved type: int} */
  762. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v66, resolved type: int} */
  763. /* JADX WARNING: type inference failed for: r10v16 */
  764. /* JADX WARNING: Multi-variable type inference failed */
  765. /* JADX WARNING: Removed duplicated region for block: B:100:0x02bf A[SYNTHETIC, Splitter:B:100:0x02bf] */
  766. /* JADX WARNING: Removed duplicated region for block: B:109:0x0336 A[Catch:{ Exception -> 0x00ed }] */
  767. /* JADX WARNING: Removed duplicated region for block: B:114:0x03d0 */
  768. /* JADX WARNING: Removed duplicated region for block: B:120:0x03f6 A[Catch:{ Exception -> 0x0413 }] */
  769. /* JADX WARNING: Removed duplicated region for block: B:20:0x0032 */
  770. /* JADX WARNING: Removed duplicated region for block: B:24:0x003c A[SYNTHETIC, Splitter:B:24:0x003c] */
  771. /* JADX WARNING: Removed duplicated region for block: B:29:0x0041 A[SYNTHETIC, Splitter:B:29:0x0041] */
  772. /* JADX WARNING: Removed duplicated region for block: B:91:0x01fd A[SYNTHETIC, Splitter:B:91:0x01fd] */
  773. /* Code decompiled incorrectly, please refer to instructions dump. */
  774. public String createPrintImage_origi(Context r27, EPImage r28, int r29, int r30, int r31, int r32, int r33, int r34, int r35, boolean r36) {
  775. /*
  776. r26 = this;
  777. r8 = r26
  778. r9 = r28
  779. r3 = r30
  780. r4 = r31
  781. r1 = r33
  782. r2 = r35
  783. java.lang.Object r23 = lockObject
  784. monitor-enter(r23)
  785. java.lang.String r5 = "EPImageCreator"
  786. java.lang.String r6 = "Lcok function by createPrintImage()."
  787. epson.print.Util.EPLog.m305d(r5, r6) // Catch:{ all -> 0x042b }
  788. r7 = 0
  789. r5 = 1
  790. if (r3 <= r4) goto L_0x0027
  791. int r6 = r9.srcWidth // Catch:{ Exception -> 0x0022 }
  792. if (r6 <= r3) goto L_0x002f
  793. int r6 = r9.srcWidth // Catch:{ Exception -> 0x0022 }
  794. int r6 = r6 / r3
  795. goto L_0x0030
  796. L_0x0022:
  797. r0 = move-exception
  798. r1 = r0
  799. r10 = r7
  800. goto L_0x0422
  801. L_0x0027:
  802. int r6 = r9.srcHeight // Catch:{ Exception -> 0x041f }
  803. if (r6 <= r4) goto L_0x002f
  804. int r6 = r9.srcHeight // Catch:{ Exception -> 0x0022 }
  805. int r6 = r6 / r4
  806. goto L_0x0030
  807. L_0x002f:
  808. r6 = 1
  809. L_0x0030:
  810. if (r6 >= r5) goto L_0x0033
  811. r6 = 1
  812. L_0x0033:
  813. r8.LoadJpegFile(r9, r6) // Catch:{ Exception -> 0x041f }
  814. boolean r6 = r26.stopRequested() // Catch:{ Exception -> 0x041f }
  815. if (r6 == 0) goto L_0x0041
  816. r26.deleteCancelFile() // Catch:{ Exception -> 0x0022 }
  817. monitor-exit(r23) // Catch:{ all -> 0x042b }
  818. return r7
  819. L_0x0041:
  820. java.lang.String r6 = r9.decodeImageFileName // Catch:{ Exception -> 0x041f }
  821. if (r6 == 0) goto L_0x0416
  822. int r6 = r9.decodeWidth // Catch:{ Exception -> 0x041f }
  823. float r6 = (float) r6 // Catch:{ Exception -> 0x041f }
  824. int r10 = r9.previewWidth // Catch:{ Exception -> 0x041f }
  825. float r10 = (float) r10 // Catch:{ Exception -> 0x041f }
  826. float r6 = r6 / r10
  827. int r10 = r9.decodeHeight // Catch:{ Exception -> 0x041f }
  828. float r10 = (float) r10 // Catch:{ Exception -> 0x041f }
  829. int r11 = r9.previewHeight // Catch:{ Exception -> 0x041f }
  830. float r11 = (float) r11 // Catch:{ Exception -> 0x041f }
  831. float r10 = r10 / r11
  832. float r6 = java.lang.Math.max(r6, r10) // Catch:{ Exception -> 0x041f }
  833. android.graphics.Rect r10 = r8.src // Catch:{ Exception -> 0x041f }
  834. android.graphics.Rect r11 = r8.src // Catch:{ Exception -> 0x041f }
  835. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x041f }
  836. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x041f }
  837. r15 = 0
  838. r13.bottom = r15 // Catch:{ Exception -> 0x041f }
  839. r12.right = r15 // Catch:{ Exception -> 0x041f }
  840. r11.top = r15 // Catch:{ Exception -> 0x041f }
  841. r10.left = r15 // Catch:{ Exception -> 0x041f }
  842. android.graphics.Rect r10 = r8.dst // Catch:{ Exception -> 0x041f }
  843. android.graphics.Rect r11 = r8.dst // Catch:{ Exception -> 0x041f }
  844. android.graphics.Rect r12 = r8.dst // Catch:{ Exception -> 0x041f }
  845. android.graphics.Rect r13 = r8.dst // Catch:{ Exception -> 0x041f }
  846. r13.bottom = r15 // Catch:{ Exception -> 0x041f }
  847. r12.right = r15 // Catch:{ Exception -> 0x041f }
  848. r11.top = r15 // Catch:{ Exception -> 0x041f }
  849. r10.left = r15 // Catch:{ Exception -> 0x041f }
  850. android.graphics.Rect r10 = r8.src // Catch:{ Exception -> 0x041f }
  851. int r11 = r9.previewPaperRectLeft // Catch:{ Exception -> 0x041f }
  852. float r11 = (float) r11 // Catch:{ Exception -> 0x041f }
  853. float r12 = r9.previewImageRectLeft // Catch:{ Exception -> 0x041f }
  854. float r11 = r11 - r12
  855. int r11 = r11 // Catch:{ Exception -> 0x041f }
  856. r10.left = r11 // Catch:{ Exception -> 0x041f }
  857. android.graphics.Rect r10 = r8.src // Catch:{ Exception -> 0x041f }
  858. int r11 = r9.previewPaperRectTop // Catch:{ Exception -> 0x041f }
  859. float r11 = (float) r11 // Catch:{ Exception -> 0x041f }
  860. float r12 = r9.previewImageRectTop // Catch:{ Exception -> 0x041f }
  861. float r11 = r11 - r12
  862. int r11 = r11 // Catch:{ Exception -> 0x041f }
  863. r10.top = r11 // Catch:{ Exception -> 0x041f }
  864. android.graphics.Rect r10 = r8.src // Catch:{ Exception -> 0x041f }
  865. int r10 = r10.left // Catch:{ Exception -> 0x041f }
  866. if (r10 >= 0) goto L_0x009e
  867. android.graphics.Rect r10 = r8.src // Catch:{ Exception -> 0x0022 }
  868. int r10 = r10.left // Catch:{ Exception -> 0x0022 }
  869. int r10 = -r10
  870. android.graphics.Rect r11 = r8.src // Catch:{ Exception -> 0x0022 }
  871. r11.left = r15 // Catch:{ Exception -> 0x0022 }
  872. goto L_0x009f
  873. L_0x009e:
  874. r10 = 0
  875. L_0x009f:
  876. android.graphics.Rect r11 = r8.src // Catch:{ Exception -> 0x041f }
  877. int r11 = r11.top // Catch:{ Exception -> 0x041f }
  878. if (r11 >= 0) goto L_0x00af
  879. android.graphics.Rect r11 = r8.src // Catch:{ Exception -> 0x0022 }
  880. int r11 = r11.top // Catch:{ Exception -> 0x0022 }
  881. int r11 = -r11
  882. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x0022 }
  883. r12.top = r15 // Catch:{ Exception -> 0x0022 }
  884. goto L_0x00b0
  885. L_0x00af:
  886. r11 = 0
  887. L_0x00b0:
  888. int r12 = r9.previewPaperRectRight // Catch:{ Exception -> 0x041f }
  889. float r12 = (float) r12 // Catch:{ Exception -> 0x041f }
  890. float r13 = r9.previewImageRectRight // Catch:{ Exception -> 0x041f }
  891. int r12 = (r12 > r13 ? 1 : (r12 == r13 ? 0 : -1))
  892. if (r12 > 0) goto L_0x00c6
  893. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x0022 }
  894. int r13 = r9.previewPaperRectRight // Catch:{ Exception -> 0x0022 }
  895. float r13 = (float) r13 // Catch:{ Exception -> 0x0022 }
  896. float r14 = r9.previewImageRectLeft // Catch:{ Exception -> 0x0022 }
  897. float r13 = r13 - r14
  898. int r13 = r13 // Catch:{ Exception -> 0x0022 }
  899. r12.right = r13 // Catch:{ Exception -> 0x0022 }
  900. r12 = 0
  901. goto L_0x00d7
  902. L_0x00c6:
  903. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x041f }
  904. float r13 = r9.previewImageRectRight // Catch:{ Exception -> 0x041f }
  905. float r14 = r9.previewImageRectLeft // Catch:{ Exception -> 0x041f }
  906. float r13 = r13 - r14
  907. int r13 = r13 // Catch:{ Exception -> 0x041f }
  908. r12.right = r13 // Catch:{ Exception -> 0x041f }
  909. int r12 = r9.previewPaperRectRight // Catch:{ Exception -> 0x041f }
  910. float r12 = (float) r12 // Catch:{ Exception -> 0x041f }
  911. float r13 = r9.previewImageRectRight // Catch:{ Exception -> 0x041f }
  912. float r12 = r12 - r13
  913. int r12 = r12 // Catch:{ Exception -> 0x041f }
  914. L_0x00d7:
  915. int r13 = r9.previewPaperRectBottom // Catch:{ Exception -> 0x041f }
  916. float r13 = (float) r13 // Catch:{ Exception -> 0x041f }
  917. float r14 = r9.previewImageRectBottom // Catch:{ Exception -> 0x041f }
  918. int r13 = (r13 > r14 ? 1 : (r13 == r14 ? 0 : -1))
  919. if (r13 > 0) goto L_0x00f2
  920. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0022 }
  921. int r14 = r9.previewPaperRectBottom // Catch:{ Exception -> 0x0022 }
  922. float r14 = (float) r14
  923. float r7 = r9.previewImageRectTop // Catch:{ Exception -> 0x00ed }
  924. float r14 = r14 - r7
  925. int r7 = r14 // Catch:{ Exception -> 0x00ed }
  926. r13.bottom = r7 // Catch:{ Exception -> 0x00ed }
  927. r7 = 0
  928. goto L_0x0103
  929. L_0x00ed:
  930. r0 = move-exception
  931. r1 = r0
  932. r10 = 0
  933. goto L_0x0422
  934. L_0x00f2:
  935. android.graphics.Rect r7 = r8.src // Catch:{ Exception -> 0x0413 }
  936. float r13 = r9.previewImageRectBottom // Catch:{ Exception -> 0x0413 }
  937. float r14 = r9.previewImageRectTop // Catch:{ Exception -> 0x0413 }
  938. float r13 = r13 - r14
  939. int r13 = r13 // Catch:{ Exception -> 0x0413 }
  940. r7.bottom = r13 // Catch:{ Exception -> 0x0413 }
  941. int r7 = r9.previewPaperRectBottom // Catch:{ Exception -> 0x0413 }
  942. float r7 = (float) r7 // Catch:{ Exception -> 0x0413 }
  943. float r13 = r9.previewImageRectBottom // Catch:{ Exception -> 0x0413 }
  944. float r7 = r7 - r13
  945. int r7 = r7 // Catch:{ Exception -> 0x0413 }
  946. L_0x0103:
  947. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  948. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  949. int r14 = r14.left // Catch:{ Exception -> 0x0413 }
  950. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  951. float r15 = r9.scaleFactor // Catch:{ Exception -> 0x0413 }
  952. float r14 = r14 / r15
  953. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  954. r13.left = r14 // Catch:{ Exception -> 0x0413 }
  955. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  956. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  957. int r14 = r14.top // Catch:{ Exception -> 0x0413 }
  958. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  959. float r15 = r9.scaleFactor // Catch:{ Exception -> 0x0413 }
  960. float r14 = r14 / r15
  961. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  962. r13.top = r14 // Catch:{ Exception -> 0x0413 }
  963. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  964. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  965. int r14 = r14.right // Catch:{ Exception -> 0x0413 }
  966. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  967. float r15 = r9.scaleFactor // Catch:{ Exception -> 0x0413 }
  968. float r14 = r14 / r15
  969. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  970. r13.right = r14 // Catch:{ Exception -> 0x0413 }
  971. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  972. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  973. int r14 = r14.bottom // Catch:{ Exception -> 0x0413 }
  974. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  975. float r15 = r9.scaleFactor // Catch:{ Exception -> 0x0413 }
  976. float r14 = r14 / r15
  977. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  978. r13.bottom = r14 // Catch:{ Exception -> 0x0413 }
  979. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  980. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  981. int r14 = r14.left // Catch:{ Exception -> 0x0413 }
  982. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  983. float r14 = r14 * r6
  984. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  985. r13.left = r14 // Catch:{ Exception -> 0x0413 }
  986. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  987. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  988. int r14 = r14.top // Catch:{ Exception -> 0x0413 }
  989. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  990. float r14 = r14 * r6
  991. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  992. r13.top = r14 // Catch:{ Exception -> 0x0413 }
  993. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  994. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  995. int r14 = r14.right // Catch:{ Exception -> 0x0413 }
  996. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  997. float r14 = r14 * r6
  998. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  999. r13.right = r14 // Catch:{ Exception -> 0x0413 }
  1000. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  1001. android.graphics.Rect r14 = r8.src // Catch:{ Exception -> 0x0413 }
  1002. int r14 = r14.bottom // Catch:{ Exception -> 0x0413 }
  1003. float r14 = (float) r14 // Catch:{ Exception -> 0x0413 }
  1004. float r14 = r14 * r6
  1005. int r14 = r14 // Catch:{ Exception -> 0x0413 }
  1006. r13.bottom = r14 // Catch:{ Exception -> 0x0413 }
  1007. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  1008. int r13 = r13.right // Catch:{ Exception -> 0x0413 }
  1009. int r14 = r9.decodeWidth // Catch:{ Exception -> 0x0413 }
  1010. int r14 = r14 - r5
  1011. r15 = 1073741824(0x40000000, float:2.0)
  1012. if (r13 <= r14) goto L_0x0187
  1013. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x00ed }
  1014. int r13 = r13.right // Catch:{ Exception -> 0x00ed }
  1015. int r14 = r9.decodeWidth // Catch:{ Exception -> 0x00ed }
  1016. int r13 = r13 - r14
  1017. int r13 = r13 + r5
  1018. float r13 = (float) r13 // Catch:{ Exception -> 0x00ed }
  1019. float r13 = r13 / r15
  1020. float r13 = r13 / r6
  1021. int r13 = r13 // Catch:{ Exception -> 0x00ed }
  1022. int r10 = r10 + r13
  1023. int r12 = r12 + r13
  1024. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x00ed }
  1025. int r14 = r9.decodeWidth // Catch:{ Exception -> 0x00ed }
  1026. int r14 = r14 - r5
  1027. r13.right = r14 // Catch:{ Exception -> 0x00ed }
  1028. L_0x0187:
  1029. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x0413 }
  1030. int r13 = r13.bottom // Catch:{ Exception -> 0x0413 }
  1031. int r14 = r9.decodeHeight // Catch:{ Exception -> 0x0413 }
  1032. int r14 = r14 - r5
  1033. if (r13 <= r14) goto L_0x01a5
  1034. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x00ed }
  1035. int r13 = r13.bottom // Catch:{ Exception -> 0x00ed }
  1036. int r14 = r9.decodeHeight // Catch:{ Exception -> 0x00ed }
  1037. int r13 = r13 - r14
  1038. int r13 = r13 + r5
  1039. float r13 = (float) r13 // Catch:{ Exception -> 0x00ed }
  1040. float r13 = r13 / r15
  1041. float r13 = r13 / r6
  1042. int r6 = r13 // Catch:{ Exception -> 0x00ed }
  1043. int r11 = r11 + r6
  1044. int r7 = r7 + r6
  1045. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x00ed }
  1046. int r13 = r9.decodeHeight // Catch:{ Exception -> 0x00ed }
  1047. int r13 = r13 - r5
  1048. r6.bottom = r13 // Catch:{ Exception -> 0x00ed }
  1049. L_0x01a5:
  1050. float r6 = (float) r3
  1051. int r13 = r9.previewPaperRectRight // Catch:{ Exception -> 0x0413 }
  1052. int r14 = r9.previewPaperRectLeft // Catch:{ Exception -> 0x0413 }
  1053. int r13 = r13 - r14
  1054. int r13 = r13 + r5
  1055. float r13 = (float) r13 // Catch:{ Exception -> 0x0413 }
  1056. float r6 = r6 / r13
  1057. int r13 = r9.rotate // Catch:{ Exception -> 0x0413 }
  1058. int r13 = r13 % 360
  1059. r14 = 90
  1060. if (r13 == r14) goto L_0x01c5
  1061. int r13 = r9.rotate // Catch:{ Exception -> 0x00ed }
  1062. int r13 = r13 % 360
  1063. r14 = 270(0x10e, float:3.78E-43)
  1064. if (r13 != r14) goto L_0x01bf
  1065. goto L_0x01c5
  1066. L_0x01bf:
  1067. r25 = r12
  1068. r12 = r7
  1069. r7 = r25
  1070. goto L_0x01d3
  1071. L_0x01c5:
  1072. float r6 = (float) r4
  1073. int r13 = r9.previewPaperRectRight // Catch:{ Exception -> 0x0413 }
  1074. int r14 = r9.previewPaperRectLeft // Catch:{ Exception -> 0x0413 }
  1075. int r13 = r13 - r14
  1076. int r13 = r13 + r5
  1077. float r13 = (float) r13 // Catch:{ Exception -> 0x0413 }
  1078. float r6 = r6 / r13
  1079. r25 = r11
  1080. r11 = r10
  1081. r10 = r25
  1082. L_0x01d3:
  1083. android.graphics.Rect r13 = r8.dst // Catch:{ Exception -> 0x0413 }
  1084. float r10 = (float) r10 // Catch:{ Exception -> 0x0413 }
  1085. float r10 = r10 * r6
  1086. int r10 = r10 // Catch:{ Exception -> 0x0413 }
  1087. r13.left = r10 // Catch:{ Exception -> 0x0413 }
  1088. android.graphics.Rect r10 = r8.dst // Catch:{ Exception -> 0x0413 }
  1089. float r11 = (float) r11 // Catch:{ Exception -> 0x0413 }
  1090. float r11 = r11 * r6
  1091. int r11 = r11 // Catch:{ Exception -> 0x0413 }
  1092. r10.top = r11 // Catch:{ Exception -> 0x0413 }
  1093. android.graphics.Rect r10 = r8.dst // Catch:{ Exception -> 0x0413 }
  1094. int r11 = r3 + -1
  1095. float r11 = (float) r11 // Catch:{ Exception -> 0x0413 }
  1096. float r7 = (float) r7 // Catch:{ Exception -> 0x0413 }
  1097. float r7 = r7 * r6
  1098. float r11 = r11 - r7
  1099. int r7 = r11 // Catch:{ Exception -> 0x0413 }
  1100. r10.right = r7 // Catch:{ Exception -> 0x0413 }
  1101. android.graphics.Rect r7 = r8.dst // Catch:{ Exception -> 0x0413 }
  1102. int r10 = r4 + -1
  1103. float r10 = (float) r10 // Catch:{ Exception -> 0x0413 }
  1104. float r11 = (float) r12 // Catch:{ Exception -> 0x0413 }
  1105. float r11 = r11 * r6
  1106. float r10 = r10 - r11
  1107. int r6 = r10 // Catch:{ Exception -> 0x0413 }
  1108. r7.bottom = r6 // Catch:{ Exception -> 0x0413 }
  1109. if (r1 != r5) goto L_0x0266
  1110. android.content.Context r6 = r8.mContext // Catch:{ Exception -> 0x00ed }
  1111. r7 = r32
  1112. epson.common.Info_paper r6 = epson.common.Info_paper.getInfoPaper(r6, r7) // Catch:{ Exception -> 0x00ed }
  1113. int r7 = r6.getTopMargin() // Catch:{ Exception -> 0x00ed }
  1114. int r7 = -r7
  1115. int r10 = r6.getLeftMargin() // Catch:{ Exception -> 0x00ed }
  1116. int r10 = -r10
  1117. int r11 = r6.getBottomMargin() // Catch:{ Exception -> 0x00ed }
  1118. int r11 = -r11
  1119. int r12 = r6.getRightMargin() // Catch:{ Exception -> 0x00ed }
  1120. int r12 = -r12
  1121. if (r36 == 0) goto L_0x022a
  1122. android.graphics.Rect r13 = r8.src // Catch:{ Exception -> 0x00ed }
  1123. int r13 = r13.width() // Catch:{ Exception -> 0x00ed }
  1124. float r13 = (float) r13 // Catch:{ Exception -> 0x00ed }
  1125. int r6 = r6.getPaper_width_boderless() // Catch:{ Exception -> 0x00ed }
  1126. int r6 = r6 - r5
  1127. float r6 = (float) r6 // Catch:{ Exception -> 0x00ed }
  1128. float r13 = r13 / r6
  1129. goto L_0x023a
  1130. L_0x022a:
  1131. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x00ed }
  1132. int r6 = r6.width() // Catch:{ Exception -> 0x00ed }
  1133. float r6 = (float) r6 // Catch:{ Exception -> 0x00ed }
  1134. android.graphics.Rect r13 = r8.dst // Catch:{ Exception -> 0x00ed }
  1135. int r13 = r13.width() // Catch:{ Exception -> 0x00ed }
  1136. float r13 = (float) r13 // Catch:{ Exception -> 0x00ed }
  1137. float r13 = r6 / r13
  1138. L_0x023a:
  1139. float r6 = (float) r7 // Catch:{ Exception -> 0x00ed }
  1140. float r6 = r6 * r13
  1141. int r6 = r6 // Catch:{ Exception -> 0x00ed }
  1142. float r7 = (float) r10 // Catch:{ Exception -> 0x00ed }
  1143. float r7 = r7 * r13
  1144. int r7 = r7 // Catch:{ Exception -> 0x00ed }
  1145. float r10 = (float) r11 // Catch:{ Exception -> 0x00ed }
  1146. float r10 = r10 * r13
  1147. int r10 = r10 // Catch:{ Exception -> 0x00ed }
  1148. float r11 = (float) r12 // Catch:{ Exception -> 0x00ed }
  1149. float r11 = r11 * r13
  1150. int r11 = r11 // Catch:{ Exception -> 0x00ed }
  1151. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x00ed }
  1152. int r13 = r12.top // Catch:{ Exception -> 0x00ed }
  1153. int r13 = r13 - r6
  1154. r12.top = r13 // Catch:{ Exception -> 0x00ed }
  1155. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x00ed }
  1156. int r12 = r6.left // Catch:{ Exception -> 0x00ed }
  1157. int r12 = r12 - r7
  1158. r6.left = r12 // Catch:{ Exception -> 0x00ed }
  1159. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x00ed }
  1160. int r7 = r6.bottom // Catch:{ Exception -> 0x00ed }
  1161. int r7 = r7 + r10
  1162. r6.bottom = r7 // Catch:{ Exception -> 0x00ed }
  1163. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x00ed }
  1164. int r7 = r6.right // Catch:{ Exception -> 0x00ed }
  1165. int r7 = r7 + r11
  1166. r6.right = r7 // Catch:{ Exception -> 0x00ed }
  1167. L_0x0266:
  1168. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x0413 }
  1169. android.graphics.Rect r7 = r8.src // Catch:{ Exception -> 0x0413 }
  1170. int r7 = r7.left // Catch:{ Exception -> 0x0413 }
  1171. int r10 = r9.decodeWidth // Catch:{ Exception -> 0x0413 }
  1172. int r10 = r10 - r5
  1173. int r7 = java.lang.Math.min(r7, r10) // Catch:{ Exception -> 0x0413 }
  1174. r10 = 0
  1175. int r7 = java.lang.Math.max(r10, r7) // Catch:{ Exception -> 0x0413 }
  1176. r6.left = r7 // Catch:{ Exception -> 0x0413 }
  1177. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x0413 }
  1178. android.graphics.Rect r7 = r8.src // Catch:{ Exception -> 0x0413 }
  1179. int r7 = r7.top // Catch:{ Exception -> 0x0413 }
  1180. int r10 = r9.decodeHeight // Catch:{ Exception -> 0x0413 }
  1181. int r10 = r10 - r5
  1182. int r7 = java.lang.Math.min(r7, r10) // Catch:{ Exception -> 0x0413 }
  1183. r10 = 0
  1184. int r7 = java.lang.Math.max(r10, r7) // Catch:{ Exception -> 0x0413 }
  1185. r6.top = r7 // Catch:{ Exception -> 0x0413 }
  1186. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x0413 }
  1187. android.graphics.Rect r7 = r8.src // Catch:{ Exception -> 0x0413 }
  1188. int r7 = r7.right // Catch:{ Exception -> 0x0413 }
  1189. int r10 = r9.decodeWidth // Catch:{ Exception -> 0x0413 }
  1190. int r10 = r10 - r5
  1191. int r7 = java.lang.Math.min(r7, r10) // Catch:{ Exception -> 0x0413 }
  1192. r10 = 0
  1193. int r7 = java.lang.Math.max(r10, r7) // Catch:{ Exception -> 0x0413 }
  1194. r6.right = r7 // Catch:{ Exception -> 0x0413 }
  1195. android.graphics.Rect r6 = r8.src // Catch:{ Exception -> 0x0413 }
  1196. android.graphics.Rect r7 = r8.src // Catch:{ Exception -> 0x0413 }
  1197. int r7 = r7.bottom // Catch:{ Exception -> 0x0413 }
  1198. int r10 = r9.decodeHeight // Catch:{ Exception -> 0x0413 }
  1199. int r10 = r10 - r5
  1200. int r7 = java.lang.Math.min(r7, r10) // Catch:{ Exception -> 0x0413 }
  1201. r15 = 0
  1202. int r7 = java.lang.Math.max(r15, r7) // Catch:{ Exception -> 0x0413 }
  1203. r6.bottom = r7 // Catch:{ Exception -> 0x0413 }
  1204. java.lang.String r6 = r9.decodeImageFileName // Catch:{ Exception -> 0x0413 }
  1205. r8.rotate(r9, r3, r4) // Catch:{ Exception -> 0x0413 }
  1206. int r7 = r9.rotate // Catch:{ Exception -> 0x0413 }
  1207. if (r7 == 0) goto L_0x02ed
  1208. android.content.Context r7 = r8.mContext // Catch:{ Exception -> 0x00ed }
  1209. epson.common.ExternalFileUtils r7 = epson.common.ExternalFileUtils.getInstance(r7) // Catch:{ Exception -> 0x00ed }
  1210. java.lang.String r7 = r7.getTempViewDir() // Catch:{ Exception -> 0x00ed }
  1211. boolean r7 = r6.startsWith(r7) // Catch:{ Exception -> 0x00ed }
  1212. if (r7 == 0) goto L_0x02ed
  1213. java.lang.String r7 = "createPrintImage"
  1214. java.lang.StringBuilder r10 = new java.lang.StringBuilder // Catch:{ Exception -> 0x00ed }
  1215. r10.<init>() // Catch:{ Exception -> 0x00ed }
  1216. java.lang.String r11 = "Delete decorded image : "
  1217. r10.append(r11) // Catch:{ Exception -> 0x00ed }
  1218. r10.append(r6) // Catch:{ Exception -> 0x00ed }
  1219. java.lang.String r10 = r10.toString() // Catch:{ Exception -> 0x00ed }
  1220. epson.print.Util.EPLog.m313i(r7, r10) // Catch:{ Exception -> 0x00ed }
  1221. java.io.File r7 = new java.io.File // Catch:{ Exception -> 0x00ed }
  1222. r7.<init>(r6) // Catch:{ Exception -> 0x00ed }
  1223. r7.delete() // Catch:{ Exception -> 0x00ed }
  1224. L_0x02ed:
  1225. if (r36 != 0) goto L_0x0356
  1226. r6 = r34
  1227. if (r6 != r5) goto L_0x0356
  1228. java.lang.String r6 = r9.decodeImageFileName // Catch:{ Exception -> 0x00ed }
  1229. java.io.File r7 = new java.io.File // Catch:{ Exception -> 0x00ed }
  1230. android.content.Context r10 = r8.mContext // Catch:{ Exception -> 0x00ed }
  1231. epson.common.ExternalFileUtils r10 = epson.common.ExternalFileUtils.getInstance(r10) // Catch:{ Exception -> 0x00ed }
  1232. java.lang.String r10 = r10.getTempViewDir() // Catch:{ Exception -> 0x00ed }
  1233. java.lang.StringBuilder r11 = new java.lang.StringBuilder // Catch:{ Exception -> 0x00ed }
  1234. r11.<init>() // Catch:{ Exception -> 0x00ed }
  1235. java.lang.String r12 = "print_"
  1236. r11.append(r12) // Catch:{ Exception -> 0x00ed }
  1237. int r12 = r9.index // Catch:{ Exception -> 0x00ed }
  1238. int r12 = r12 + r5
  1239. r11.append(r12) // Catch:{ Exception -> 0x00ed }
  1240. java.lang.String r12 = "_gray.bmp"
  1241. r11.append(r12) // Catch:{ Exception -> 0x00ed }
  1242. java.lang.String r11 = r11.toString() // Catch:{ Exception -> 0x00ed }
  1243. r7.<init>(r10, r11) // Catch:{ Exception -> 0x00ed }
  1244. java.lang.String r7 = r7.getPath() // Catch:{ Exception -> 0x00ed }
  1245. epson.print.EPImageUtil r10 = r8.util // Catch:{ Exception -> 0x00ed }
  1246. r10.color2grayscale(r6, r7) // Catch:{ Exception -> 0x00ed }
  1247. android.content.Context r10 = r8.mContext // Catch:{ Exception -> 0x00ed }
  1248. epson.common.ExternalFileUtils r10 = epson.common.ExternalFileUtils.getInstance(r10) // Catch:{ Exception -> 0x00ed }
  1249. java.lang.String r10 = r10.getTempViewDir() // Catch:{ Exception -> 0x00ed }
  1250. boolean r10 = r6.startsWith(r10) // Catch:{ Exception -> 0x00ed }
  1251. if (r10 == 0) goto L_0x0354
  1252. java.lang.String r10 = "createPrintImage"
  1253. java.lang.StringBuilder r11 = new java.lang.StringBuilder // Catch:{ Exception -> 0x00ed }
  1254. r11.<init>() // Catch:{ Exception -> 0x00ed }
  1255. java.lang.String r12 = "Delete decorded image : "
  1256. r11.append(r12) // Catch:{ Exception -> 0x00ed }
  1257. r11.append(r6) // Catch:{ Exception -> 0x00ed }
  1258. java.lang.String r11 = r11.toString() // Catch:{ Exception -> 0x00ed }
  1259. epson.print.Util.EPLog.m313i(r10, r11) // Catch:{ Exception -> 0x00ed }
  1260. java.io.File r10 = new java.io.File // Catch:{ Exception -> 0x00ed }
  1261. r10.<init>(r6) // Catch:{ Exception -> 0x00ed }
  1262. r10.delete() // Catch:{ Exception -> 0x00ed }
  1263. L_0x0354:
  1264. r9.decodeImageFileName = r7 // Catch:{ Exception -> 0x00ed }
  1265. L_0x0356:
  1266. java.io.File r6 = new java.io.File // Catch:{ Exception -> 0x0413 }
  1267. android.content.Context r7 = r8.mContext // Catch:{ Exception -> 0x0413 }
  1268. epson.common.ExternalFileUtils r7 = epson.common.ExternalFileUtils.getInstance(r7) // Catch:{ Exception -> 0x0413 }
  1269. java.lang.String r7 = r7.getPrintDir() // Catch:{ Exception -> 0x0413 }
  1270. java.lang.StringBuilder r10 = new java.lang.StringBuilder // Catch:{ Exception -> 0x0413 }
  1271. r10.<init>() // Catch:{ Exception -> 0x0413 }
  1272. int r11 = r9.index // Catch:{ Exception -> 0x0413 }
  1273. int r11 = r11 + r5
  1274. r10.append(r11) // Catch:{ Exception -> 0x0413 }
  1275. java.lang.String r11 = ".bmp"
  1276. r10.append(r11) // Catch:{ Exception -> 0x0413 }
  1277. java.lang.String r10 = r10.toString() // Catch:{ Exception -> 0x0413 }
  1278. r6.<init>(r7, r10) // Catch:{ Exception -> 0x0413 }
  1279. java.lang.String r6 = r6.getPath() // Catch:{ Exception -> 0x0413 }
  1280. epson.print.EPImageUtil r10 = r8.util // Catch:{ Exception -> 0x0413 }
  1281. java.lang.String r11 = r9.decodeImageFileName // Catch:{ Exception -> 0x0413 }
  1282. android.graphics.Rect r7 = r8.src // Catch:{ Exception -> 0x0413 }
  1283. int r7 = r7.left // Catch:{ Exception -> 0x0413 }
  1284. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x0413 }
  1285. int r14 = r12.top // Catch:{ Exception -> 0x0413 }
  1286. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x0413 }
  1287. int r13 = r12.right // Catch:{ Exception -> 0x0413 }
  1288. android.graphics.Rect r12 = r8.src // Catch:{ Exception -> 0x0413 }
  1289. int r12 = r12.bottom // Catch:{ Exception -> 0x0413 }
  1290. android.graphics.Rect r15 = r8.dst // Catch:{ Exception -> 0x0413 }
  1291. int r15 = r15.left // Catch:{ Exception -> 0x0413 }
  1292. android.graphics.Rect r5 = r8.dst // Catch:{ Exception -> 0x0413 }
  1293. int r5 = r5.top // Catch:{ Exception -> 0x0413 }
  1294. android.graphics.Rect r3 = r8.dst // Catch:{ Exception -> 0x0413 }
  1295. int r3 = r3.right // Catch:{ Exception -> 0x0413 }
  1296. android.graphics.Rect r4 = r8.dst // Catch:{ Exception -> 0x0413 }
  1297. int r4 = r4.bottom // Catch:{ Exception -> 0x0413 }
  1298. r18 = r12
  1299. r12 = r6
  1300. r17 = r13
  1301. r13 = r30
  1302. r19 = r14
  1303. r14 = r31
  1304. r20 = r15
  1305. r24 = 0
  1306. r15 = r7
  1307. r16 = r19
  1308. r19 = r20
  1309. r20 = r5
  1310. r21 = r3
  1311. r22 = r4
  1312. r10.resizeImage(r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22) // Catch:{ Exception -> 0x0413 }
  1313. java.lang.String r3 = r9.decodeImageFileName // Catch:{ Exception -> 0x0413 }
  1314. android.content.Context r4 = r8.mContext // Catch:{ Exception -> 0x0413 }
  1315. epson.common.ExternalFileUtils r4 = epson.common.ExternalFileUtils.getInstance(r4) // Catch:{ Exception -> 0x0413 }
  1316. java.lang.String r4 = r4.getTempViewDir() // Catch:{ Exception -> 0x0413 }
  1317. boolean r3 = r3.startsWith(r4) // Catch:{ Exception -> 0x0413 }
  1318. if (r3 == 0) goto L_0x03f2
  1319. java.lang.String r3 = "createPrintImage"
  1320. java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch:{ Exception -> 0x00ed }
  1321. r4.<init>() // Catch:{ Exception -> 0x00ed }
  1322. java.lang.String r5 = "Delete decorded image : "
  1323. r4.append(r5) // Catch:{ Exception -> 0x00ed }
  1324. java.lang.String r5 = r9.decodeImageFileName // Catch:{ Exception -> 0x00ed }
  1325. r4.append(r5) // Catch:{ Exception -> 0x00ed }
  1326. java.lang.String r4 = r4.toString() // Catch:{ Exception -> 0x00ed }
  1327. epson.print.Util.EPLog.m313i(r3, r4) // Catch:{ Exception -> 0x00ed }
  1328. java.io.File r3 = new java.io.File // Catch:{ Exception -> 0x00ed }
  1329. java.lang.String r4 = r9.decodeImageFileName // Catch:{ Exception -> 0x00ed }
  1330. r3.<init>(r4) // Catch:{ Exception -> 0x00ed }
  1331. r3.delete() // Catch:{ Exception -> 0x00ed }
  1332. L_0x03f2:
  1333. r9.decodeImageFileName = r6 // Catch:{ Exception -> 0x0413 }
  1334. if (r2 == 0) goto L_0x0427
  1335. java.lang.String r3 = r28.getOriginalFileName() // Catch:{ Exception -> 0x0413 }
  1336. java.lang.String r5 = epson.print.Util.Photo.getDateTimeSystem(r3, r2) // Catch:{ Exception -> 0x0413 }
  1337. r2 = 1
  1338. if (r1 != r2) goto L_0x0403
  1339. r7 = 1
  1340. goto L_0x0404
  1341. L_0x0403:
  1342. r7 = 0
  1343. L_0x0404:
  1344. r1 = r26
  1345. r2 = r28
  1346. r3 = r30
  1347. r4 = r31
  1348. r6 = r29
  1349. r10 = 0
  1350. r1.writeDate(r2, r3, r4, r5, r6, r7) // Catch:{ Exception -> 0x041d }
  1351. goto L_0x0427
  1352. L_0x0413:
  1353. r0 = move-exception
  1354. r10 = 0
  1355. goto L_0x0421
  1356. L_0x0416:
  1357. r10 = r7
  1358. java.lang.IllegalStateException r1 = new java.lang.IllegalStateException // Catch:{ Exception -> 0x041d }
  1359. r1.<init>() // Catch:{ Exception -> 0x041d }
  1360. throw r1 // Catch:{ Exception -> 0x041d }
  1361. L_0x041d:
  1362. r0 = move-exception
  1363. goto L_0x0421
  1364. L_0x041f:
  1365. r0 = move-exception
  1366. r10 = r7
  1367. L_0x0421:
  1368. r1 = r0
  1369. L_0x0422:
  1370. r1.printStackTrace() // Catch:{ all -> 0x042b }
  1371. r9.decodeImageFileName = r10 // Catch:{ all -> 0x042b }
  1372. L_0x0427:
  1373. java.lang.String r1 = r9.decodeImageFileName // Catch:{ all -> 0x042b }
  1374. monitor-exit(r23) // Catch:{ all -> 0x042b }
  1375. return r1
  1376. L_0x042b:
  1377. r0 = move-exception
  1378. r1 = r0
  1379. monitor-exit(r23) // Catch:{ all -> 0x042b }
  1380. throw r1
  1381. */
  1382. throw new UnsupportedOperationException("Method not decompiled: epson.print.EPImageCreator.createPrintImage_origi(android.content.Context, epson.print.EPImage, int, int, int, int, int, int, int, boolean):java.lang.String");
  1383. }
  1384. public String createMultiPrintImage_org(Context context, int i, int i2, EPImageList ePImageList, int i3, int i4, int i5, int i6, int i7, int i8, int i9) {
  1385. Rect rect;
  1386. int i10;
  1387. int i11;
  1388. Mat mat;
  1389. EPImage ePImage;
  1390. boolean z;
  1391. boolean z2;
  1392. int i12 = i;
  1393. int i13 = i2;
  1394. EPImageList ePImageList2 = ePImageList;
  1395. int i14 = i3;
  1396. int i15 = i4;
  1397. int i16 = i5;
  1398. int i17 = i9;
  1399. new ArrayList();
  1400. boolean z3 = ePImageList2.get(0).isPaperLandScape;
  1401. Mat mat2 = new Mat(i16, i15, CvType.CV_8UC3, Scalar.all(255.0d));
  1402. boolean z4 = i15 > i16;
  1403. if (i12 == 65536) {
  1404. i10 = i14 * 2;
  1405. rect = Info_paper.getRect_2in1(i15, i16, i13, true);
  1406. } else if (i12 == 131072 || i12 == 262144) {
  1407. i10 = i14 * 4;
  1408. rect = Info_paper.getRect_4in1(i15, i16, i13, true);
  1409. } else {
  1410. rect = null;
  1411. i10 = 0;
  1412. }
  1413. boolean z5 = rect.width() > rect.height();
  1414. while (true) {
  1415. try {
  1416. EPImage ePImage2 = ePImageList2.get(i10);
  1417. if (ePImage2 == null) {
  1418. mat = mat2;
  1419. i11 = i16;
  1420. } else {
  1421. if (ePImage2.isPaperLandScape != z5) {
  1422. if (z4) {
  1423. ePImage2.rotate += EPImage.EPS_ROTATE_270;
  1424. } else {
  1425. ePImage2.rotate += 90;
  1426. }
  1427. }
  1428. int i18 = i10;
  1429. boolean z6 = z5;
  1430. boolean z7 = z4;
  1431. Mat mat3 = mat2;
  1432. boolean z8 = z3;
  1433. i11 = i16;
  1434. String createPrintImage_origi = createPrintImage_origi(context, ePImage2, i2, rect.width(), rect.height(), i6, 2, i7, i8, false);
  1435. if (createPrintImage_origi == null) {
  1436. mat = mat3;
  1437. } else {
  1438. if (i12 != 65536) {
  1439. if (i12 != 131072) {
  1440. if (i12 != 262144) {
  1441. z = z7;
  1442. mat = mat3;
  1443. z2 = z8;
  1444. }
  1445. }
  1446. int i19 = i18 % 4;
  1447. z = z7;
  1448. z2 = z8;
  1449. mat = mat3;
  1450. MakeMultiPrintImage.layoutPrintImage(mat, createPrintImage_origi, MakeMultiPrintImage.calcLayout4in1(i12, z, z2, i19));
  1451. if (i19 == 3) {
  1452. }
  1453. } else {
  1454. z = z7;
  1455. mat = mat3;
  1456. z2 = z8;
  1457. switch (i18 % 2) {
  1458. case 0:
  1459. MakeMultiPrintImage.layoutPrintImage(mat, createPrintImage_origi, 0);
  1460. continue;
  1461. case 1:
  1462. MakeMultiPrintImage.layoutPrintImage(mat, createPrintImage_origi, 3);
  1463. break;
  1464. default:
  1465. continue;
  1466. }
  1467. }
  1468. i10 = i18 + 1;
  1469. z3 = z2;
  1470. z4 = z;
  1471. mat2 = mat;
  1472. i16 = i11;
  1473. z5 = z6;
  1474. int i20 = i9;
  1475. int i21 = i2;
  1476. }
  1477. }
  1478. } catch (IndexOutOfBoundsException unused) {
  1479. mat = mat2;
  1480. i11 = i16;
  1481. } catch (Throwable unused2) {
  1482. mat = mat2;
  1483. i11 = i16;
  1484. }
  1485. }
  1486. String path = new File(ExternalFileUtils.getInstance(context).getPrintDir(), "multi_" + (i14 + 1) + ".bmp").getPath();
  1487. Imgcodecs.imwrite(path, mat);
  1488. mat.release();
  1489. int i22 = i9;
  1490. if (i22 % 360 == 0) {
  1491. ePImage = new EPImage();
  1492. ePImage.decodeImageFileName = path;
  1493. } else {
  1494. EPImage ePImage3 = new EPImage(path, i14);
  1495. ePImage3.rotate = i22;
  1496. ePImage3.decodeImageFileName = path;
  1497. rotate(ePImage3, i15, i11);
  1498. ePImage = ePImage3;
  1499. }
  1500. return ePImage.decodeImageFileName;
  1501. }
  1502. static class MakeMultiPrintImage {
  1503. public static final int LAYOUT_BUTTOMLEFT = 2;
  1504. public static final int LAYOUT_BUTTOMRIGHT = 3;
  1505. public static final int LAYOUT_TOPLEFT = 0;
  1506. public static final int LAYOUT_TOPRIGHT = 1;
  1507. MakeMultiPrintImage() {
  1508. }
  1509. static void layoutPrintImage(Mat mat, String str, int i) {
  1510. Mat mat2;
  1511. Mat imread = Imgcodecs.imread(str, -1);
  1512. switch (i) {
  1513. case 0:
  1514. mat2 = mat.submat(0, imread.rows(), 0, imread.cols());
  1515. break;
  1516. case 1:
  1517. mat2 = mat.submat(0, imread.rows(), mat.cols() - imread.cols(), mat.cols());
  1518. break;
  1519. case 2:
  1520. mat2 = mat.submat(mat.rows() - imread.rows(), mat.rows(), 0, imread.cols());
  1521. break;
  1522. case 3:
  1523. mat2 = mat.submat(mat.rows() - imread.rows(), mat.rows(), mat.cols() - imread.cols(), mat.cols());
  1524. break;
  1525. default:
  1526. mat2 = null;
  1527. break;
  1528. }
  1529. imread.copyTo(mat2);
  1530. mat2.release();
  1531. imread.release();
  1532. new File(str).delete();
  1533. }
  1534. static int calcLayout4in1(int i, boolean z, boolean z2, int i2) {
  1535. Mat mat;
  1536. int i3;
  1537. int i4 = i;
  1538. boolean z3 = z;
  1539. boolean z4 = z2;
  1540. Mat mat2 = new Mat(2, 2, CvType.CV_8UC1, Scalar.all(0.0d));
  1541. if (i4 == 131072) {
  1542. mat2.put(0, 0, 0.0d);
  1543. mat2.put(0, 1, 1.0d);
  1544. mat2.put(1, 0, 2.0d);
  1545. mat2.put(1, 1, 3.0d);
  1546. } else if (i4 == 262144) {
  1547. mat2.put(0, 0, 0.0d);
  1548. mat2.put(0, 1, 2.0d);
  1549. mat2.put(1, 0, 1.0d);
  1550. mat2.put(1, 1, 3.0d);
  1551. }
  1552. new Mat();
  1553. if (z3 && !z4) {
  1554. mat = mat2.mo42753t();
  1555. Core.flip(mat, mat, 0);
  1556. } else if (z3 || !z4) {
  1557. mat = mat2.clone();
  1558. } else {
  1559. mat = mat2.mo42753t();
  1560. Core.flip(mat, mat, 1);
  1561. }
  1562. mat2.release();
  1563. int i5 = 0;
  1564. loop0:
  1565. while (true) {
  1566. if (i5 >= mat.rows()) {
  1567. i5 = 0;
  1568. i3 = 0;
  1569. break;
  1570. }
  1571. i3 = 0;
  1572. while (i3 < mat.cols()) {
  1573. if ((mat.get(i5, i3)[0]) == i2) {
  1574. break loop0;
  1575. }
  1576. i3++;
  1577. }
  1578. int i6 = i2;
  1579. i5++;
  1580. }
  1581. mat.release();
  1582. if (i5 == 0) {
  1583. if (i3 != 0 && i3 == 1) {
  1584. return 1;
  1585. }
  1586. return 0;
  1587. } else if (i5 != 1) {
  1588. return 0;
  1589. } else {
  1590. if (i3 == 0) {
  1591. return 2;
  1592. }
  1593. if (i3 == 1) {
  1594. return 3;
  1595. }
  1596. return 0;
  1597. }
  1598. }
  1599. }
  1600. public int createJpegImage(EPImage ePImage, int i) {
  1601. int i2;
  1602. synchronized (lockObject) {
  1603. try {
  1604. epsonImage epsonimage = new epsonImage();
  1605. String path = new File(ExternalFileUtils.getInstance(mContext).getPrintDir(), ePImage.loadImageFileName.substring(ePImage.loadImageFileName.lastIndexOf(47) + 1)).getPath();
  1606. String str = path.substring(0, path.lastIndexOf(46)) + ".jpg";
  1607. i2 = epsonimage.bmp2Jpg2(ePImage.decodeImageFileName, str);
  1608. ePImage.decodeImageFileName = str;
  1609. } catch (Exception e) {
  1610. e.printStackTrace();
  1611. ePImage.decodeImageFileName = null;
  1612. i2 = -1;
  1613. }
  1614. }
  1615. return i2;
  1616. }
  1617. private String rotate(EPImage ePImage, int i, int i2) {
  1618. String str = ePImage.decodeImageFileName;
  1619. String tempViewDir = ExternalFileUtils.getInstance(mContext).getTempViewDir();
  1620. String path = new File(tempViewDir, "rotate_" + ePImage.rotate + CommonDefine.UNDER_BAR + (ePImage.index + 1) + ".bmp").getPath();
  1621. ePImage.rotate = ePImage.rotate % 360;
  1622. if (ePImage.rotate == 0) {
  1623. return ePImage.decodeImageFileName;
  1624. }
  1625. if (ePImage.rotate == 90 || ePImage.rotate == 270) {
  1626. int i3 = ePImage.decodeWidth;
  1627. ePImage.decodeWidth = ePImage.decodeHeight;
  1628. ePImage.decodeHeight = i3;
  1629. int i4 = ePImage.previewWidth;
  1630. ePImage.previewWidth = ePImage.previewHeight;
  1631. ePImage.previewHeight = i4;
  1632. }
  1633. int i5 = ePImage.rotate;
  1634. if (i5 == 90) {
  1635. int i6 = src.left;
  1636. src.left = (ePImage.decodeWidth - 1) - src.bottom;
  1637. Rect rect = src;
  1638. rect.bottom = rect.right;
  1639. src.right = (ePImage.decodeWidth - 1) - src.top;
  1640. src.top = i6;
  1641. } else if (i5 == 180) {
  1642. int i7 = src.left;
  1643. src.left = (ePImage.decodeWidth - 1) - src.right;
  1644. src.right = (ePImage.decodeWidth - 1) - i7;
  1645. int i8 = src.top;
  1646. src.top = (ePImage.decodeHeight - 1) - src.bottom;
  1647. src.bottom = (ePImage.decodeHeight - 1) - i8;
  1648. } else if (i5 == 270) {
  1649. int i9 = src.left;
  1650. Rect rect2 = src;
  1651. rect2.left = rect2.top;
  1652. src.top = (ePImage.decodeHeight - 1) - src.right;
  1653. Rect rect3 = src;
  1654. rect3.right = rect3.bottom;
  1655. src.bottom = (ePImage.decodeHeight - 1) - i9;
  1656. }
  1657. util.rotateImage(str, path, ePImage.rotate);
  1658. ePImage.decodeImageFileName = path;
  1659. return ePImage.decodeImageFileName;
  1660. }
  1661. public String writeDate(EPImage ePImage, int i, int i2, String str, int i3, boolean z) {
  1662. int i4;
  1663. int i5;
  1664. EPImage ePImage2 = ePImage;
  1665. String str2 = str;
  1666. boolean z2 = z;
  1667. String path = new File(ExternalFileUtils.getInstance(mContext).getPrintDir(), "date_" + (ePImage2.index + 1) + ".bmp").getPath();
  1668. int fontSize = getFontSize(i3);
  1669. if (str2 != null) {
  1670. try {
  1671. int length = str.length() * fontSize;
  1672. EPLog.m316v("drawTextToImage", "font_size=" + fontSize + " width=" + length + " height=" + fontSize);
  1673. if (length <= 0 || fontSize <= 0) {
  1674. throw new Exception();
  1675. }
  1676. Paint paint = new Paint(1);
  1677. paint.setColor(Color.rgb(226, 102, 10));
  1678. paint.setShadowLayer(1.0f, 2.0f, 2.0f, ViewCompat.MEASURED_STATE_MASK);
  1679. float f = (float) fontSize;
  1680. paint.setTextSize(f);
  1681. paint.setTextAlign(Paint.Align.RIGHT);
  1682. EPLog.m313i("drawTextToImage", "strDateTime = " + str2);
  1683. int i6 = length * fontSize;
  1684. int[] iArr = new int[i6];
  1685. int i7 = 0;
  1686. for (int i8 = 0; i8 < i6; i8++) {
  1687. iArr[i8] = -1;
  1688. }
  1689. Bitmap createBitmap = Bitmap.createBitmap(iArr, length, fontSize, Bitmap.Config.ARGB_8888);
  1690. if (createBitmap != null) {
  1691. Bitmap copy = createBitmap.copy(Bitmap.Config.ARGB_8888, true);
  1692. if (copy != null) {
  1693. createBitmap.recycle();
  1694. Canvas canvas = new Canvas(copy);
  1695. Paint.FontMetrics fontMetrics = paint.getFontMetrics();
  1696. float f2 = (fontMetrics.descent - fontMetrics.ascent) - f;
  1697. canvas.drawText(str2, ((float) length) - f2, f - f2, paint);
  1698. Bitmap copy2 = copy.copy(Bitmap.Config.ARGB_8888, false);
  1699. if (copy2 != null) {
  1700. copy.recycle();
  1701. new BMPFile().saveBitmap(path, copy2, copy2.getWidth(), copy2.getHeight());
  1702. String str3 = ePImage2.decodeImageFileName;
  1703. String path2 = new File(ExternalFileUtils.getInstance(mContext).getPrintDir(), "date2_" + (ePImage2.index + 1) + ".bmp").getPath();
  1704. int i9 = ePImage2.rotate;
  1705. if (i9 == 0) {
  1706. i7 = (i - copy2.getWidth()) - 1;
  1707. i4 = (i2 - copy2.getHeight()) - 1;
  1708. if (z2) {
  1709. i7 = (i7 - 36) - 42;
  1710. i4 = (i4 - 72) - 42;
  1711. }
  1712. } else if (i9 == 90) {
  1713. int width = (i2 - copy2.getWidth()) - 1;
  1714. if (z2) {
  1715. width = (width - 72) - 42;
  1716. i7 = 78;
  1717. }
  1718. util.rotateR90Image(path, path2);
  1719. path = path2;
  1720. } else if (i9 == 180) {
  1721. if (z2) {
  1722. i4 = 114;
  1723. i7 = 78;
  1724. } else {
  1725. i4 = 0;
  1726. }
  1727. util.rotate180Image(path, path2);
  1728. path = path2;
  1729. } else if (i9 != 270) {
  1730. i4 = 0;
  1731. } else {
  1732. int height = (i - copy2.getHeight()) - 1;
  1733. if (z2) {
  1734. i5 = 82;
  1735. i7 = (height - 36) - 42;
  1736. } else {
  1737. i7 = height;
  1738. i5 = 0;
  1739. }
  1740. util.rotateR270Image(path, path2);
  1741. i4 = i5;
  1742. path = path2;
  1743. }
  1744. util.writeDate(str3, path, i7, i4);
  1745. ePImage2.decodeImageFileName = str3;
  1746. return ePImage2.decodeImageFileName;
  1747. }
  1748. throw new Exception();
  1749. }
  1750. throw new Exception();
  1751. }
  1752. throw new Exception();
  1753. } catch (Exception e) {
  1754. e.printStackTrace();
  1755. }
  1756. } else {
  1757. throw new Exception();
  1758. }
  1759. }
  1760. private synchronized void makeCancelFile() {
  1761. try {
  1762. new File(CANCEL_FILE_NAME).createNewFile();
  1763. EPLog.m305d("EPImageCreator", "EPImageCreator::makeCancelFile() create cancel file done.");
  1764. } catch (IOException e) {
  1765. EPLog.m307e("EPImageCreator", "error. can not create cancel_file. " + e);
  1766. }
  1767. return;
  1768. }
  1769. private synchronized void deleteCancelFile() {
  1770. try {
  1771. new File(CANCEL_FILE_NAME).delete();
  1772. } catch (SecurityException e) {
  1773. EPLog.m307e("EPImageCreator", e.toString());
  1774. }
  1775. return;
  1776. }
  1777. }