ECopyPreview.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. /* access modifiers changed from: protected */
  199. public void drawScanPreview(Bitmap bitmap) {
  200. this.layout.setScanImage(bitmap);
  201. requestInvalidateView();
  202. }
  203. /* access modifiers changed from: protected */
  204. public void calculateScanImageSize(int i, int i2, ScanImageSizeCalculator scanImageSizeCalculator) {
  205. float scanImageScale = this.layout.getScanImageScale(i, i2);
  206. scanImageSizeCalculator.onScanImageSize((int) (((float) i) * scanImageScale), (int) (((float) i2) * scanImageScale), scanImageScale);
  207. }
  208. /* access modifiers changed from: protected */
  209. public void setPaperFrame(RectF rectF) {
  210. this.paperFrame = rectF;
  211. this.layout.setPaperFrame(rectF);
  212. requestInvalidateView();
  213. }
  214. /* access modifiers changed from: protected */
  215. public void onDraw(Canvas canvas) {
  216. canvas.save();
  217. this.backgroundDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
  218. this.backgroundDrawable.draw(canvas);
  219. Point offset = this.layout.getOffset();
  220. offset.offset(this.paperPadding.left, this.paperPadding.top);
  221. RectF paperRect = this.layout.getPaperRect();
  222. paperRect.offset((float) offset.x, (float) offset.y);
  223. if (this.optionContext.copyType == ECopyComponent.ECopyType.Mirror) {
  224. canvas.scale(-1.0f, 1.0f);
  225. canvas.translate(-(paperRect.centerX() * 2.0f), 0.0f);
  226. }
  227. canvas.drawRect(paperRect, this.paperShadowPaint);
  228. Paint paint = null;
  229. if (this.colorOption.getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale) {
  230. paint = this.grayscalePaint;
  231. }
  232. canvas.drawBitmap(this.layout.getBitmap(), (float) offset.x, (float) offset.y, paint);
  233. RectF copyFrame = this.layout.getCopyFrame();
  234. if (!this.paperFrame.isEmpty() && copyFrame != null) {
  235. copyFrame.offset((float) offset.x, (float) offset.y);
  236. Path path = new Path();
  237. path.addRect(copyFrame, Path.Direction.CW);
  238. canvas.drawPath(path, this.copyFramePaint);
  239. }
  240. canvas.restore();
  241. }
  242. class Size {
  243. int height;
  244. int width;
  245. Size(int i, int i2) {
  246. this.width = i;
  247. this.height = i2;
  248. }
  249. Size(Size size) {
  250. this.width = size.width;
  251. this.height = size.height;
  252. }
  253. private void scale(float f) {
  254. this.width = (int) (((float) this.width) * f);
  255. this.height = (int) (((float) this.height) * f);
  256. }
  257. }
  258. static abstract class Layout {
  259. enum AspectFit {
  260. Max,
  261. Min
  262. }
  263. private abstract Bitmap getBitmap();
  264. private abstract RectF getCopyFrame();
  265. private abstract Point getOffset();
  266. private abstract RectF getPaperRect();
  267. private abstract float getScanImageScale(int i, int i2);
  268. private abstract void setCopyScale(float f);
  269. private abstract void setPaperFrame(RectF rectF);
  270. private abstract void setScanImage(Bitmap bitmap);
  271. Layout() {
  272. }
  273. private void scaleRect(float f, RectF rectF) {
  274. Matrix matrix = new Matrix();
  275. matrix.postScale(f, f);
  276. matrix.mapRect(rectF);
  277. }
  278. private float getAspectFitScale(float f, float f2, float f3, float f4, AspectFit aspectFit) {
  279. PointF pointF = new PointF();
  280. pointF.x = f / f3;
  281. pointF.y = f2 / f4;
  282. return aspectFit == AspectFit.Min ? Math.min(pointF.x, pointF.y) : Math.max(pointF.x, pointF.y);
  283. }
  284. }
  285. class LayoutStandard extends Layout {
  286. boolean autofitEnabled = false;
  287. Canvas canvas;
  288. RectF copyFrame;
  289. float copyScale = 1.0f;
  290. float imageScale = 1.0f;
  291. int layoutHeight;
  292. int layoutWidth;
  293. float limitCopyScaleDown = 0.0f;
  294. Bitmap maxPaperImage;
  295. Point offset = new Point();
  296. RectF paper;
  297. Path paperBorderClipPath = new Path();
  298. Bitmap paperImage;
  299. Size paperSize;
  300. RectF scanFrame;
  301. Bitmap scanImage;
  302. LayoutStandard(int i, int i2) {
  303. this.layoutWidth = i;
  304. this.layoutHeight = i2;
  305. if (ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.XScale).getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.XScale_Autofit) {
  306. this.autofitEnabled = true;
  307. }
  308. ECopyOptionItem copyOptionItemOf = ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.PrintMediaSize);
  309. switch (copyOptionItemOf.getSelectedChoice()) {
  310. case PrintMediaSize_A4:
  311. this.paperSize = ECopyPreview.this.f360A4;
  312. break;
  313. case PrintMediaSize_B5:
  314. this.paperSize = ECopyPreview.this.f361B5;
  315. break;
  316. case PrintMediaSize_L:
  317. this.paperSize = ECopyPreview.this.f363L;
  318. break;
  319. case PrintMediaSize_2L:
  320. this.paperSize = ECopyPreview.this.f364L2;
  321. break;
  322. case PrintMediaSize_Postcard:
  323. this.paperSize = ECopyPreview.this.Hagaki;
  324. break;
  325. case PrintMediaSize_KG:
  326. this.paperSize = ECopyPreview.this.f362KG;
  327. break;
  328. case PrintMediaSize_8x10in:
  329. this.paperSize = ECopyPreview.this.f365P6;
  330. break;
  331. default:
  332. this.paperSize = ECopyPreview.this.Max;
  333. break;
  334. }
  335. float f = (float) i;
  336. float f2 = (float) i2;
  337. float aspectFitScale = getAspectFitScale(f, f2, (float) this.paperSize.width, (float) this.paperSize.height, Layout.AspectFit.Min);
  338. RectF rectF = new RectF(0.0f, 0.0f, (float) this.paperSize.width, (float) this.paperSize.height);
  339. scaleRect(aspectFitScale, rectF);
  340. this.paperImage = Bitmap.createBitmap((int) rectF.width(), (int) rectF.height(), Bitmap.Config.ARGB_8888);
  341. RectF rectF2 = new RectF(0.0f, 0.0f, (float) this.paperSize.width, (float) this.paperSize.height);
  342. rectF2.left += 18.0f;
  343. rectF2.top += 18.0f;
  344. rectF2.right -= 18.0f;
  345. rectF2.bottom -= 18.0f;
  346. scaleRect(aspectFitScale, rectF2);
  347. this.paperBorderClipPath.addRect(rectF2, Path.Direction.CW);
  348. float aspectFitScale2 = getAspectFitScale(f, f2, (float) ECopyPreview.this.Max.width, (float) ECopyPreview.this.Max.height, Layout.AspectFit.Min);
  349. RectF rectF3 = new RectF(0.0f, 0.0f, (float) ECopyPreview.this.Max.width, (float) ECopyPreview.this.Max.height);
  350. scaleRect(aspectFitScale2, rectF3);
  351. this.maxPaperImage = Bitmap.createBitmap((int) rectF3.width(), (int) rectF3.height(), Bitmap.Config.ARGB_8888);
  352. invalidatePaperSize();
  353. }
  354. private Bitmap getBitmap() {
  355. boolean showPaper = showPaper();
  356. Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
  357. this.canvas = new Canvas(bitmap);
  358. this.canvas.save();
  359. ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
  360. ECopyPreview.this.paperDrawable.draw(this.canvas);
  361. Bitmap bitmap2 = this.scanImage;
  362. if (bitmap2 != null) {
  363. if (showPaper) {
  364. float f = this.copyScale / this.limitCopyScaleDown;
  365. if (this.autofitEnabled) {
  366. f = 1.0f / getAspectFitScale(this.scanFrame.width(), this.scanFrame.height(), (float) this.canvas.getWidth(), (float) this.canvas.getHeight(), Layout.AspectFit.Max);
  367. }
  368. Matrix matrix = new Matrix();
  369. matrix.postScale(f, f);
  370. this.canvas.clipPath(this.paperBorderClipPath);
  371. this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
  372. } else {
  373. this.canvas.drawBitmap(bitmap2, 0.0f, 0.0f, (Paint) null);
  374. }
  375. }
  376. this.canvas.restore();
  377. return bitmap;
  378. }
  379. private float getScanImageScale(int i, int i2) {
  380. 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);
  381. return this.imageScale;
  382. }
  383. private void setScanImage(Bitmap bitmap) {
  384. this.scanImage = bitmap;
  385. }
  386. private Point getOffset() {
  387. return new Point(this.offset);
  388. }
  389. private void setPaperFrame(RectF rectF) {
  390. this.scanFrame = new RectF(rectF);
  391. scaleRect(this.imageScale, this.scanFrame);
  392. this.copyFrame = new RectF(rectF);
  393. this.copyFrame.left += 18.0f;
  394. this.copyFrame.top += 18.0f;
  395. this.copyFrame.right -= 36.0f;
  396. this.copyFrame.bottom -= 36.0f;
  397. scaleRect(this.imageScale, this.copyFrame);
  398. calcLimitCopyScaleDown();
  399. invalidatePaperSize();
  400. }
  401. private RectF getCopyFrame() {
  402. RectF rectF;
  403. if (showPaper() || this.scanImage == null || (rectF = this.copyFrame) == null) {
  404. return null;
  405. }
  406. RectF rectF2 = new RectF(rectF);
  407. float max = 1.0f / Math.max(this.copyScale, this.limitCopyScaleDown);
  408. rectF2.right *= max;
  409. rectF2.bottom *= max;
  410. return rectF2;
  411. }
  412. private void setCopyScale(float f) {
  413. this.copyScale = f;
  414. invalidatePaperSize();
  415. }
  416. private boolean showPaper() {
  417. boolean z = this.copyScale < this.limitCopyScaleDown;
  418. if (this.autofitEnabled) {
  419. return true;
  420. }
  421. return z;
  422. }
  423. private void invalidatePaperSize() {
  424. Size size = showPaper() ? this.paperSize : ECopyPreview.this.Max;
  425. float aspectFitScale = getAspectFitScale((float) this.layoutWidth, (float) this.layoutHeight, (float) size.width, (float) size.height, Layout.AspectFit.Min);
  426. this.paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
  427. scaleRect(aspectFitScale, this.paper);
  428. this.offset.x = ((int) (((float) this.layoutWidth) - this.paper.right)) / 2;
  429. this.offset.y = ((int) (((float) this.layoutHeight) - this.paper.bottom)) / 2;
  430. }
  431. private void calcLimitCopyScaleDown() {
  432. this.limitCopyScaleDown = getAspectFitScale(this.copyFrame.right, this.copyFrame.bottom, this.paper.width(), this.paper.height(), Layout.AspectFit.Max);
  433. }
  434. private RectF getPaperRect() {
  435. return new RectF(0.0f, 0.0f, this.paper.width(), this.paper.height());
  436. }
  437. }
  438. class LayoutMirror extends LayoutStandard {
  439. LayoutMirror(int i, int i2) {
  440. super(i, i2);
  441. }
  442. private Bitmap getBitmap() {
  443. boolean showPaper = showPaper();
  444. Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
  445. this.canvas = new Canvas(bitmap);
  446. this.canvas.save();
  447. ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
  448. ECopyPreview.this.paperDrawable.draw(this.canvas);
  449. if (this.scanImage != null) {
  450. if (showPaper) {
  451. float f = this.copyScale / this.limitCopyScaleDown;
  452. if (this.autofitEnabled) {
  453. f = 1.0f / getAspectFitScale(this.scanFrame.width(), this.scanFrame.height(), (float) this.canvas.getWidth(), (float) this.canvas.getHeight(), Layout.AspectFit.Max);
  454. }
  455. Matrix matrix = new Matrix();
  456. matrix.postScale(f, f);
  457. matrix.postTranslate(((float) bitmap.getWidth()) - (((float) this.scanImage.getWidth()) * f), 0.0f);
  458. this.canvas.clipPath(this.paperBorderClipPath);
  459. this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
  460. } else {
  461. this.canvas.drawBitmap(this.scanImage, 0.0f, 0.0f, (Paint) null);
  462. }
  463. }
  464. this.canvas.restore();
  465. return bitmap;
  466. }
  467. }
  468. class LayoutBorderless extends LayoutStandard {
  469. /* renamed from: BO */
  470. int f367BO;
  471. /* renamed from: LO */
  472. int f368LO;
  473. /* renamed from: RO */
  474. int f369RO;
  475. /* renamed from: TO */
  476. int f370TO;
  477. LayoutBorderless(int i, int i2) {
  478. super(i, i2);
  479. ECopyOptionItem.ECopyOptionItemChoice selectedChoice = ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.PrintMediaSize).getSelectedChoice();
  480. if (selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_KG || selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_L || selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_Postcard) {
  481. this.f368LO = 15;
  482. this.f369RO = 15;
  483. this.f370TO = 8;
  484. this.f367BO = 15;
  485. return;
  486. }
  487. this.f368LO = 15;
  488. this.f369RO = 15;
  489. this.f370TO = 17;
  490. this.f367BO = 15;
  491. }
  492. private Bitmap getBitmap() {
  493. boolean showPaper = showPaper();
  494. Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
  495. this.canvas = new Canvas(bitmap);
  496. this.canvas.save();
  497. ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
  498. ECopyPreview.this.paperDrawable.draw(this.canvas);
  499. if (this.scanImage != null) {
  500. if (showPaper) {
  501. float f = this.copyScale;
  502. if (this.autofitEnabled) {
  503. 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);
  504. }
  505. Matrix matrix = new Matrix();
  506. matrix.postTranslate((float) (-this.f368LO), (float) (-this.f370TO));
  507. matrix.postScale(f, f);
  508. this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
  509. } else {
  510. this.canvas.drawBitmap(this.scanImage, (float) (-this.f368LO), (float) (-this.f370TO), (Paint) null);
  511. }
  512. }
  513. this.canvas.restore();
  514. return bitmap;
  515. }
  516. private void setPaperFrame(RectF rectF) {
  517. this.scanFrame = new RectF(rectF);
  518. scaleRect(this.imageScale, this.scanFrame);
  519. this.copyFrame = new RectF(rectF);
  520. scaleRect(this.imageScale, this.copyFrame);
  521. calcLimitCopyScaleDown();
  522. invalidatePaperSize();
  523. this.f368LO = (int) (((float) this.f368LO) * this.imageScale);
  524. this.f369RO = (int) (((float) this.f369RO) * this.imageScale);
  525. this.f370TO = (int) (((float) this.f370TO) * this.imageScale);
  526. this.f367BO = (int) (((float) this.f367BO) * this.imageScale);
  527. }
  528. }
  529. class Layout2Up extends Layout {
  530. RectF copyFrame;
  531. float imageScale;
  532. Point offset = new Point();
  533. RectF page1;
  534. Bitmap page1Bitmap;
  535. RectF page2;
  536. RectF paper;
  537. private RectF getCopyFrame() {
  538. return null;
  539. }
  540. private void setCopyScale(float f) {
  541. }
  542. Layout2Up(int i, int i2) {
  543. Size size = ECopyPreview.this.A4_2Up;
  544. Size size2 = ECopyPreview.this.A4_2UpPage;
  545. this.paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
  546. this.page1 = new RectF(30.0f, 32.0f, (float) (size2.width + 30), (float) (size2.height + 32));
  547. this.page2 = new RectF(this.page1.right + 35.0f, this.page1.top, this.page1.right + 35.0f + ((float) size2.width), this.page1.bottom);
  548. float f = (float) i;
  549. float f2 = (float) i2;
  550. float aspectFitScale = getAspectFitScale(f, f2, (float) size.width, (float) size.height, Layout.AspectFit.Min);
  551. scaleRect(aspectFitScale, this.paper);
  552. scaleRect(aspectFitScale, this.page1);
  553. scaleRect(aspectFitScale, this.page2);
  554. this.offset.x = ((int) (f - this.paper.right)) / 2;
  555. this.offset.y = ((int) (f2 - this.paper.bottom)) / 2;
  556. }
  557. public Bitmap getBitmap() {
  558. Bitmap createBitmap = Bitmap.createBitmap((int) this.paper.width(), (int) this.paper.height(), Bitmap.Config.ARGB_8888);
  559. Canvas canvas = new Canvas(createBitmap);
  560. ECopyPreview.this.paperDrawable.setBounds(0, 0, createBitmap.getWidth(), createBitmap.getHeight());
  561. ECopyPreview.this.paperDrawable.draw(canvas);
  562. Bitmap createBitmap2 = Bitmap.createBitmap((int) this.page1.width(), (int) this.page1.height(), Bitmap.Config.ARGB_8888);
  563. new Canvas(createBitmap2).drawColor(-3355444);
  564. Bitmap bitmap = this.page1Bitmap;
  565. if (bitmap == null) {
  566. bitmap = createBitmap2;
  567. }
  568. canvas.drawBitmap(bitmap, (Rect) null, this.page1, (Paint) null);
  569. canvas.drawBitmap(createBitmap2, (Rect) null, this.page2, (Paint) null);
  570. return createBitmap;
  571. }
  572. private float getScanImageScale(int i, int i2) {
  573. this.imageScale = getAspectFitScale(this.page1.width(), this.page1.height(), (float) i, (float) i2, Layout.AspectFit.Min);
  574. return this.imageScale;
  575. }
  576. private void setScanImage(Bitmap bitmap) {
  577. Rect rect = new Rect((int) this.copyFrame.left, (int) this.copyFrame.top, (int) this.copyFrame.right, (int) this.copyFrame.bottom);
  578. this.page1Bitmap = Bitmap.createBitmap((int) this.page1.width(), (int) this.page1.height(), Bitmap.Config.ARGB_8888);
  579. Canvas canvas = new Canvas(this.page1Bitmap);
  580. canvas.drawBitmap(bitmap, rect, new RectF(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight()), (Paint) null);
  581. }
  582. private Point getOffset() {
  583. return new Point(this.offset);
  584. }
  585. private void setPaperFrame(RectF rectF) {
  586. this.copyFrame = new RectF(rectF);
  587. scaleRect(this.imageScale, this.copyFrame);
  588. }
  589. private RectF getPaperRect() {
  590. return new RectF(0.0f, 0.0f, this.paper.width(), this.paper.height());
  591. }
  592. }
  593. }