public class ScanFragment
extends android.app.Fragment
Modifier and Type | Class and Description |
---|---|
private class |
ScanFragment.ScanAsyncTask
A class to scan the image on the click of the button.
|
private class |
ScanFragment.ScanButtonClickListener
A class to know when to scan the image.
|
Modifier and Type | Field and Description |
---|---|
private android.graphics.Bitmap |
original
The image to be cropped
|
private PolygonView |
polygonView
The polygonView to mark the corners
|
private ProgressDialogFragment |
progressDialogFragment
The Fragment to show when any operation is being performed
|
android.widget.Button |
scanButton
A button to approve the corners selected by the user
|
private android.widget.FrameLayout |
sourceFrame
The frame containing the source image
|
private android.widget.ImageView |
sourceImageView
The imageView containing the image to be cropped
|
private android.view.View |
view
The root view of the fragment
|
Constructor and Description |
---|
ScanFragment() |
Modifier and Type | Method and Description |
---|---|
protected void |
dismissDialog()
A function to dismiss the progress dialog.
|
private void |
getBitmap()
Get the bitmap asynchronously set by the user
|
private java.util.List<android.graphics.PointF> |
getContourEdgePoints(android.graphics.Bitmap tempBitmap)
A function to get the points of the corners
|
private java.util.Map<java.lang.Integer,android.graphics.PointF> |
getEdgePoints(android.graphics.Bitmap tempBitmap)
Get edge points (corners)
|
private java.util.Map<java.lang.Integer,android.graphics.PointF> |
getOutlinePoints(android.graphics.Bitmap tempBitmap)
The outline points of the image (the actual image)
|
private android.graphics.Bitmap |
getScannedBitmap(android.graphics.Bitmap original,
java.util.Map<java.lang.Integer,android.graphics.PointF> points)
A function to crop the image to the given points
|
private android.net.Uri |
getUri()
The URI of the bitmap
|
private void |
init()
The main function of the Fragment
|
private boolean |
isScanPointsValid(java.util.Map<java.lang.Integer,android.graphics.PointF> points)
A function to check whether the given points correspond to a quadrilateral or not.
|
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
A function to create the view and start the main function (the init function)
|
void |
onReceiveBitmap(android.graphics.Bitmap bitmap)
A function to receive the requested bitmap
|
private java.util.Map<java.lang.Integer,android.graphics.PointF> |
orderedValidEdgePoints(android.graphics.Bitmap tempBitmap,
java.util.List<android.graphics.PointF> pointFs)
A function to order the edge points
|
private android.graphics.Bitmap |
scaledBitmap(android.graphics.Bitmap bitmap,
int width,
int height)
A function to scale a bitmap
|
private void |
setBitmap(android.graphics.Bitmap original)
A function to set the image in the fragment
|
private void |
showErrorDialog()
A function to show an error dialog.
|
protected void |
showProgressDialog(java.lang.String message)
A function to show the progress dialog.
|
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onResume, onSaveInstanceState, onStart, onStop, onTrimMemory, onViewCreated, onViewStateRestored, postponeEnterTransition, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
private android.graphics.Bitmap original
private PolygonView polygonView
private ProgressDialogFragment progressDialogFragment
public android.widget.Button scanButton
private android.widget.FrameLayout sourceFrame
private android.widget.ImageView sourceImageView
private android.view.View view
protected void dismissDialog()
private void getBitmap()
private java.util.List<android.graphics.PointF> getContourEdgePoints(android.graphics.Bitmap tempBitmap)
tempBitmap
- the bitmap to find the corners inprivate java.util.Map<java.lang.Integer,android.graphics.PointF> getEdgePoints(android.graphics.Bitmap tempBitmap)
tempBitmap
- the bitmap to track onprivate java.util.Map<java.lang.Integer,android.graphics.PointF> getOutlinePoints(android.graphics.Bitmap tempBitmap)
tempBitmap
- the image to get points ofprivate android.graphics.Bitmap getScannedBitmap(android.graphics.Bitmap original, java.util.Map<java.lang.Integer,android.graphics.PointF> points)
original
- the image to be croppedpoints
- the points to crop the image fromprivate android.net.Uri getUri()
private void init()
private boolean isScanPointsValid(java.util.Map<java.lang.Integer,android.graphics.PointF> points)
points
- the points to checkpublic android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
onCreateView
in class android.app.Fragment
inflater
- the default LayoutInflatorcontainer
- the default containersavedInstanceState
- the save state of the fragment (not used)public void onReceiveBitmap(android.graphics.Bitmap bitmap)
bitmap
- the requested bitmapprivate java.util.Map<java.lang.Integer,android.graphics.PointF> orderedValidEdgePoints(android.graphics.Bitmap tempBitmap, java.util.List<android.graphics.PointF> pointFs)
tempBitmap
- the bitmap to get ordered points of.pointFs
- the points to be orderedprivate android.graphics.Bitmap scaledBitmap(android.graphics.Bitmap bitmap, int width, int height)
bitmap
- the bitmap to be scaledwidth
- the width to be scaled to.height
- the height to be scaled to.private void setBitmap(android.graphics.Bitmap original)
original
- the image to be set.private void showErrorDialog()
protected void showProgressDialog(java.lang.String message)
message
- the message to show.