In my app I try to store an image from an imageView as a byte array and store that in a databse
ImageView imageView = (ImageView) findViewById(R.id.imgpreview);
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] byteArray = baos.toByteArray();
This byteArray is then stored in a database, and extracted back out inside a custom GridAdapter so that the byte array can be converted back to a bitmap and set as the image view.
ImageView image = (ImageView)gridView.findViewById(R.id.image1);
TextView description = (TextView)gridView.findViewById(R.id.tv1);
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray.get(position), 0, byteArray.get(position).length);
image.setImageBitmap(bmp);
It doesn't seem to be a problem with storing or retrieving the byte array, as I log a toString of the byte array just before it attempts to decode it and it appears to be correctly logged, so I'm confused as to why it's being shown as null, the exact message is:
D/skia: --- SkImageDecoder::Factory returned null
I've looked through all the threads with solutions I could find and tried them all, I just can't figure out how to fix it. I've tried with varying image sizes. If any more info is needed let me know, thanks in advance.