Convert byte array (ISO FMC format )to bitmap - android

In my code I have a method grabFingerprint(); this method returns a byte[] array.
The byte array represents fingerprint data in ISO FMC COMPACT format, or null. (ISO_19794_2_2005 )
Now I want to convert this array to a bitmap. But standard conversion causes the application to crash without an error.
Bitmap bmp = BitmapFactory.decodeByteArray(iso, 0, iso.length);
Any help would be greatly appreciated..

Related

Convert YUV image to single byte array

I am using CameraX to obtain frames from the camera for further analysis. The callback returns ImageProxy object that contains 3 planes of YUV_420_888 image. Now, I want to pass this image to 3rd party library for further processing. The function there accepts one dimensional byte array with "raw image data" - as documentation says. I don't understand how can I convert those 3 arrays (Y, U, V) into one byte array.
I have tried to convert it into Bitmap and then to byte array but the library returns that input is invalid. I have also tried to take only one channel from YUV and pass it to the library and it worked but the results were poor because (as I am guessing) one channel didn't carry enough information for the algorithms.
How can I merge Y, U and V channels into one byte array?

Convert iOS image data to corresponding bitmap object in Android

How can we convert nsdata bytes array of an image in iOS to the corresponding Bitmap bytes array in Android?
Thanks in advance!

Android onPreviewFrame

i'm trying to get data from onPreviewFrame(byte[] data, Camera camera)
and convert it to BASE64,
Base64.encodeToString(data, Base64.DEFAULT)
the result given is not convertible to an image
(using some sites like http://codebeautify.org/base64-to-image-converter)
note that data is a signed byte array that contain some negative values (values between -128 to 127), i think it should be array of unsigned byte, no?
can you help me please, how to get a BASE64 from onPreviewFrame?
thanks,

How to know if a byte array is a valid image

Is there a way to know if a byte array is a valid image?
I am taking a photograph, In OnActivityResult:
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 75, out);
//arrayFotos is an ArrayList
arrayFotos.add(new BeanFotos("", imageBitmap, lastKnwonLocation.getLatitude(), lastKnwonLocation.getLongitude()));
I am storing it in database:
//listaFotos and arrayFotos are the same array, but with different names, because I am storing it in another class in my app
for(int i=0;i<listaFotos.size();i++){
values.clear();
values.put("codficha", codficha);
int bytes=listaFotos.get(i).getFoto().getByteCount();
ByteBuffer buffer = ByteBuffer.allocate(bytes);
listaFotos.get(i).getFoto().copyPixelsToBuffer(buffer);
values.put("foto", buffer.array());
db.insert("fotos", null, values);
}
Later, I need that image to be shown:
byte[] arrayFoto = csr2.getBlob(0);
Bitmap fotoBitmap=BitmapFactory.decodeByteArray(arrayFoto, 0, arrayFoto.length);
The problem is, no matter what i do, the decodeByteArray method always returns null. I have tried with external libraries, and it is always null, so I am thinking maybe I am storing it in the wrong way. The arrayFoto variable is NOT null, I am receiving bytes (84584, to be exact) but the decodeByteArray method returns null.
So, is there a way for me to be sure that the byte array is a correct image?
Thanks.
It seems you are writing the uncompressed Bitmap to the database. You need to compress it to jpeg or png first if you want to be able to decode it using BitmapFactory.
Also, storing images in a database is a bad idea since the cursor window size is limited to 1MB. You should not store binary data in a SQLite db unless it's very small.

android Reading image into byte array and last byte of image

Android:
I have two byte arrays one byte array of bitmap and another byte array of String.
I have combine these two byte arrays into 3rd one.
I will write 3rd byte array into storage.
When i read that image which is created from combine byte array of image and string i want to know in byte[] that where image bytes ends and where string bytes gets start.
How do i know the byte representation of end of image byte ? or starting of string byte ?
Thanks in advance.
Before you write out the byte array, you should write out the length of the image part. That way you'll know how much data to read. So your file will look like this:
Length of image (4 bytes, probably - use DataOutputStream for simplicity)
Image data
Text data
(As an aside, I suggest you explicitly write out the text data as UTF-8, and read it as UTF-8. Or you could just use DataOutputStream.writeUTF and DataInputStream.readUTF of course...)

Categories

Resources