user918197
user918197

Reputation: 1139

Merging multiple picture to form one complete picture in Android

i would like to know whether is it possible to merge several images to form one complete image. For my case, is a floor plan that is split in 18 small images and i would like to merge them into one. I had one idea but not sure whether is it workable. My idea is this:

I would first place the top left most image first, with the x and y coordinates as (0,0). Next for the subsequent images (right/bottom of this first image), using the width and height of the image, i would find out the coordinates where the next image would be placed. Doing this i presume would required 18 ImageView to achieve that.

Btw, these 18 images are .gif format and so do i need to like convert them to Bitmap or something before i can display them using ImageView?

Upvotes: 0

Views: 1035

Answers (2)

Dan S
Dan S

Reputation: 9189

Yes its possible create a Bitmap object large enough to hold the whole floor plan and use Canvas to paint them into to the large bitmap. Be sure to cache it or you'll be recreating it every time and you'll have to convert it to png for compatibility with older devices.

Upvotes: 0

ligi
ligi

Reputation: 39539

You could merge the images to a bigger images by drawing the small images to a canvas associated with the resulting big bitmap

Canvas c=new Canvas(result_bitmapenter);

and then draw your small images onto the canvas

c.drawBitmap(small,...);

But that might not be the best way as big images eat lots of memory - perhaps you should concider dynamic loading instead of merging then

Upvotes: 1

Related Questions