Note that there are some explanatory texts on larger screens.

plurals
  1. POOpening PNG image created in Android on an iPad?
    primarykey
    data
    text
    <p>I'm writing an application that lets you draw a signature, convert it to PNG and upload it to a server in Base64 format. </p> <p>This image should be able to be downloaded using both the iPad and an Android tablet.</p> <p>The Android tablet can download and display images from other tablets and other iPads, but for some reason the iPad chokes when it tries to convert the raw image data into a usable image format?</p> <p>The exception being thrown on the iPad is:</p> <pre><code>imageio: png incorrect header check No IDATs written into file </code></pre> <p>The Android code which creates the PNG image and turns it into Base64 is as follows:</p> <pre><code> public static String getBase64ImageFromImageView(ImageView imageView) { Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] bitmapByteArray = baos.toByteArray(); return Base64.encodeToString(bitmapByteArray, Base64.NO_WRAP); } </code></pre> <p>And the Objective-C code which is throwing the error is:</p> <pre><code> NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(signatureImage)]; </code></pre> <p>Where signatureImage is a UIImage containing the Base64 decoded image data. </p> <p>We've verified that the Base64-ed image is correct by decoding it and saving it as an image file (which works fine)</p> <p>It's the "UIImagePNGRepresentation" call which is causing the issue, but I have no idea why!</p> <p>Any idea, SO gurus?</p> <p><strong>Edit</strong> Just had a thought about this, when I want to use the signature file on android I call the following:</p> <pre><code> byte[] bytes = Base64.decode(base64, Base64.DEFAULT); imageView.setImageBitmap(BitmapFactory.decodeByteArray(bytes, 0, bytes.length)); </code></pre> <p>Could it be that the iPad needs to somehow decompress or decode the image prior to using it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload