Reputation: 114
I'm sending big images from a server to the app that connects to it, not big enough to cause out of memory exceptions, but enough so that it takes disturbingly long for the image to be sent over 4g. I was wondering if there was a way to buffer the bitmap with the bytes of the image we currently have, and only load the part of the image that has been received, and update it as new data is accepted, looking somewhat like how images load from top to bottom in browsers when the connection is slow.
Upvotes: 1
Views: 106
Reputation: 1847
I think if you want to display images in chunk, then you need to send them in chunk from the server. I mean that suppose you had one big image, then divide the image from its height. i.e if you have image of size AXB, then you can divide them in say 3, then each image will be AX(B/3), So now send images to client and you can gradually show first image, then when you receive 2nd chunk, then merge 1 and 2nd chunk and refresh the image with new image and follow the similar procedure till you have received the whole image. I think the whole point is keep user interested that app is working very fast.
The other approach can be have 2 sets of images at server. One with very low resolution and small size from actual size, so that it has very low size in bytes. When user request, send the low resolution image and take some time to show it with spinning wheel and behind the scene, try to download the real image and once you receive that, you can show the real image.
Upvotes: 2