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