ECopyPreview.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. package epson.print.copy.Component.ecopycomponent;
  2. import android.app.Activity;
  3. import android.content.Context;
  4. import android.graphics.Bitmap;
  5. import android.graphics.Canvas;
  6. import android.graphics.ColorMatrix;
  7. import android.graphics.ColorMatrixColorFilter;
  8. import android.graphics.Matrix;
  9. import android.graphics.Paint;
  10. import android.graphics.Path;
  11. import android.graphics.Point;
  12. import android.graphics.PointF;
  13. import android.graphics.Rect;
  14. import android.graphics.RectF;
  15. import android.graphics.drawable.ColorDrawable;
  16. import android.graphics.drawable.Drawable;
  17. import android.support.p000v4.internal.view.SupportMenu;
  18. import android.view.View;
  19. import android.widget.LinearLayout;
  20. import epson.common.Constants;
  21. import epson.print.copy.Component.ecopycomponent.ECopyComponent;
  22. import epson.print.copy.Component.ecopycomponent.ECopyOptionItem;
  23. public class ECopyPreview extends View {
  24. /* renamed from: A4 */
  25. final Size f360A4 = new Size(1240, Constants.SCAN_MAX_HEIGHT);
  26. final Size A4_2Up = new Size(Constants.SCAN_MAX_HEIGHT, 1240);
  27. final Size A4_2UpPage = new Size(827, 1176);
  28. /* renamed from: B5 */
  29. final Size f361B5 = new Size(1075, 1518);
  30. final int BM_2Up = 35;
  31. final int BM_Border = 18;
  32. final int BO_Type1 = 24;
  33. final int BO_Type2 = 15;
  34. final Size Hagaki = new Size(591, 874);
  35. /* renamed from: KG */
  36. final Size f362KG = new Size(602, 898);
  37. /* renamed from: L */
  38. final Size f363L = new Size(526, 750);
  39. /* renamed from: L2 */
  40. final Size f364L2 = new Size(750, 1051);
  41. final int LM_2Up = 32;
  42. final int LM_Border = 18;
  43. final int LO_Type1 = 15;
  44. final int LO_Type2 = 15;
  45. final Size Max = new Size(Constants.SCAN_MAX_WIDTH, Constants.SCAN_MAX_HEIGHT);
  46. /* renamed from: P6 */
  47. final Size f365P6 = new Size(1199, 1500);
  48. final int PG_2Up = 35;
  49. final int PL_A4 = Constants.SCAN_MAX_HEIGHT;
  50. final int PL_B5 = 1518;
  51. final int PL_Hagaki = 874;
  52. final int PL_KG = 898;
  53. final int PL_L = 750;
  54. final int PL_L2 = 1051;
  55. final int PL_MAX = Constants.SCAN_MAX_HEIGHT;
  56. final int PL_P6 = 1500;
  57. final int PW_A4 = 1240;
  58. final int PW_B5 = 1075;
  59. final int PW_Hagaki = 591;
  60. final int PW_KG = 602;
  61. final int PW_L = 526;
  62. final int PW_L2 = 750;
  63. final int PW_MAX = Constants.SCAN_MAX_WIDTH;
  64. final int PW_P6 = 1199;
  65. final int RM_2Up = 32;
  66. final int RM_Border = 18;
  67. final int RO_Type1 = 15;
  68. final int RO_Type2 = 15;
  69. final int TM_2Up = 30;
  70. final int TM_Border = 18;
  71. final int TO_Type1 = 17;
  72. final int TO_Type2 = 8;
  73. Drawable backgroundDrawable = new ColorDrawable(0);
  74. ECopyOptionItem colorOption;
  75. ECopyOptionItem copiesOpiton;
  76. Paint copyFramePaint = new Paint();
  77. Size drawSize;
  78. Paint grayscalePaint;
  79. Layout layout;
  80. ECopyPreviewInvalidateListener listener;
  81. ICopyPreviewCommitEditedOptionContext optionCommitter;
  82. ECopyOptionContext optionContext;
  83. Drawable paperDrawable = new ColorDrawable(-1);
  84. RectF paperFrame;
  85. Rect paperPadding;
  86. Paint paperShadowPaint;
  87. ECopyOptionItem scaleOption;
  88. public enum ECopyPreviewColor {
  89. Color,
  90. Monochrome
  91. }
  92. public interface ECopyPreviewInvalidateListener {
  93. void needInvalidateView();
  94. }
  95. interface ICopyPreviewCommitEditedOptionContext {
  96. void commit(ECopyOptionContext eCopyOptionContext);
  97. }
  98. protected interface ScanImageSizeCalculator {
  99. void onScanImageSize(int i, int i2, float f);
  100. }
  101. private ECopyPreview(Context context) {
  102. super(context);
  103. this.copyFramePaint.setColor(SupportMenu.CATEGORY_MASK);
  104. this.copyFramePaint.setStyle(Paint.Style.STROKE);
  105. this.copyFramePaint.setStrokeWidth(2.0f);
  106. this.paperPadding = new Rect();
  107. this.grayscalePaint = new Paint();
  108. this.paperShadowPaint = new Paint();
  109. this.paperFrame = new RectF();
  110. ColorMatrix colorMatrix = new ColorMatrix();
  111. colorMatrix.setSaturation(0.0f);
  112. this.grayscalePaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
  113. }
  114. public void setBackground(Drawable drawable) {
  115. this.backgroundDrawable = drawable;
  116. }
  117. public void setPaperDrawable(Drawable drawable) {
  118. this.paperDrawable = drawable;
  119. }
  120. public void setCopyFramePaint(Paint paint) {
  121. this.copyFramePaint = paint;
  122. }
  123. public void setPaperShadowPaint(Paint paint) {
  124. this.paperShadowPaint = paint;
  125. }
  126. public void setPaperPadding(Rect rect) {
  127. this.paperPadding = new Rect(rect);
  128. resize();
  129. }
  130. private void requestInvalidateView() {
  131. ((Activity) getContext()).runOnUiThread(new Runnable() {
  132. public void run() {
  133. ECopyPreview.this.listener.needInvalidateView();
  134. }
  135. });
  136. }
  137. public void setColor(ECopyPreviewColor eCopyPreviewColor) {
  138. ECopyOptionItem.ECopyOptionItemChoice eCopyOptionItemChoice = ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_Color;
  139. if (eCopyPreviewColor == ECopyPreviewColor.Monochrome) {
  140. eCopyOptionItemChoice = ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale;
  141. }
  142. this.colorOption.selectChoice(eCopyOptionItemChoice);
  143. requestInvalidateView();
  144. }
  145. public ECopyPreviewColor getColor() {
  146. return this.colorOption.getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale ? ECopyPreviewColor.Monochrome : ECopyPreviewColor.Color;
  147. }
  148. public void setScale(int i) {
  149. this.scaleOption.selectValue(i);
  150. this.layout.setCopyScale(((float) this.scaleOption.getSelectedValue()) / 100.0f);
  151. requestInvalidateView();
  152. }
  153. public int getScale() {
  154. return this.scaleOption.getSelectedValue();
  155. }
  156. public void setCopies(int i) {
  157. this.copiesOpiton.selectValue(i);
  158. }
  159. public int getCopies() {
  160. return this.copiesOpiton.getSelectedValue();
  161. }
  162. public void dismiss(boolean z) {
  163. if (z) {
  164. this.optionCommitter.commit(this.optionContext);
  165. }
  166. }
  167. private void compose(ECopyOptionContext eCopyOptionContext, ICopyPreviewCommitEditedOptionContext iCopyPreviewCommitEditedOptionContext) {
  168. this.optionContext = eCopyOptionContext;
  169. this.optionCommitter = iCopyPreviewCommitEditedOptionContext;
  170. this.copiesOpiton = this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.Copies);
  171. this.scaleOption = this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.CopyMagnification);
  172. this.colorOption = this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.ColorEffectsType);
  173. resize();
  174. }
  175. private void resize() {
  176. int i = (this.drawSize.width - this.paperPadding.left) - this.paperPadding.right;
  177. int i2 = (this.drawSize.height - this.paperPadding.top) - this.paperPadding.bottom;
  178. ECopyComponent.ECopyType copyType = this.optionContext.getCopyType();
  179. if (copyType == ECopyComponent.ECopyType.A4_2up || copyType == ECopyComponent.ECopyType.B5_2up || copyType == ECopyComponent.ECopyType.A4_2up_Book || copyType == ECopyComponent.ECopyType.B5_2up_Book) {
  180. this.layout = new Layout2Up(i, i2);
  181. } else if (copyType == ECopyComponent.ECopyType.Mirror) {
  182. this.layout = new LayoutMirror(i, i2);
  183. } else if (copyType == ECopyComponent.ECopyType.Borderless) {
  184. this.layout = new LayoutBorderless(i, i2);
  185. } else {
  186. this.layout = new LayoutStandard(i, i2);
  187. }
  188. this.layout.setCopyScale(((float) this.scaleOption.getSelectedValue()) / 100.0f);
  189. }
  190. protected static ECopyPreview createPreview(Context context, int i, int i2, ECopyPreviewInvalidateListener eCopyPreviewInvalidateListener) {
  191. ECopyPreview eCopyPreview = new ECopyPreview(context);
  192. eCopyPreview.setLayoutParams(new LinearLayout.LayoutParams(i, i2));
  193. eCopyPreview.getClass();
  194. eCopyPreview.drawSize = new Size(i, i2);
  195. eCopyPreview.listener = eCopyPreviewInvalidateListener;
  196. return eCopyPreview;
  197. }
  198. protected void drawScanPreview(Bitmap bitmap) {
  199. this.layout.setScanImage(bitmap);
  200. requestInvalidateView();
  201. }
  202. protected void calculateScanImageSize(int i, int i2, ScanImageSizeCalculator scanImageSizeCalculator) {
  203. float scanImageScale = this.layout.getScanImageScale(i, i2);
  204. scanImageSizeCalculator.onScanImageSize((int) (((float) i) * scanImageScale), (int) (((float) i2) * scanImageScale), scanImageScale);
  205. }
  206. protected void setPaperFrame(RectF rectF) {
  207. this.paperFrame = rectF;
  208. this.layout.setPaperFrame(rectF);
  209. requestInvalidateView();
  210. }
  211. protected void onDraw(Canvas canvas) {
  212. canvas.save();
  213. this.backgroundDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
  214. this.backgroundDrawable.draw(canvas);
  215. Point offset = this.layout.getOffset();
  216. offset.offset(this.paperPadding.left, this.paperPadding.top);
  217. RectF paperRect = this.layout.getPaperRect();
  218. paperRect.offset((float) offset.x, (float) offset.y);
  219. if (this.optionContext.copyType == ECopyComponent.ECopyType.Mirror) {
  220. canvas.scale(-1.0f, 1.0f);
  221. canvas.translate(-(paperRect.centerX() * 2.0f), 0.0f);
  222. }
  223. canvas.drawRect(paperRect, this.paperShadowPaint);
  224. Paint paint = null;
  225. if (this.colorOption.getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale) {
  226. paint = this.grayscalePaint;
  227. }
  228. canvas.drawBitmap(this.layout.getBitmap(), (float) offset.x, (float) offset.y, paint);
  229. RectF copyFrame = this.layout.getCopyFrame();
  230. if (!this.paperFrame.isEmpty() && copyFrame != null) {
  231. copyFrame.offset((float) offset.x, (float) offset.y);
  232. Path path = new Path();
  233. path.addRect(copyFrame, Path.Direction.CW);
  234. canvas.drawPath(path, this.copyFramePaint);
  235. }
  236. canvas.restore();
  237. }
  238. class Size {
  239. int height;
  240. int width;
  241. Size(int i, int i2) {
  242. this.width = i;
  243. this.height = i2;
  244. }
  245. Size(Size size) {
  246. this.width = size.width;
  247. this.height = size.height;
  248. }
  249. private void scale(float f) {
  250. this.width = (int) (((float) this.width) * f);
  251. this.height = (int) (((float) this.height) * f);
  252. }
  253. }
  254. static abstract class Layout {
  255. enum AspectFit {
  256. Max,
  257. Min
  258. }
  259. private abstract Bitmap getBitmap();
  260. private abstract RectF getCopyFrame();
  261. private abstract Point getOffset();
  262. private abstract RectF getPaperRect();
  263. private abstract float getScanImageScale(int i, int i2);
  264. private abstract void setCopyScale(float f);
  265. private abstract void setPaperFrame(RectF rectF);
  266. private abstract void setScanImage(Bitmap bitmap);
  267. Layout() {
  268. }
  269. private void scaleRect(float f, RectF rectF) {
  270. Matrix matrix = new Matrix();
  271. matrix.postScale(f, f);
  272. matrix.mapRect(rectF);
  273. }
  274. private float getAspectFitScale(float f, float f2, float f3, float f4, AspectFit aspectFit) {
  275. PointF pointF = new PointF();
  276. pointF.x = f / f3;
  277. pointF.y = f2 / f4;
  278. return aspectFit == AspectFit.Min ? Math.min(pointF.x, pointF.y) : Math.max(pointF.x, pointF.y);
  279. }
  280. }
  281. class LayoutStandard extends Layout {
  282. boolean autofitEnabled = false;
  283. Canvas canvas;
  284. RectF copyFrame;
  285. float copyScale = 1.0f;
  286. float imageScale = 1.0f;
  287. int layoutHeight;
  288. int layoutWidth;
  289. float limitCopyScaleDown = 0.0f;
  290. Bitmap maxPaperImage;
  291. Point offset = new Point();
  292. RectF paper;
  293. Path paperBorderClipPath = new Path();
  294. Bitmap paperImage;
  295. Size paperSize;
  296. RectF scanFrame;
  297. Bitmap scanImage;
  298. LayoutStandard(int i, int i2) {
  299. this.layoutWidth = i;
  300. this.layoutHeight = i2;
  301. if (ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.XScale).getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.XScale_Autofit) {
  302. this.autofitEnabled = true;
  303. }
  304. ECopyOptionItem copyOptionItemOf = ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.PrintMediaSize);
  305. switch (copyOptionItemOf.getSelectedChoice()) {
  306. case PrintMediaSize_A4:
  307. this.paperSize = ECopyPreview.this.f360A4;
  308. break;
  309. case PrintMediaSize_B5:
  310. this.paperSize = ECopyPreview.this.f361B5;
  311. break;
  312. case PrintMediaSize_L:
  313. this.paperSize = ECopyPreview.this.f363L;
  314. break;
  315. case PrintMediaSize_2L:
  316. this.paperSize = ECopyPreview.this.f364L2;
  317. break;
  318. case PrintMediaSize_Postcard:
  319. this.paperSize = ECopyPreview.this.Hagaki;
  320. break;
  321. case PrintMediaSize_KG:
  322. this.paperSize = ECopyPreview.this.f362KG;
  323. break;
  324. case PrintMediaSize_8x10in:
  325. this.paperSize = ECopyPreview.this.f365P6;
  326. break;
  327. default:
  328. this.paperSize = ECopyPreview.this.Max;
  329. break;
  330. }
  331. float f = (float) i;
  332. float f2 = (float) i2;
  333. float aspectFitScale = getAspectFitScale(f, f2, (float) this.paperSize.width, (float) this.paperSize.height, Layout.AspectFit.Min);
  334. RectF rectF = new RectF(0.0f, 0.0f, (float) this.paperSize.width, (float) this.paperSize.height);
  335. scaleRect(aspectFitScale, rectF);
  336. this.paperImage = Bitmap.createBitmap((int) rectF.width(), (int) rectF.height(), Bitmap.Config.ARGB_8888);
  337. RectF rectF2 = new RectF(0.0f, 0.0f, (float) this.paperSize.width, (float) this.paperSize.height);
  338. rectF2.left += 18.0f;
  339. rectF2.top += 18.0f;
  340. rectF2.right -= 18.0f;
  341. rectF2.bottom -= 18.0f;
  342. scaleRect(aspectFitScale, rectF2);
  343. this.paperBorderClipPath.addRect(rectF2, Path.Direction.CW);
  344. float aspectFitScale2 = getAspectFitScale(f, f2, (float) ECopyPreview.this.Max.width, (float) ECopyPreview.this.Max.height, Layout.AspectFit.Min);
  345. RectF rectF3 = new RectF(0.0f, 0.0f, (float) ECopyPreview.this.Max.width, (float) ECopyPreview.this.Max.height);
  346. scaleRect(aspectFitScale2, rectF3);
  347. this.maxPaperImage = Bitmap.createBitmap((int) rectF3.width(), (int) rectF3.height(), Bitmap.Config.ARGB_8888);
  348. invalidatePaperSize();
  349. }
  350. private Bitmap getBitmap() {
  351. boolean showPaper = showPaper();
  352. Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
  353. this.canvas = new Canvas(bitmap);
  354. this.canvas.save();
  355. ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
  356. ECopyPreview.this.paperDrawable.draw(this.canvas);
  357. Bitmap bitmap2 = this.scanImage;
  358. if (bitmap2 != null) {
  359. if (showPaper) {
  360. float f = this.copyScale / this.limitCopyScaleDown;
  361. if (this.autofitEnabled) {
  362. f = 1.0f / getAspectFitScale(this.scanFrame.width(), this.scanFrame.height(), (float) this.canvas.getWidth(), (float) this.canvas.getHeight(), Layout.AspectFit.Max);
  363. }
  364. Matrix matrix = new Matrix();
  365. matrix.postScale(f, f);
  366. this.canvas.clipPath(this.paperBorderClipPath);
  367. this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
  368. } else {
  369. this.canvas.drawBitmap(bitmap2, 0.0f, 0.0f, (Paint) null);
  370. }
  371. }
  372. this.canvas.restore();
  373. return bitmap;
  374. }
  375. private float getScanImageScale(int i, int i2) {
  376. this.imageScale = getAspectFitScale((float) ((ECopyPreview.this.drawSize.width - ECopyPreview.this.paperPadding.left) - ECopyPreview.this.paperPadding.right), (float) ((ECopyPreview.this.drawSize.height - ECopyPreview.this.paperPadding.top) - ECopyPreview.this.paperPadding.bottom), (float) i, (float) i2, Layout.AspectFit.Min);
  377. return this.imageScale;
  378. }
  379. private void setScanImage(Bitmap bitmap) {
  380. this.scanImage = bitmap;
  381. }
  382. private Point getOffset() {
  383. return new Point(this.offset);
  384. }
  385. private void setPaperFrame(RectF rectF) {
  386. this.scanFrame = new RectF(rectF);
  387. scaleRect(this.imageScale, this.scanFrame);
  388. this.copyFrame = new RectF(rectF);
  389. this.copyFrame.left += 18.0f;
  390. this.copyFrame.top += 18.0f;
  391. this.copyFrame.right -= 36.0f;
  392. this.copyFrame.bottom -= 36.0f;
  393. scaleRect(this.imageScale, this.copyFrame);
  394. calcLimitCopyScaleDown();
  395. invalidatePaperSize();
  396. }
  397. private RectF getCopyFrame() {
  398. RectF rectF;
  399. if (showPaper() || this.scanImage == null || (rectF = this.copyFrame) == null) {
  400. return null;
  401. }
  402. RectF rectF2 = new RectF(rectF);
  403. float max = 1.0f / Math.max(this.copyScale, this.limitCopyScaleDown);
  404. rectF2.right *= max;
  405. rectF2.bottom *= max;
  406. return rectF2;
  407. }
  408. private void setCopyScale(float f) {
  409. this.copyScale = f;
  410. invalidatePaperSize();
  411. }
  412. private boolean showPaper() {
  413. boolean z = this.copyScale < this.limitCopyScaleDown;
  414. if (this.autofitEnabled) {
  415. return true;
  416. }
  417. return z;
  418. }
  419. private void invalidatePaperSize() {
  420. Size size = showPaper() ? this.paperSize : ECopyPreview.this.Max;
  421. float aspectFitScale = getAspectFitScale((float) this.layoutWidth, (float) this.layoutHeight, (float) size.width, (float) size.height, Layout.AspectFit.Min);
  422. this.paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
  423. scaleRect(aspectFitScale, this.paper);
  424. this.offset.x = ((int) (((float) this.layoutWidth) - this.paper.right)) / 2;
  425. this.offset.y = ((int) (((float) this.layoutHeight) - this.paper.bottom)) / 2;
  426. }
  427. private void calcLimitCopyScaleDown() {
  428. this.limitCopyScaleDown = getAspectFitScale(this.copyFrame.right, this.copyFrame.bottom, this.paper.width(), this.paper.height(), Layout.AspectFit.Max);
  429. }
  430. private RectF getPaperRect() {
  431. return new RectF(0.0f, 0.0f, this.paper.width(), this.paper.height());
  432. }
  433. }
  434. class LayoutMirror extends LayoutStandard {
  435. LayoutMirror(int i, int i2) {
  436. super(i, i2);
  437. }
  438. private Bitmap getBitmap() {
  439. boolean showPaper = showPaper();
  440. Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
  441. this.canvas = new Canvas(bitmap);
  442. this.canvas.save();
  443. ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
  444. ECopyPreview.this.paperDrawable.draw(this.canvas);
  445. if (this.scanImage != null) {
  446. if (showPaper) {
  447. float f = this.copyScale / this.limitCopyScaleDown;
  448. if (this.autofitEnabled) {
  449. f = 1.0f / getAspectFitScale(this.scanFrame.width(), this.scanFrame.height(), (float) this.canvas.getWidth(), (float) this.canvas.getHeight(), Layout.AspectFit.Max);
  450. }
  451. Matrix matrix = new Matrix();
  452. matrix.postScale(f, f);
  453. matrix.postTranslate(((float) bitmap.getWidth()) - (((float) this.scanImage.getWidth()) * f), 0.0f);
  454. this.canvas.clipPath(this.paperBorderClipPath);
  455. this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
  456. } else {
  457. this.canvas.drawBitmap(this.scanImage, 0.0f, 0.0f, (Paint) null);
  458. }
  459. }
  460. this.canvas.restore();
  461. return bitmap;
  462. }
  463. }
  464. class LayoutBorderless extends LayoutStandard {
  465. /* renamed from: BO */
  466. int f367BO;
  467. /* renamed from: LO */
  468. int f368LO;
  469. /* renamed from: RO */
  470. int f369RO;
  471. /* renamed from: TO */
  472. int f370TO;
  473. LayoutBorderless(int i, int i2) {
  474. super(i, i2);
  475. ECopyOptionItem.ECopyOptionItemChoice selectedChoice = ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.PrintMediaSize).getSelectedChoice();
  476. if (selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_KG || selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_L || selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_Postcard) {
  477. this.f368LO = 15;
  478. this.f369RO = 15;
  479. this.f370TO = 8;
  480. this.f367BO = 15;
  481. return;
  482. }
  483. this.f368LO = 15;
  484. this.f369RO = 15;
  485. this.f370TO = 17;
  486. this.f367BO = 15;
  487. }
  488. private Bitmap getBitmap() {
  489. boolean showPaper = showPaper();
  490. Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
  491. this.canvas = new Canvas(bitmap);
  492. this.canvas.save();
  493. ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
  494. ECopyPreview.this.paperDrawable.draw(this.canvas);
  495. if (this.scanImage != null) {
  496. if (showPaper) {
  497. float f = this.copyScale;
  498. if (this.autofitEnabled) {
  499. f = 1.0f / getAspectFitScale(this.scanFrame.width(), this.scanFrame.height(), (float) ((this.paperImage.getWidth() + this.f368LO) + this.f369RO), (float) ((this.paperImage.getHeight() + this.f370TO) + this.f367BO), Layout.AspectFit.Min);
  500. }
  501. Matrix matrix = new Matrix();
  502. matrix.postTranslate((float) (-this.f368LO), (float) (-this.f370TO));
  503. matrix.postScale(f, f);
  504. this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
  505. } else {
  506. this.canvas.drawBitmap(this.scanImage, (float) (-this.f368LO), (float) (-this.f370TO), (Paint) null);
  507. }
  508. }
  509. this.canvas.restore();
  510. return bitmap;
  511. }
  512. private void setPaperFrame(RectF rectF) {
  513. this.scanFrame = new RectF(rectF);
  514. scaleRect(this.imageScale, this.scanFrame);
  515. this.copyFrame = new RectF(rectF);
  516. scaleRect(this.imageScale, this.copyFrame);
  517. calcLimitCopyScaleDown();
  518. invalidatePaperSize();
  519. this.f368LO = (int) (((float) this.f368LO) * this.imageScale);
  520. this.f369RO = (int) (((float) this.f369RO) * this.imageScale);
  521. this.f370TO = (int) (((float) this.f370TO) * this.imageScale);
  522. this.f367BO = (int) (((float) this.f367BO) * this.imageScale);
  523. }
  524. }
  525. class Layout2Up extends Layout {
  526. RectF copyFrame;
  527. float imageScale;
  528. Point offset = new Point();
  529. RectF page1;
  530. Bitmap page1Bitmap;
  531. RectF page2;
  532. RectF paper;
  533. private RectF getCopyFrame() {
  534. return null;
  535. }
  536. private void setCopyScale(float f) {
  537. }
  538. Layout2Up(int i, int i2) {
  539. Size size = ECopyPreview.this.A4_2Up;
  540. Size size2 = ECopyPreview.this.A4_2UpPage;
  541. this.paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
  542. this.page1 = new RectF(30.0f, 32.0f, (float) (size2.width + 30), (float) (size2.height + 32));
  543. this.page2 = new RectF(this.page1.right + 35.0f, this.page1.top, this.page1.right + 35.0f + ((float) size2.width), this.page1.bottom);
  544. float f = (float) i;
  545. float f2 = (float) i2;
  546. float aspectFitScale = getAspectFitScale(f, f2, (float) size.width, (float) size.height, Layout.AspectFit.Min);
  547. scaleRect(aspectFitScale, this.paper);
  548. scaleRect(aspectFitScale, this.page1);
  549. scaleRect(aspectFitScale, this.page2);
  550. this.offset.x = ((int) (f - this.paper.right)) / 2;
  551. this.offset.y = ((int) (f2 - this.paper.bottom)) / 2;
  552. }
  553. public Bitmap getBitmap() {
  554. Bitmap createBitmap = Bitmap.createBitmap((int) this.paper.width(), (int) this.paper.height(), Bitmap.Config.ARGB_8888);
  555. Canvas canvas = new Canvas(createBitmap);
  556. ECopyPreview.this.paperDrawable.setBounds(0, 0, createBitmap.getWidth(), createBitmap.getHeight());
  557. ECopyPreview.this.paperDrawable.draw(canvas);
  558. Bitmap createBitmap2 = Bitmap.createBitmap((int) this.page1.width(), (int) this.page1.height(), Bitmap.Config.ARGB_8888);
  559. new Canvas(createBitmap2).drawColor(-3355444);
  560. Bitmap bitmap = this.page1Bitmap;
  561. if (bitmap == null) {
  562. bitmap = createBitmap2;
  563. }
  564. canvas.drawBitmap(bitmap, (Rect) null, this.page1, (Paint) null);
  565. canvas.drawBitmap(createBitmap2, (Rect) null, this.page2, (Paint) null);
  566. return createBitmap;
  567. }
  568. private float getScanImageScale(int i, int i2) {
  569. this.imageScale = getAspectFitScale(this.page1.width(), this.page1.height(), (float) i, (float) i2, Layout.AspectFit.Min);
  570. return this.imageScale;
  571. }
  572. private void setScanImage(Bitmap bitmap) {
  573. Rect rect = new Rect((int) this.copyFrame.left, (int) this.copyFrame.top, (int) this.copyFrame.right, (int) this.copyFrame.bottom);
  574. this.page1Bitmap = Bitmap.createBitmap((int) this.page1.width(), (int) this.page1.height(), Bitmap.Config.ARGB_8888);
  575. Canvas canvas = new Canvas(this.page1Bitmap);
  576. canvas.drawBitmap(bitmap, rect, new RectF(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight()), (Paint) null);
  577. }
  578. private Point getOffset() {
  579. return new Point(this.offset);
  580. }
  581. private void setPaperFrame(RectF rectF) {
  582. this.copyFrame = new RectF(rectF);
  583. scaleRect(this.imageScale, this.copyFrame);
  584. }
  585. private RectF getPaperRect() {
  586. return new RectF(0.0f, 0.0f, this.paper.width(), this.paper.height());
  587. }
  588. }
  589. }