mducc
mducc

Reputation: 743

Can't show image in ImageView

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)

Upvotes: 0

Views: 142

Answers (1)

Dhaval Solanki
Dhaval Solanki

Reputation: 4705

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.

Upvotes: 2

Related Questions