|
|
@@ -112,36 +112,36 @@ public class ECopyPreview extends View {
|
|
|
|
|
|
private ECopyPreview(Context context) {
|
|
|
super(context);
|
|
|
- this.copyFramePaint.setColor(SupportMenu.CATEGORY_MASK);
|
|
|
- this.copyFramePaint.setStyle(Paint.Style.STROKE);
|
|
|
- this.copyFramePaint.setStrokeWidth(2.0f);
|
|
|
- this.paperPadding = new Rect();
|
|
|
- this.grayscalePaint = new Paint();
|
|
|
- this.paperShadowPaint = new Paint();
|
|
|
- this.paperFrame = new RectF();
|
|
|
+ copyFramePaint.setColor(SupportMenu.CATEGORY_MASK);
|
|
|
+ copyFramePaint.setStyle(Paint.Style.STROKE);
|
|
|
+ copyFramePaint.setStrokeWidth(2.0f);
|
|
|
+ paperPadding = new Rect();
|
|
|
+ grayscalePaint = new Paint();
|
|
|
+ paperShadowPaint = new Paint();
|
|
|
+ paperFrame = new RectF();
|
|
|
ColorMatrix colorMatrix = new ColorMatrix();
|
|
|
colorMatrix.setSaturation(0.0f);
|
|
|
- this.grayscalePaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
|
|
|
+ grayscalePaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
|
|
|
}
|
|
|
|
|
|
public void setBackground(Drawable drawable) {
|
|
|
- this.backgroundDrawable = drawable;
|
|
|
+ backgroundDrawable = drawable;
|
|
|
}
|
|
|
|
|
|
public void setPaperDrawable(Drawable drawable) {
|
|
|
- this.paperDrawable = drawable;
|
|
|
+ paperDrawable = drawable;
|
|
|
}
|
|
|
|
|
|
public void setCopyFramePaint(Paint paint) {
|
|
|
- this.copyFramePaint = paint;
|
|
|
+ copyFramePaint = paint;
|
|
|
}
|
|
|
|
|
|
public void setPaperShadowPaint(Paint paint) {
|
|
|
- this.paperShadowPaint = paint;
|
|
|
+ paperShadowPaint = paint;
|
|
|
}
|
|
|
|
|
|
public void setPaperPadding(Rect rect) {
|
|
|
- this.paperPadding = new Rect(rect);
|
|
|
+ paperPadding = new Rect(rect);
|
|
|
resize();
|
|
|
}
|
|
|
|
|
|
@@ -158,61 +158,61 @@ public class ECopyPreview extends View {
|
|
|
if (eCopyPreviewColor == ECopyPreviewColor.Monochrome) {
|
|
|
eCopyOptionItemChoice = ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale;
|
|
|
}
|
|
|
- this.colorOption.selectChoice(eCopyOptionItemChoice);
|
|
|
+ colorOption.selectChoice(eCopyOptionItemChoice);
|
|
|
requestInvalidateView();
|
|
|
}
|
|
|
|
|
|
public ECopyPreviewColor getColor() {
|
|
|
- return this.colorOption.getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale ? ECopyPreviewColor.Monochrome : ECopyPreviewColor.Color;
|
|
|
+ return colorOption.getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale ? ECopyPreviewColor.Monochrome : ECopyPreviewColor.Color;
|
|
|
}
|
|
|
|
|
|
public void setScale(int i) {
|
|
|
- this.scaleOption.selectValue(i);
|
|
|
- this.layout.setCopyScale(((float) this.scaleOption.getSelectedValue()) / 100.0f);
|
|
|
+ scaleOption.selectValue(i);
|
|
|
+ layout.setCopyScale(((float) scaleOption.getSelectedValue()) / 100.0f);
|
|
|
requestInvalidateView();
|
|
|
}
|
|
|
|
|
|
public int getScale() {
|
|
|
- return this.scaleOption.getSelectedValue();
|
|
|
+ return scaleOption.getSelectedValue();
|
|
|
}
|
|
|
|
|
|
public void setCopies(int i) {
|
|
|
- this.copiesOpiton.selectValue(i);
|
|
|
+ copiesOpiton.selectValue(i);
|
|
|
}
|
|
|
|
|
|
public int getCopies() {
|
|
|
- return this.copiesOpiton.getSelectedValue();
|
|
|
+ return copiesOpiton.getSelectedValue();
|
|
|
}
|
|
|
|
|
|
public void dismiss(boolean z) {
|
|
|
if (z) {
|
|
|
- this.optionCommitter.commit(this.optionContext);
|
|
|
+ optionCommitter.commit(this.optionContext);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void compose(ECopyOptionContext eCopyOptionContext, ICopyPreviewCommitEditedOptionContext iCopyPreviewCommitEditedOptionContext) {
|
|
|
- this.optionContext = eCopyOptionContext;
|
|
|
- this.optionCommitter = iCopyPreviewCommitEditedOptionContext;
|
|
|
- this.copiesOpiton = this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.Copies);
|
|
|
- this.scaleOption = this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.CopyMagnification);
|
|
|
- this.colorOption = this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.ColorEffectsType);
|
|
|
+ optionContext = eCopyOptionContext;
|
|
|
+ optionCommitter = iCopyPreviewCommitEditedOptionContext;
|
|
|
+ copiesOpiton = optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.Copies);
|
|
|
+ scaleOption = optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.CopyMagnification);
|
|
|
+ colorOption = optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.ColorEffectsType);
|
|
|
resize();
|
|
|
}
|
|
|
|
|
|
private void resize() {
|
|
|
- int i = (this.drawSize.width - this.paperPadding.left) - this.paperPadding.right;
|
|
|
- int i2 = (this.drawSize.height - this.paperPadding.top) - this.paperPadding.bottom;
|
|
|
- ECopyComponent.ECopyType copyType = this.optionContext.getCopyType();
|
|
|
+ int i = (this.drawSize.width - paperPadding.left) - paperPadding.right;
|
|
|
+ int i2 = (this.drawSize.height - paperPadding.top) - paperPadding.bottom;
|
|
|
+ ECopyComponent.ECopyType copyType = optionContext.getCopyType();
|
|
|
if (copyType == ECopyComponent.ECopyType.A4_2up || copyType == ECopyComponent.ECopyType.B5_2up || copyType == ECopyComponent.ECopyType.A4_2up_Book || copyType == ECopyComponent.ECopyType.B5_2up_Book) {
|
|
|
- this.layout = new Layout2Up(i, i2);
|
|
|
+ layout = new Layout2Up(i, i2);
|
|
|
} else if (copyType == ECopyComponent.ECopyType.Mirror) {
|
|
|
- this.layout = new LayoutMirror(i, i2);
|
|
|
+ layout = new LayoutMirror(i, i2);
|
|
|
} else if (copyType == ECopyComponent.ECopyType.Borderless) {
|
|
|
- this.layout = new LayoutBorderless(i, i2);
|
|
|
+ layout = new LayoutBorderless(i, i2);
|
|
|
} else {
|
|
|
- this.layout = new LayoutStandard(i, i2);
|
|
|
+ layout = new LayoutStandard(i, i2);
|
|
|
}
|
|
|
- this.layout.setCopyScale(((float) this.scaleOption.getSelectedValue()) / 100.0f);
|
|
|
+ layout.setCopyScale(((float) scaleOption.getSelectedValue()) / 100.0f);
|
|
|
}
|
|
|
|
|
|
protected static ECopyPreview createPreview(Context context, int i, int i2, ECopyPreviewInvalidateListener eCopyPreviewInvalidateListener) {
|
|
|
@@ -225,45 +225,45 @@ public class ECopyPreview extends View {
|
|
|
}
|
|
|
|
|
|
protected void drawScanPreview(Bitmap bitmap) {
|
|
|
- this.layout.setScanImage(bitmap);
|
|
|
+ layout.setScanImage(bitmap);
|
|
|
requestInvalidateView();
|
|
|
}
|
|
|
|
|
|
protected void calculateScanImageSize(int i, int i2, ScanImageSizeCalculator scanImageSizeCalculator) {
|
|
|
- float scanImageScale = this.layout.getScanImageScale(i, i2);
|
|
|
+ float scanImageScale = layout.getScanImageScale(i, i2);
|
|
|
scanImageSizeCalculator.onScanImageSize((int) (((float) i) * scanImageScale), (int) (((float) i2) * scanImageScale), scanImageScale);
|
|
|
}
|
|
|
|
|
|
protected void setPaperFrame(RectF rectF) {
|
|
|
- this.paperFrame = rectF;
|
|
|
- this.layout.setPaperFrame(rectF);
|
|
|
+ paperFrame = rectF;
|
|
|
+ layout.setPaperFrame(rectF);
|
|
|
requestInvalidateView();
|
|
|
}
|
|
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
canvas.save();
|
|
|
- this.backgroundDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
|
|
- this.backgroundDrawable.draw(canvas);
|
|
|
- Point offset = this.layout.getOffset();
|
|
|
- offset.offset(this.paperPadding.left, this.paperPadding.top);
|
|
|
- RectF paperRect = this.layout.getPaperRect();
|
|
|
+ backgroundDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
|
|
+ backgroundDrawable.draw(canvas);
|
|
|
+ Point offset = layout.getOffset();
|
|
|
+ offset.offset(this.paperPadding.left, paperPadding.top);
|
|
|
+ RectF paperRect = layout.getPaperRect();
|
|
|
paperRect.offset((float) offset.x, (float) offset.y);
|
|
|
if (this.optionContext.copyType == ECopyComponent.ECopyType.Mirror) {
|
|
|
canvas.scale(-1.0f, 1.0f);
|
|
|
canvas.translate(-(paperRect.centerX() * 2.0f), 0.0f);
|
|
|
}
|
|
|
- canvas.drawRect(paperRect, this.paperShadowPaint);
|
|
|
+ canvas.drawRect(paperRect, paperShadowPaint);
|
|
|
Paint paint = null;
|
|
|
if (this.colorOption.getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_MonochromeGrayscale) {
|
|
|
- paint = this.grayscalePaint;
|
|
|
+ paint = grayscalePaint;
|
|
|
}
|
|
|
canvas.drawBitmap(this.layout.getBitmap(), (float) offset.x, (float) offset.y, paint);
|
|
|
- RectF copyFrame = this.layout.getCopyFrame();
|
|
|
+ RectF copyFrame = layout.getCopyFrame();
|
|
|
if (!this.paperFrame.isEmpty() && copyFrame != null) {
|
|
|
copyFrame.offset((float) offset.x, (float) offset.y);
|
|
|
Path path = new Path();
|
|
|
path.addRect(copyFrame, Path.Direction.CW);
|
|
|
- canvas.drawPath(path, this.copyFramePaint);
|
|
|
+ canvas.drawPath(path, copyFramePaint);
|
|
|
}
|
|
|
canvas.restore();
|
|
|
}
|
|
|
@@ -273,18 +273,18 @@ public class ECopyPreview extends View {
|
|
|
int width;
|
|
|
|
|
|
Size(int i, int i2) {
|
|
|
- this.width = i;
|
|
|
- this.height = i2;
|
|
|
+ width = i;
|
|
|
+ height = i2;
|
|
|
}
|
|
|
|
|
|
Size(Size size) {
|
|
|
- this.width = size.width;
|
|
|
- this.height = size.height;
|
|
|
+ width = size.width;
|
|
|
+ height = size.height;
|
|
|
}
|
|
|
|
|
|
private void scale(float f) {
|
|
|
- this.width = (int) (((float) this.width) * f);
|
|
|
- this.height = (int) (((float) this.height) * f);
|
|
|
+ width = (int) (((float) width) * f);
|
|
|
+ height = (int) (((float) height) * f);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -347,91 +347,91 @@ public class ECopyPreview extends View {
|
|
|
Bitmap scanImage;
|
|
|
|
|
|
LayoutStandard(int i, int i2) {
|
|
|
- this.layoutWidth = i;
|
|
|
- this.layoutHeight = i2;
|
|
|
+ layoutWidth = i;
|
|
|
+ layoutHeight = i2;
|
|
|
if (ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.XScale).getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.XScale_Autofit) {
|
|
|
- this.autofitEnabled = true;
|
|
|
+ autofitEnabled = true;
|
|
|
}
|
|
|
ECopyOptionItem copyOptionItemOf = ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.PrintMediaSize);
|
|
|
switch (copyOptionItemOf.getSelectedChoice()) {
|
|
|
case PrintMediaSize_A4:
|
|
|
- this.paperSize = ECopyPreview.this.f360A4;
|
|
|
+ paperSize = ECopyPreview.this.f360A4;
|
|
|
break;
|
|
|
case PrintMediaSize_B5:
|
|
|
- this.paperSize = ECopyPreview.this.f361B5;
|
|
|
+ paperSize = ECopyPreview.this.f361B5;
|
|
|
break;
|
|
|
case PrintMediaSize_L:
|
|
|
- this.paperSize = ECopyPreview.this.f363L;
|
|
|
+ paperSize = ECopyPreview.this.f363L;
|
|
|
break;
|
|
|
case PrintMediaSize_2L:
|
|
|
- this.paperSize = ECopyPreview.this.f364L2;
|
|
|
+ paperSize = ECopyPreview.this.f364L2;
|
|
|
break;
|
|
|
case PrintMediaSize_Postcard:
|
|
|
- this.paperSize = ECopyPreview.this.Hagaki;
|
|
|
+ paperSize = ECopyPreview.this.Hagaki;
|
|
|
break;
|
|
|
case PrintMediaSize_KG:
|
|
|
- this.paperSize = ECopyPreview.this.f362KG;
|
|
|
+ paperSize = ECopyPreview.this.f362KG;
|
|
|
break;
|
|
|
case PrintMediaSize_8x10in:
|
|
|
- this.paperSize = ECopyPreview.this.f365P6;
|
|
|
+ paperSize = ECopyPreview.this.f365P6;
|
|
|
break;
|
|
|
default:
|
|
|
- this.paperSize = ECopyPreview.this.Max;
|
|
|
+ paperSize = ECopyPreview.this.Max;
|
|
|
break;
|
|
|
}
|
|
|
float f = (float) i;
|
|
|
float f2 = (float) i2;
|
|
|
- float aspectFitScale = getAspectFitScale(f, f2, (float) this.paperSize.width, (float) this.paperSize.height, Layout.AspectFit.Min);
|
|
|
- RectF rectF = new RectF(0.0f, 0.0f, (float) this.paperSize.width, (float) this.paperSize.height);
|
|
|
+ float aspectFitScale = getAspectFitScale(f, f2, (float) paperSize.width, (float) paperSize.height, Layout.AspectFit.Min);
|
|
|
+ RectF rectF = new RectF(0.0f, 0.0f, (float) paperSize.width, (float) paperSize.height);
|
|
|
scaleRect(aspectFitScale, rectF);
|
|
|
- this.paperImage = Bitmap.createBitmap((int) rectF.width(), (int) rectF.height(), Bitmap.Config.ARGB_8888);
|
|
|
- RectF rectF2 = new RectF(0.0f, 0.0f, (float) this.paperSize.width, (float) this.paperSize.height);
|
|
|
+ paperImage = Bitmap.createBitmap((int) rectF.width(), (int) rectF.height(), Bitmap.Config.ARGB_8888);
|
|
|
+ RectF rectF2 = new RectF(0.0f, 0.0f, (float) paperSize.width, (float) paperSize.height);
|
|
|
rectF2.left += 18.0f;
|
|
|
rectF2.top += 18.0f;
|
|
|
rectF2.right -= 18.0f;
|
|
|
rectF2.bottom -= 18.0f;
|
|
|
scaleRect(aspectFitScale, rectF2);
|
|
|
- this.paperBorderClipPath.addRect(rectF2, Path.Direction.CW);
|
|
|
+ paperBorderClipPath.addRect(rectF2, Path.Direction.CW);
|
|
|
float aspectFitScale2 = getAspectFitScale(f, f2, (float) ECopyPreview.this.Max.width, (float) ECopyPreview.this.Max.height, Layout.AspectFit.Min);
|
|
|
RectF rectF3 = new RectF(0.0f, 0.0f, (float) ECopyPreview.this.Max.width, (float) ECopyPreview.this.Max.height);
|
|
|
scaleRect(aspectFitScale2, rectF3);
|
|
|
- this.maxPaperImage = Bitmap.createBitmap((int) rectF3.width(), (int) rectF3.height(), Bitmap.Config.ARGB_8888);
|
|
|
+ maxPaperImage = Bitmap.createBitmap((int) rectF3.width(), (int) rectF3.height(), Bitmap.Config.ARGB_8888);
|
|
|
invalidatePaperSize();
|
|
|
}
|
|
|
|
|
|
private Bitmap getBitmap() {
|
|
|
boolean showPaper = showPaper();
|
|
|
- Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
|
|
|
- this.canvas = new Canvas(bitmap);
|
|
|
- this.canvas.save();
|
|
|
+ Bitmap bitmap = showPaper ? paperImage : maxPaperImage;
|
|
|
+ canvas = new Canvas(bitmap);
|
|
|
+ canvas.save();
|
|
|
ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
|
|
ECopyPreview.this.paperDrawable.draw(this.canvas);
|
|
|
- Bitmap bitmap2 = this.scanImage;
|
|
|
+ Bitmap bitmap2 = scanImage;
|
|
|
if (bitmap2 != null) {
|
|
|
if (showPaper) {
|
|
|
- float f = this.copyScale / this.limitCopyScaleDown;
|
|
|
+ float f = copyScale / limitCopyScaleDown;
|
|
|
if (this.autofitEnabled) {
|
|
|
- f = 1.0f / getAspectFitScale(this.scanFrame.width(), this.scanFrame.height(), (float) this.canvas.getWidth(), (float) this.canvas.getHeight(), Layout.AspectFit.Max);
|
|
|
+ f = 1.0f / getAspectFitScale(this.scanFrame.width(), scanFrame.height(), (float) canvas.getWidth(), (float) canvas.getHeight(), Layout.AspectFit.Max);
|
|
|
}
|
|
|
Matrix matrix = new Matrix();
|
|
|
matrix.postScale(f, f);
|
|
|
- this.canvas.clipPath(this.paperBorderClipPath);
|
|
|
- this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
|
|
|
+ canvas.clipPath(this.paperBorderClipPath);
|
|
|
+ canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
|
|
|
} else {
|
|
|
- this.canvas.drawBitmap(bitmap2, 0.0f, 0.0f, (Paint) null);
|
|
|
+ canvas.drawBitmap(bitmap2, 0.0f, 0.0f, (Paint) null);
|
|
|
}
|
|
|
}
|
|
|
- this.canvas.restore();
|
|
|
+ canvas.restore();
|
|
|
return bitmap;
|
|
|
}
|
|
|
|
|
|
private float getScanImageScale(int i, int i2) {
|
|
|
- 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);
|
|
|
- return this.imageScale;
|
|
|
+ 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);
|
|
|
+ return imageScale;
|
|
|
}
|
|
|
|
|
|
private void setScanImage(Bitmap bitmap) {
|
|
|
- this.scanImage = bitmap;
|
|
|
+ scanImage = bitmap;
|
|
|
}
|
|
|
|
|
|
private Point getOffset() {
|
|
|
@@ -439,37 +439,37 @@ public class ECopyPreview extends View {
|
|
|
}
|
|
|
|
|
|
private void setPaperFrame(RectF rectF) {
|
|
|
- this.scanFrame = new RectF(rectF);
|
|
|
- scaleRect(this.imageScale, this.scanFrame);
|
|
|
- this.copyFrame = new RectF(rectF);
|
|
|
- this.copyFrame.left += 18.0f;
|
|
|
- this.copyFrame.top += 18.0f;
|
|
|
- this.copyFrame.right -= 36.0f;
|
|
|
- this.copyFrame.bottom -= 36.0f;
|
|
|
- scaleRect(this.imageScale, this.copyFrame);
|
|
|
+ scanFrame = new RectF(rectF);
|
|
|
+ scaleRect(this.imageScale, scanFrame);
|
|
|
+ copyFrame = new RectF(rectF);
|
|
|
+ copyFrame.left += 18.0f;
|
|
|
+ copyFrame.top += 18.0f;
|
|
|
+ copyFrame.right -= 36.0f;
|
|
|
+ copyFrame.bottom -= 36.0f;
|
|
|
+ scaleRect(this.imageScale, copyFrame);
|
|
|
calcLimitCopyScaleDown();
|
|
|
invalidatePaperSize();
|
|
|
}
|
|
|
|
|
|
private RectF getCopyFrame() {
|
|
|
RectF rectF;
|
|
|
- if (showPaper() || this.scanImage == null || (rectF = this.copyFrame) == null) {
|
|
|
+ if (showPaper() || scanImage == null || (rectF = copyFrame) == null) {
|
|
|
return null;
|
|
|
}
|
|
|
RectF rectF2 = new RectF(rectF);
|
|
|
- float max = 1.0f / Math.max(this.copyScale, this.limitCopyScaleDown);
|
|
|
+ float max = 1.0f / Math.max(this.copyScale, limitCopyScaleDown);
|
|
|
rectF2.right *= max;
|
|
|
rectF2.bottom *= max;
|
|
|
return rectF2;
|
|
|
}
|
|
|
|
|
|
private void setCopyScale(float f) {
|
|
|
- this.copyScale = f;
|
|
|
+ copyScale = f;
|
|
|
invalidatePaperSize();
|
|
|
}
|
|
|
|
|
|
private boolean showPaper() {
|
|
|
- boolean z = this.copyScale < this.limitCopyScaleDown;
|
|
|
+ boolean z = copyScale < limitCopyScaleDown;
|
|
|
if (this.autofitEnabled) {
|
|
|
return true;
|
|
|
}
|
|
|
@@ -477,20 +477,20 @@ public class ECopyPreview extends View {
|
|
|
}
|
|
|
|
|
|
private void invalidatePaperSize() {
|
|
|
- Size size = showPaper() ? this.paperSize : ECopyPreview.this.Max;
|
|
|
- float aspectFitScale = getAspectFitScale((float) this.layoutWidth, (float) this.layoutHeight, (float) size.width, (float) size.height, Layout.AspectFit.Min);
|
|
|
- this.paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
|
|
|
- scaleRect(aspectFitScale, this.paper);
|
|
|
- this.offset.x = ((int) (((float) this.layoutWidth) - this.paper.right)) / 2;
|
|
|
- this.offset.y = ((int) (((float) this.layoutHeight) - this.paper.bottom)) / 2;
|
|
|
+ Size size = showPaper() ? paperSize : ECopyPreview.this.Max;
|
|
|
+ float aspectFitScale = getAspectFitScale((float) layoutWidth, (float) layoutHeight, (float) size.width, (float) size.height, Layout.AspectFit.Min);
|
|
|
+ paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
|
|
|
+ scaleRect(aspectFitScale, paper);
|
|
|
+ offset.x = ((int) (((float) layoutWidth) - paper.right)) / 2;
|
|
|
+ offset.y = ((int) (((float) layoutHeight) - paper.bottom)) / 2;
|
|
|
}
|
|
|
|
|
|
private void calcLimitCopyScaleDown() {
|
|
|
- this.limitCopyScaleDown = getAspectFitScale(this.copyFrame.right, this.copyFrame.bottom, this.paper.width(), this.paper.height(), Layout.AspectFit.Max);
|
|
|
+ limitCopyScaleDown = getAspectFitScale(this.copyFrame.right, copyFrame.bottom, paper.width(), paper.height(), Layout.AspectFit.Max);
|
|
|
}
|
|
|
|
|
|
private RectF getPaperRect() {
|
|
|
- return new RectF(0.0f, 0.0f, this.paper.width(), this.paper.height());
|
|
|
+ return new RectF(0.0f, 0.0f, paper.width(), paper.height());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -501,27 +501,27 @@ public class ECopyPreview extends View {
|
|
|
|
|
|
private Bitmap getBitmap() {
|
|
|
boolean showPaper = showPaper();
|
|
|
- Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
|
|
|
- this.canvas = new Canvas(bitmap);
|
|
|
- this.canvas.save();
|
|
|
+ Bitmap bitmap = showPaper ? paperImage : maxPaperImage;
|
|
|
+ canvas = new Canvas(bitmap);
|
|
|
+ canvas.save();
|
|
|
ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
|
|
ECopyPreview.this.paperDrawable.draw(this.canvas);
|
|
|
if (this.scanImage != null) {
|
|
|
if (showPaper) {
|
|
|
- float f = this.copyScale / this.limitCopyScaleDown;
|
|
|
+ float f = copyScale / limitCopyScaleDown;
|
|
|
if (this.autofitEnabled) {
|
|
|
- f = 1.0f / getAspectFitScale(this.scanFrame.width(), this.scanFrame.height(), (float) this.canvas.getWidth(), (float) this.canvas.getHeight(), Layout.AspectFit.Max);
|
|
|
+ f = 1.0f / getAspectFitScale(this.scanFrame.width(), scanFrame.height(), (float) canvas.getWidth(), (float) canvas.getHeight(), Layout.AspectFit.Max);
|
|
|
}
|
|
|
Matrix matrix = new Matrix();
|
|
|
matrix.postScale(f, f);
|
|
|
- matrix.postTranslate(((float) bitmap.getWidth()) - (((float) this.scanImage.getWidth()) * f), 0.0f);
|
|
|
- this.canvas.clipPath(this.paperBorderClipPath);
|
|
|
- this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
|
|
|
+ matrix.postTranslate(((float) bitmap.getWidth()) - (((float) scanImage.getWidth()) * f), 0.0f);
|
|
|
+ canvas.clipPath(this.paperBorderClipPath);
|
|
|
+ canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
|
|
|
} else {
|
|
|
- this.canvas.drawBitmap(this.scanImage, 0.0f, 0.0f, (Paint) null);
|
|
|
+ canvas.drawBitmap(this.scanImage, 0.0f, 0.0f, (Paint) null);
|
|
|
}
|
|
|
}
|
|
|
- this.canvas.restore();
|
|
|
+ canvas.restore();
|
|
|
return bitmap;
|
|
|
}
|
|
|
}
|
|
|
@@ -544,54 +544,54 @@ public class ECopyPreview extends View {
|
|
|
super(i, i2);
|
|
|
ECopyOptionItem.ECopyOptionItemChoice selectedChoice = ECopyPreview.this.optionContext.getCopyOptionItemOf(ECopyOptionItem.ECopyOptionItemKey.PrintMediaSize).getSelectedChoice();
|
|
|
if (selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_KG || selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_L || selectedChoice == ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_Postcard) {
|
|
|
- this.f368LO = 15;
|
|
|
- this.f369RO = 15;
|
|
|
- this.f370TO = 8;
|
|
|
- this.f367BO = 15;
|
|
|
+ f368LO = 15;
|
|
|
+ f369RO = 15;
|
|
|
+ f370TO = 8;
|
|
|
+ f367BO = 15;
|
|
|
return;
|
|
|
}
|
|
|
- this.f368LO = 15;
|
|
|
- this.f369RO = 15;
|
|
|
- this.f370TO = 17;
|
|
|
- this.f367BO = 15;
|
|
|
+ f368LO = 15;
|
|
|
+ f369RO = 15;
|
|
|
+ f370TO = 17;
|
|
|
+ f367BO = 15;
|
|
|
}
|
|
|
|
|
|
private Bitmap getBitmap() {
|
|
|
boolean showPaper = showPaper();
|
|
|
- Bitmap bitmap = showPaper ? this.paperImage : this.maxPaperImage;
|
|
|
- this.canvas = new Canvas(bitmap);
|
|
|
- this.canvas.save();
|
|
|
+ Bitmap bitmap = showPaper ? paperImage : maxPaperImage;
|
|
|
+ canvas = new Canvas(bitmap);
|
|
|
+ canvas.save();
|
|
|
ECopyPreview.this.paperDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
|
|
ECopyPreview.this.paperDrawable.draw(this.canvas);
|
|
|
if (this.scanImage != null) {
|
|
|
if (showPaper) {
|
|
|
- float f = this.copyScale;
|
|
|
+ float f = copyScale;
|
|
|
if (this.autofitEnabled) {
|
|
|
- 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);
|
|
|
+ f = 1.0f / getAspectFitScale(this.scanFrame.width(), scanFrame.height(), (float) ((this.paperImage.getWidth() + f368LO) + f369RO), (float) ((this.paperImage.getHeight() + f370TO) + f367BO), Layout.AspectFit.Min);
|
|
|
}
|
|
|
Matrix matrix = new Matrix();
|
|
|
matrix.postTranslate((float) (-this.f368LO), (float) (-this.f370TO));
|
|
|
matrix.postScale(f, f);
|
|
|
- this.canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
|
|
|
+ canvas.drawBitmap(this.scanImage, matrix, (Paint) null);
|
|
|
} else {
|
|
|
- this.canvas.drawBitmap(this.scanImage, (float) (-this.f368LO), (float) (-this.f370TO), (Paint) null);
|
|
|
+ canvas.drawBitmap(this.scanImage, (float) (-this.f368LO), (float) (-this.f370TO), (Paint) null);
|
|
|
}
|
|
|
}
|
|
|
- this.canvas.restore();
|
|
|
+ canvas.restore();
|
|
|
return bitmap;
|
|
|
}
|
|
|
|
|
|
private void setPaperFrame(RectF rectF) {
|
|
|
- this.scanFrame = new RectF(rectF);
|
|
|
- scaleRect(this.imageScale, this.scanFrame);
|
|
|
- this.copyFrame = new RectF(rectF);
|
|
|
- scaleRect(this.imageScale, this.copyFrame);
|
|
|
+ scanFrame = new RectF(rectF);
|
|
|
+ scaleRect(this.imageScale, scanFrame);
|
|
|
+ copyFrame = new RectF(rectF);
|
|
|
+ scaleRect(this.imageScale, copyFrame);
|
|
|
calcLimitCopyScaleDown();
|
|
|
invalidatePaperSize();
|
|
|
- this.f368LO = (int) (((float) this.f368LO) * this.imageScale);
|
|
|
- this.f369RO = (int) (((float) this.f369RO) * this.imageScale);
|
|
|
- this.f370TO = (int) (((float) this.f370TO) * this.imageScale);
|
|
|
- this.f367BO = (int) (((float) this.f367BO) * this.imageScale);
|
|
|
+ f368LO = (int) (((float) f368LO) * imageScale);
|
|
|
+ f369RO = (int) (((float) f369RO) * imageScale);
|
|
|
+ f370TO = (int) (((float) f370TO) * imageScale);
|
|
|
+ f367BO = (int) (((float) f367BO) * imageScale);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -614,43 +614,43 @@ public class ECopyPreview extends View {
|
|
|
Layout2Up(int i, int i2) {
|
|
|
Size size = ECopyPreview.this.A4_2Up;
|
|
|
Size size2 = ECopyPreview.this.A4_2UpPage;
|
|
|
- this.paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
|
|
|
- this.page1 = new RectF(30.0f, 32.0f, (float) (size2.width + 30), (float) (size2.height + 32));
|
|
|
- this.page2 = new RectF(this.page1.right + 35.0f, this.page1.top, this.page1.right + 35.0f + ((float) size2.width), this.page1.bottom);
|
|
|
+ paper = new RectF(0.0f, 0.0f, (float) size.width, (float) size.height);
|
|
|
+ page1 = new RectF(30.0f, 32.0f, (float) (size2.width + 30), (float) (size2.height + 32));
|
|
|
+ page2 = new RectF(this.page1.right + 35.0f, page1.top, page1.right + 35.0f + ((float) size2.width), page1.bottom);
|
|
|
float f = (float) i;
|
|
|
float f2 = (float) i2;
|
|
|
float aspectFitScale = getAspectFitScale(f, f2, (float) size.width, (float) size.height, Layout.AspectFit.Min);
|
|
|
- scaleRect(aspectFitScale, this.paper);
|
|
|
- scaleRect(aspectFitScale, this.page1);
|
|
|
- scaleRect(aspectFitScale, this.page2);
|
|
|
- this.offset.x = ((int) (f - this.paper.right)) / 2;
|
|
|
- this.offset.y = ((int) (f2 - this.paper.bottom)) / 2;
|
|
|
+ scaleRect(aspectFitScale, paper);
|
|
|
+ scaleRect(aspectFitScale, page1);
|
|
|
+ scaleRect(aspectFitScale, page2);
|
|
|
+ offset.x = ((int) (f - paper.right)) / 2;
|
|
|
+ offset.y = ((int) (f2 - paper.bottom)) / 2;
|
|
|
}
|
|
|
|
|
|
public Bitmap getBitmap() {
|
|
|
- Bitmap createBitmap = Bitmap.createBitmap((int) this.paper.width(), (int) this.paper.height(), Bitmap.Config.ARGB_8888);
|
|
|
+ Bitmap createBitmap = Bitmap.createBitmap((int) paper.width(), (int) paper.height(), Bitmap.Config.ARGB_8888);
|
|
|
Canvas canvas = new Canvas(createBitmap);
|
|
|
ECopyPreview.this.paperDrawable.setBounds(0, 0, createBitmap.getWidth(), createBitmap.getHeight());
|
|
|
ECopyPreview.this.paperDrawable.draw(canvas);
|
|
|
- Bitmap createBitmap2 = Bitmap.createBitmap((int) this.page1.width(), (int) this.page1.height(), Bitmap.Config.ARGB_8888);
|
|
|
+ Bitmap createBitmap2 = Bitmap.createBitmap((int) page1.width(), (int) page1.height(), Bitmap.Config.ARGB_8888);
|
|
|
new Canvas(createBitmap2).drawColor(-3355444);
|
|
|
- Bitmap bitmap = this.page1Bitmap;
|
|
|
+ Bitmap bitmap = page1Bitmap;
|
|
|
if (bitmap == null) {
|
|
|
bitmap = createBitmap2;
|
|
|
}
|
|
|
- canvas.drawBitmap(bitmap, (Rect) null, this.page1, (Paint) null);
|
|
|
- canvas.drawBitmap(createBitmap2, (Rect) null, this.page2, (Paint) null);
|
|
|
+ canvas.drawBitmap(bitmap, (Rect) null, page1, (Paint) null);
|
|
|
+ canvas.drawBitmap(createBitmap2, (Rect) null, page2, (Paint) null);
|
|
|
return createBitmap;
|
|
|
}
|
|
|
|
|
|
private float getScanImageScale(int i, int i2) {
|
|
|
- this.imageScale = getAspectFitScale(this.page1.width(), this.page1.height(), (float) i, (float) i2, Layout.AspectFit.Min);
|
|
|
- return this.imageScale;
|
|
|
+ imageScale = getAspectFitScale(this.page1.width(), page1.height(), (float) i, (float) i2, Layout.AspectFit.Min);
|
|
|
+ return imageScale;
|
|
|
}
|
|
|
|
|
|
private void setScanImage(Bitmap bitmap) {
|
|
|
- Rect rect = new Rect((int) this.copyFrame.left, (int) this.copyFrame.top, (int) this.copyFrame.right, (int) this.copyFrame.bottom);
|
|
|
- this.page1Bitmap = Bitmap.createBitmap((int) this.page1.width(), (int) this.page1.height(), Bitmap.Config.ARGB_8888);
|
|
|
+ Rect rect = new Rect((int) copyFrame.left, (int) copyFrame.top, (int) copyFrame.right, (int) copyFrame.bottom);
|
|
|
+ page1Bitmap = Bitmap.createBitmap((int) page1.width(), (int) page1.height(), Bitmap.Config.ARGB_8888);
|
|
|
Canvas canvas = new Canvas(this.page1Bitmap);
|
|
|
canvas.drawBitmap(bitmap, rect, new RectF(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight()), (Paint) null);
|
|
|
}
|
|
|
@@ -660,12 +660,12 @@ public class ECopyPreview extends View {
|
|
|
}
|
|
|
|
|
|
private void setPaperFrame(RectF rectF) {
|
|
|
- this.copyFrame = new RectF(rectF);
|
|
|
- scaleRect(this.imageScale, this.copyFrame);
|
|
|
+ copyFrame = new RectF(rectF);
|
|
|
+ scaleRect(this.imageScale, copyFrame);
|
|
|
}
|
|
|
|
|
|
private RectF getPaperRect() {
|
|
|
- return new RectF(0.0f, 0.0f, this.paper.width(), this.paper.height());
|
|
|
+ return new RectF(0.0f, 0.0f, paper.width(), paper.height());
|
|
|
}
|
|
|
}
|
|
|
}
|