Last active
June 24, 2018 06:15
-
-
Save rajat1saxena/d9bb40104a17a05f2bdce541bd791720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the image's Uri from shared intent etc. | |
val imageSelected: Uri = intent.getParcelableExtra(Intent.EXTRA_STREAM) | |
try { | |
// get the raw file data of the photo | |
val mInputPFD = contentResolver.openFileDescriptor(imageSelected, "r") | |
val mContentFileDescriptor = mInputPFD.fileDescriptor | |
val fIS = FileInputStream(mContentFileDescriptor) | |
val mGraphicBuffer = ByteArrayOutputStream() | |
val buf = ByteArray(1024) | |
while (true) { | |
val readNum = fIS.read(buf) | |
if (readNum == -1) break | |
mGraphicBuffer.write(buf, 0, readNum) | |
} | |
// Generate the checksum | |
mChecksum = generateChecksum(mGraphicBuffer) | |
} catch (e: Exception) { | |
e.printStackTrace() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment