0

I have a problem, i load an image(4128x3096) from storage and i want show it on screen.

But after run, my screen is blank (screen white)

But when i load another image(1080x720), it worked and show image on screen

Now, i want show and fill an image(4128x3096) on screen

How to do it?

This is my code:

val bitmap = BitmapFactory.decodeFile(patchFile)
val matrix = Matrix()
matrix.postRotate(90F)
val newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
imageView.setImageBitmap(newBitmap)

LogCat:

    05-29 11:27:47.194 32471-32507/com.example.minhduc.aicam W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3096x4128, max=4096x4096)
    Bitmap too large to be uploaded into a texture (3096x4128, max=4096x4096)
05-29 11:27:48.970 32471-32493/com.example.minhduc.aicam W/MessageQueue: Handler (android.widget.Toast$TN$2) {a8d7afe} sending message to a Handler on a dead thread
    java.lang.IllegalStateException: Handler (android.widget.Toast$TN$2) {a8d7afe} sending message to a Handler on a dead thread
        at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
        at android.os.Handler.enqueueMessage(Handler.java:643)
        at android.os.Handler.sendMessageAtTime(Handler.java:612)
        at android.os.Handler.sendMessageDelayed(Handler.java:582)
        at android.os.Handler.sendMessage(Handler.java:519)
        at android.os.Message.sendToTarget(Message.java:416)
        at android.widget.Toast$TN.hide(Toast.java:414)
        at android.app.ITransientNotification$Stub.onTransact(ITransientNotification.java:57)
        at android.os.Binder.execTransact(Binder.java:565)
mducc
  • 743
  • 1
  • 9
  • 32
  • please post LogCat so we can check what's the issue – The Badak May 29 '18 at 04:20
  • refer this link https://stackoverflow.com/questions/16954109/reduce-the-size-of-a-bitmap-to-a-specified-size-in-android to reduce the size of the bitmap so that it will get loaded in `ImageView` – Bhagyashri May 29 '18 at 04:24
  • this is my logcat: Bitmap too large to be uploaded into a texture (3096x4128, max=4096x4096), i updated my question – mducc May 29 '18 at 04:25
  • decodeFile() will return null if the bitmap would become too big for available memory. Better use images with lower resolution. Or scale down during load. Have a look at the options parameter. – greenapps May 29 '18 at 04:29
  • just pre-scale image before loading. – Vladyslav Matviienko May 29 '18 at 05:27

1 Answers1

2

Actually your image size is too large just because image view not loading the image.

Better way use library like picasso, Glide or Universal image loader which will load image perfectly otherwise resize your bitmap.

Naveen T P
  • 6,955
  • 2
  • 22
  • 29
Dhaval Solanki
  • 4,589
  • 1
  • 23
  • 39