From a28624137b61d96a65bd2e04323e119aaecf9ff3 Mon Sep 17 00:00:00 2001 From: andrejlukasevic Date: Wed, 27 Jan 2016 15:06:36 +0200 Subject: [PATCH 1/3] Button created --- .../build/intermediates/dex-cache/cache.xml | 26 +++++++------- .../java/com/scanlibrary/ScanFragment.java | 32 ++++++++++++++++++ .../src/main/java/com/scanlibrary/Utils.java | 8 +++++ .../ic_rotate_90_degrees_ccw_white_24dp.png | Bin 0 -> 489 bytes .../ic_rotate_90_degrees_ccw_white_24dp.png | Bin 0 -> 366 bytes .../ic_rotate_90_degrees_ccw_white_24dp.png | Bin 0 -> 627 bytes .../ic_rotate_90_degrees_ccw_white_24dp.png | Bin 0 -> 926 bytes .../ic_rotate_90_degrees_ccw_white_24dp.png | Bin 0 -> 1151 bytes .../src/main/res/menu/scan_menu.xml | 6 ++++ .../src/main/res/values-lt/strings.xml | 1 + .../src/main/res/values-ru/strings.xml | 1 + .../src/main/res/values/strings.xml | 1 + 12 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 ScanDemoExample/scanlibrary/src/main/res/drawable-hdpi/ic_rotate_90_degrees_ccw_white_24dp.png create mode 100644 ScanDemoExample/scanlibrary/src/main/res/drawable-mdpi/ic_rotate_90_degrees_ccw_white_24dp.png create mode 100644 ScanDemoExample/scanlibrary/src/main/res/drawable-xhdpi/ic_rotate_90_degrees_ccw_white_24dp.png create mode 100644 ScanDemoExample/scanlibrary/src/main/res/drawable-xxhdpi/ic_rotate_90_degrees_ccw_white_24dp.png create mode 100644 ScanDemoExample/scanlibrary/src/main/res/drawable-xxxhdpi/ic_rotate_90_degrees_ccw_white_24dp.png diff --git a/ScanDemoExample/build/intermediates/dex-cache/cache.xml b/ScanDemoExample/build/intermediates/dex-cache/cache.xml index 29211b53..5093ecf7 100644 --- a/ScanDemoExample/build/intermediates/dex-cache/cache.xml +++ b/ScanDemoExample/build/intermediates/dex-cache/cache.xml @@ -2,39 +2,39 @@ - + sha1="2c91c949a45a21cdecf26e03951e46c7beec9ad8"> + - + sha1="01ec05bfbafcc07646ba813000bf2ef11742dd03"> + - + sha1="4b74cefe1f0c1b819e7260c8627a14674e37fd35"> + + sha1="0e8c5ae3a878f94e72b12a6ddaec219369b5db66"> - + sha1="81d42bf983a8741f4888a6e333e454e4a5e0eeb7"> + diff --git a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java index e34f8b99..e6aca293 100644 --- a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java +++ b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java @@ -158,13 +158,17 @@ public void onSaveInstanceState(Bundle outState) { } private MenuItem cropBtn; + private MenuItem rotateBtn; @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.scan_menu, menu); cropBtn = menu.findItem(R.id.crop); + rotateBtn = menu.findItem(R.id.rotate); + cropBtn.setVisible(!isCropMode); + rotateBtn.setVisible(!isCropMode); super.onCreateOptionsMenu(menu, inflater); } @@ -178,6 +182,9 @@ public boolean onOptionsItemSelected(MenuItem item) { } else if (item.getItemId() == R.id.done) { onDoneButtonClicked(); return true; + } else if (item.getItemId() == R.id.rotate) { + onRotateButtonClicked(); + return true; } return super.onOptionsItemSelected(item); } @@ -203,6 +210,7 @@ private void releaseAllBitmaps() { private void onCropButtonClicked() { cropBtn.setVisible(false); + rotateBtn.setVisible(false); isCropMode = true; Bitmap scaledBitmap = scaleBitmap(takenPhotoBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight()); @@ -220,11 +228,26 @@ private void onCropButtonClicked() { viewHolder.polygonView.setLayoutParams(layoutParams); } + private void onRotateButtonClicked() { + Bitmap takenPhotoBitmapTmp = Utils.rotateBitmap(takenPhotoBitmap, -90); + takenPhotoBitmap.recycle(); + takenPhotoBitmap = takenPhotoBitmapTmp; + + Bitmap documentBitmapTmp = Utils.rotateBitmap(documentBitmap, -90); + documentBitmap.recycle(); + documentBitmap = documentBitmapTmp; + + viewHolder.sourceImageView.setImageBitmap(scaleBitmap(documentBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight())); +// Bitmap tempBitmap = ((BitmapDrawable) viewHolder.sourceImageView.getDrawable()).getBitmap(); + points = getOutlinePoints(viewHolder.sourceFrame); + } + private void onDoneButtonClicked() { if (isCropMode) { isCropMode = false; cropBtn.setVisible(true); + rotateBtn.setVisible(true); Map points = viewHolder.polygonView.getPoints(); if (isScanPointsValid(points)) { @@ -392,6 +415,15 @@ private static Map getOutlinePoints(Bitmap tempBitmap) { return outlinePoints; } + private static Map getOutlinePoints(View view) { + Map outlinePoints = new HashMap<>(); + outlinePoints.put(0, new PointF(0, 0)); + outlinePoints.put(1, new PointF(view.getWidth(), 0)); + outlinePoints.put(2, new PointF(0, view.getHeight())); + outlinePoints.put(3, new PointF(view.getWidth(), view.getHeight())); + return outlinePoints; + } + private static Map orderedValidEdgePoints(Bitmap tempBitmap, List pointFs) { Map orderedPoints = PolygonView.getOrderedPoints(pointFs); if (!PolygonView.isValidShape(orderedPoints)) { diff --git a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java index 1faf536c..55596a85 100644 --- a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java +++ b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java @@ -2,6 +2,8 @@ import android.app.Activity; import android.content.pm.ActivityInfo; +import android.graphics.Bitmap; +import android.graphics.Matrix; import android.util.DisplayMetrics; import android.util.Log; import android.view.Surface; @@ -77,4 +79,10 @@ public static int getScreenOrientation(Activity activity) { return orientation; } + public static Bitmap rotateBitmap(Bitmap source, float angle) { + Matrix matrix = new Matrix(); + matrix.postRotate(angle); + return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); + } + } \ No newline at end of file diff --git a/ScanDemoExample/scanlibrary/src/main/res/drawable-hdpi/ic_rotate_90_degrees_ccw_white_24dp.png b/ScanDemoExample/scanlibrary/src/main/res/drawable-hdpi/ic_rotate_90_degrees_ccw_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..729423cef3df93c7f26f65c3266629877c746550 GIT binary patch literal 489 zcmVnw?0csC8_JIxmr7AmO3KgVUTUq}E#X2;3%Ny&V=4XzrHJiJ(bWC~ z+3GkcX%9E=+G*!=_C4!c@_Jr=>e1)!o&M<*PD-1XlvkKHRS^nCWhj`+P%u@YU;rIU znyx6e4n2|EFOTi5@*@CPb#5@Ip&?1ed;&}vvCmZ>0Ng2u8d_R{@-d(k9kB$sy$KWy zx~YI7JIn#j^oN4!p#qAAyaFr6^H9SASn~%g2DRG>sXIG;12Z|O5RA*t3d*>Y?I`G| z2b5)!R8E-(7Xr#N15p#;SvORK9!wAQIZGXkw}ARF<az2|K^ z_`MD#_W^SosG8@1N4E7q1z72Zl4-z8!&xR}Is_I2lBddjZzD&&<@LiFIf+}Hlc?~!v$wPwLggIsz zaAWYhcGx?U4j470Zodf&0B%XjpN8`b7Ve8nXJg4E`1FYs0pAV^K#^Bmuu5TM*~ z$uSR|(_QYYM<$rLxc>J(YK-!|b5g1SvC9U=<`%~Gk02!f%K!iX M07*qoM6N<$f{ON`L;wH) literal 0 HcmV?d00001 diff --git a/ScanDemoExample/scanlibrary/src/main/res/drawable-xhdpi/ic_rotate_90_degrees_ccw_white_24dp.png b/ScanDemoExample/scanlibrary/src/main/res/drawable-xhdpi/ic_rotate_90_degrees_ccw_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..1f03dc60c01a6ce886c5881f3dd07a8a95e21c42 GIT binary patch literal 627 zcmV-(0*w8MP)s9yw*<^Q>-t`n*o(u8#bJVHhcXg7=2`R2rc3lm+N~ zS%A)$2k5*X@XtE||2(8DG0$zzu-*s6=fj!fD3vk+fI0{LfW09;(kT=4`hjjkd@y4P zRd#ZgN2Ij#iasAO$a{{NUrK=KjBuS6Xcnm!2L@>ZDVAu01@yM^&iv&)Q6Mm8i2<4c zKv=;&&|ED7=zNf91OTCn`=Hq$1^yjpC1Hf;@ChvUw z6-5a5ys%eWFANYMz9`|H7cOe=rU4>^cV3v)=5Yh$5}V!gquR_EFhGRZ;+hvGwfht? zK!j+y=68^3yJmq1;hJAXL)-HtF+d6D{Bj7zo0wd~>?PsnKJdFUaE&S!MWHS=4^*Q`Yin&ulCljPBiKn^J|$3HS99U$3) zA^Dtsq@xX@oi?BpQY9!yH-+|z1u1Di$v#(-!J&h zNo)H<-BTwyS1`-dRFO8T@E9ksy-i;zP?B>3fOY11m3tYWLWvR;2H3{S9AXu)?Fn{q zZaCR%_9j?5ad9^ufrmN3FQoM=Z!tpD&3F5V zL8h5ujwKqLXPpL1%rV1L+~QHfgZ%YCJx~wy4`O5>wNF#^kpKVy07*qoM6N<$f&{~- A5dZ)H literal 0 HcmV?d00001 diff --git a/ScanDemoExample/scanlibrary/src/main/res/drawable-xxxhdpi/ic_rotate_90_degrees_ccw_white_24dp.png b/ScanDemoExample/scanlibrary/src/main/res/drawable-xxxhdpi/ic_rotate_90_degrees_ccw_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..adfd6457f48ebf8ce41bbe18d7df929a8efb5b7c GIT binary patch literal 1151 zcmV-_1c3XAP)>; zZZvBdNYq7vL?JAd1g{EN4z@9dbMxrV-re?`@9*s4`S$$2o#1@F_ws(h@jMU8k^jY- zYmPD!=LC-{Lo|R-z9%3;z9%3;z5~D^-vJOM-vQv1-}nHX?*nkjZ+w8t_XBw4`vdIx zz5uU$s4~YG7x!gpb=f%rv1@c|J#g&R>);km+Tv zlaqv2p(iJRj>}Atlq+!^y=flE2cW~!35PQQgopSOy>k@P0ET=6LDG+PTtsguFM!TZ zC-i3m2&=h--gYxU=UWLGo-U)*?gFhQfX+7&`Z588ZuA50kPV>o?F7ki`>5R%D+~aY zZzsHoWV$b@U7sBg&OggGCejJU+n}Bbqv5YpdwvH(cSM4IHGeq_u;)uuLL1{G_gxTR z&yP+xs$Q|zq5+nC^$HM&u#y`jcMuJ*<@*rSchT2qfF<9Juv0w^3JPG(*M#xh2_4Ln zT(<%k@;wQ^lH4l_V956*43gY?3Sh|hBH z$oC|yBDu+WfE|Q3Y5iAwdI)WXbx5Wwl3b-8poQav_9+EJ{#~3$Z-ISC##@>WFc94G z^+#wz0}KR*e8XR2J0V`ausy@q=%R$rDEQ|i^pe~O4KNVg@`Vpc?p+Nq5Zv;GbLlU0 zSqPs~aLr$#UZ*!{fPvtYFYHne*4s3|Kyb> z4#~~4CJe9>V&*SrlH|@HVStrzcf@?*7`59S2G|MLBIa*omgKHb3AzuD^ zE}{1UVg`f>(LVd5=>5Wy`~aGeU;eAip*O{SNL~O<$SZ#X!-O`+qexBwO~~z?=O{CT zR^>S)KY%7Yf#_okYcsqsml-F#Dtizszo{f?}Y{hVfov|ZyH z4$#@Czol$tGrfGoY0fjoELG;2VU!Vu8KRemX?6G+mh&|M{?`OF0Zl*?@HfB!)YEK$ RyygG^002ovPDHLkV1gZd6X^f| literal 0 HcmV?d00001 diff --git a/ScanDemoExample/scanlibrary/src/main/res/menu/scan_menu.xml b/ScanDemoExample/scanlibrary/src/main/res/menu/scan_menu.xml index 1ea9943a..75cb5c91 100644 --- a/ScanDemoExample/scanlibrary/src/main/res/menu/scan_menu.xml +++ b/ScanDemoExample/scanlibrary/src/main/res/menu/scan_menu.xml @@ -1,6 +1,12 @@ + + Baigti Transformuoti + Pasukti Negalima iškirpti dokumento, pakeiskite taškus Transformuojama... \ No newline at end of file diff --git a/ScanDemoExample/scanlibrary/src/main/res/values-ru/strings.xml b/ScanDemoExample/scanlibrary/src/main/res/values-ru/strings.xml index a61f59cd..d116acf8 100644 --- a/ScanDemoExample/scanlibrary/src/main/res/values-ru/strings.xml +++ b/ScanDemoExample/scanlibrary/src/main/res/values-ru/strings.xml @@ -2,6 +2,7 @@ Завершить Обрезать + Повернуть Не можем обрезать изображение, меняйте пункты Трансформируется... \ No newline at end of file diff --git a/ScanDemoExample/scanlibrary/src/main/res/values/strings.xml b/ScanDemoExample/scanlibrary/src/main/res/values/strings.xml index ded5ef8c..3750cd77 100644 --- a/ScanDemoExample/scanlibrary/src/main/res/values/strings.xml +++ b/ScanDemoExample/scanlibrary/src/main/res/values/strings.xml @@ -4,6 +4,7 @@ ScanLibrary Finish Crop + Rotate Can\'t crop the image, change the points Transforming... From e60f3a410f80eaef738ad06f25ca2981ec3ec0c1 Mon Sep 17 00:00:00 2001 From: andrejlukasevic Date: Wed, 27 Jan 2016 15:29:10 +0200 Subject: [PATCH 2/3] Rotating --- .../build/intermediates/dex-cache/cache.xml | 26 +++++++++---------- .../java/com/scanlibrary/ScanFragment.java | 22 +++++----------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/ScanDemoExample/build/intermediates/dex-cache/cache.xml b/ScanDemoExample/build/intermediates/dex-cache/cache.xml index 5093ecf7..5979cf7f 100644 --- a/ScanDemoExample/build/intermediates/dex-cache/cache.xml +++ b/ScanDemoExample/build/intermediates/dex-cache/cache.xml @@ -1,6 +1,13 @@ + + + - + sha1="ac21bfde5f37e5fb1d90d19251d84b059f833684"> + - - - - + sha1="01ec05bfbafcc07646ba813000bf2ef11742dd03"> + diff --git a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java index e6aca293..b9fe35a0 100644 --- a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java +++ b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java @@ -60,10 +60,8 @@ public class ScanFragment extends Fragment { private Map points; private boolean isCropMode = false; - private boolean isPointsDownScaled = false; private int previousOreantation = -1; - private boolean isOreantationChanged = false; // =========================================================== // Constructors @@ -98,12 +96,8 @@ public void onViewCreated(View view, Bundle savedInstanceState) { int currentOreantation = Utils.getScreenOrientation(getActivity()); if (previousOreantation == -1) { previousOreantation = currentOreantation; - isOreantationChanged = false; - } else if (previousOreantation == currentOreantation) { - isOreantationChanged = false; - } else { - previousOreantation = currentOreantation; - isOreantationChanged = true; + } else if (previousOreantation != currentOreantation) { + points = null; } if (takenPhotoLocation == null) { @@ -128,9 +122,8 @@ public void run() { layoutParams.gravity = Gravity.CENTER; viewHolder.polygonView.setLayoutParams(layoutParams); - if (isOreantationChanged) { + if (points == null) { points = getOutlinePoints(tempBitmap); - isPointsDownScaled = true; } viewHolder.polygonView.setPoints(points); } @@ -216,12 +209,12 @@ private void onCropButtonClicked() { Bitmap scaledBitmap = scaleBitmap(takenPhotoBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight()); viewHolder.sourceImageView.setImageBitmap(scaledBitmap); - if (!isPointsDownScaled) downScalePoints(points, takenPhotoBitmap, scaledBitmap.getWidth(), scaledBitmap.getHeight()); - isPointsDownScaled = true; - viewHolder.polygonView.setPoints(points); - Bitmap tempBitmap = ((BitmapDrawable) viewHolder.sourceImageView.getDrawable()).getBitmap(); viewHolder.polygonView.setVisibility(View.VISIBLE); + + points = getEdgePoints(tempBitmap); + + viewHolder.polygonView.setPoints(points); int padding = (int) getResources().getDimension(R.dimen.scanPadding); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(tempBitmap.getWidth() + 2 * padding, tempBitmap.getHeight() + 2 * padding); layoutParams.gravity = Gravity.CENTER; @@ -463,7 +456,6 @@ protected void dismissDialog() { private void onDocumentFromBitmapTaskFinished(DocumentFromBitmapTaskResult result) { documentBitmap = result.bitmap; points = result.points; - isPointsDownScaled = false; viewHolder.sourceImageView.setImageBitmap(scaleBitmap(documentBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight())); From 2f18774f18c43dbde166a3a0c946b75e1e82e469 Mon Sep 17 00:00:00 2001 From: andrejlukasevic Date: Wed, 27 Jan 2016 16:24:36 +0200 Subject: [PATCH 3/3] Able to rotate and zoom image --- .../build/intermediates/dex-cache/cache.xml | 31 ++++++++++++------- ScanDemoExample/scanlibrary/build.gradle | 2 ++ .../java/com/scanlibrary/ScanFragment.java | 22 +++++++++++-- .../src/main/java/com/scanlibrary/Utils.java | 1 + .../src/main/res/layout/fragment_scan.xml | 20 ++++++++---- 5 files changed, 56 insertions(+), 20 deletions(-) diff --git a/ScanDemoExample/build/intermediates/dex-cache/cache.xml b/ScanDemoExample/build/intermediates/dex-cache/cache.xml index 5979cf7f..f19df12c 100644 --- a/ScanDemoExample/build/intermediates/dex-cache/cache.xml +++ b/ScanDemoExample/build/intermediates/dex-cache/cache.xml @@ -2,32 +2,32 @@ - + sha1="2c91c949a45a21cdecf26e03951e46c7beec9ad8"> + - + sha1="705ffc2c856ea563f08d87cc59e797eb37c69e3f"> + - + sha1="81d42bf983a8741f4888a6e333e454e4a5e0eeb7"> + - + sha1="1ca346c89899db689554b90d197c36ee298bd2e3"> + + + + diff --git a/ScanDemoExample/scanlibrary/build.gradle b/ScanDemoExample/scanlibrary/build.gradle index 9d5ac633..e0937103 100644 --- a/ScanDemoExample/scanlibrary/build.gradle +++ b/ScanDemoExample/scanlibrary/build.gradle @@ -29,4 +29,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) + //Library for Image View That have Ability to zoom... + compile 'com.davemorrissey.labs:subsampling-scale-image-view:2.3.0' } diff --git a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java index b9fe35a0..b14dcc2c 100644 --- a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java +++ b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java @@ -26,6 +26,8 @@ import android.widget.ImageView; import android.widget.Toast; +import com.davemorrissey.labs.subscaleview.ScaleImageView; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -105,6 +107,9 @@ public void onViewCreated(View view, Bundle savedInstanceState) { } else { if (documentBitmap != null) { viewHolder.sourceImageView.setImageBitmap(documentBitmap); + viewHolder.sourceImageView.setVisibility(View.INVISIBLE); + viewHolder.scaleImageView.setImageBitmap(documentBitmap); + viewHolder.scaleImageView.setVisibility(View.VISIBLE); } } @@ -208,6 +213,8 @@ private void onCropButtonClicked() { Bitmap scaledBitmap = scaleBitmap(takenPhotoBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight()); viewHolder.sourceImageView.setImageBitmap(scaledBitmap); + viewHolder.sourceImageView.setVisibility(View.VISIBLE); + viewHolder.scaleImageView.setVisibility(View.GONE); Bitmap tempBitmap = ((BitmapDrawable) viewHolder.sourceImageView.getDrawable()).getBitmap(); viewHolder.polygonView.setVisibility(View.VISIBLE); @@ -230,7 +237,11 @@ private void onRotateButtonClicked() { documentBitmap.recycle(); documentBitmap = documentBitmapTmp; - viewHolder.sourceImageView.setImageBitmap(scaleBitmap(documentBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight())); + Bitmap scaledBitmap = scaleBitmap(documentBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight()); + viewHolder.sourceImageView.setImageBitmap(scaledBitmap); + viewHolder.sourceImageView.setVisibility(View.INVISIBLE); + viewHolder.scaleImageView.setImageBitmap(scaledBitmap); + viewHolder.scaleImageView.setVisibility(View.VISIBLE); // Bitmap tempBitmap = ((BitmapDrawable) viewHolder.sourceImageView.getDrawable()).getBitmap(); points = getOutlinePoints(viewHolder.sourceFrame); } @@ -457,7 +468,11 @@ private void onDocumentFromBitmapTaskFinished(DocumentFromBitmapTaskResult resul documentBitmap = result.bitmap; points = result.points; - viewHolder.sourceImageView.setImageBitmap(scaleBitmap(documentBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight())); + Bitmap scaledBitmap = scaleBitmap(documentBitmap, viewHolder.sourceFrame.getWidth(), viewHolder.sourceFrame.getHeight()); + viewHolder.sourceImageView.setImageBitmap(scaledBitmap); + viewHolder.sourceImageView.setVisibility(View.INVISIBLE); + viewHolder.scaleImageView.setImageBitmap(scaledBitmap); + viewHolder.scaleImageView.setVisibility(View.VISIBLE); viewHolder.polygonView.setVisibility(View.GONE); } @@ -487,6 +502,7 @@ protected void onPreExecute() { @Override protected DocumentFromBitmapTaskResult doInBackground(Void... params) { + System.gc(); DocumentFromBitmapTaskResult result = new DocumentFromBitmapTaskResult(); if (points != null) { @@ -515,11 +531,13 @@ private static class DocumentFromBitmapTaskResult { private static class ViewHolder { private ImageView sourceImageView; + private ScaleImageView scaleImageView; private FrameLayout sourceFrame; private PolygonView polygonView; void prepare(View parent) { sourceImageView = (ImageView) parent.findViewById(R.id.sourceImageView); + scaleImageView = (ScaleImageView) parent.findViewById(R.id.scaleImage); sourceFrame = (FrameLayout) parent.findViewById(R.id.sourceFrame); polygonView = (PolygonView) parent.findViewById(R.id.polygonView); } diff --git a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java index 55596a85..58eab8a5 100644 --- a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java +++ b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/Utils.java @@ -80,6 +80,7 @@ public static int getScreenOrientation(Activity activity) { } public static Bitmap rotateBitmap(Bitmap source, float angle) { + System.gc(); Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); diff --git a/ScanDemoExample/scanlibrary/src/main/res/layout/fragment_scan.xml b/ScanDemoExample/scanlibrary/src/main/res/layout/fragment_scan.xml index 5eedbeac..75dab687 100644 --- a/ScanDemoExample/scanlibrary/src/main/res/layout/fragment_scan.xml +++ b/ScanDemoExample/scanlibrary/src/main/res/layout/fragment_scan.xml @@ -1,9 +1,9 @@ - + + + + - \ No newline at end of file + \ No newline at end of file