This code reads a number of images from files and merges them into a
single image. The merged image is a single column, i.e. each image is
appended to the merged image below the preceding image. So you'll see
as the source bitmaps are gleaned from the files a height calculation
is done. The canvas size is calculated from the maximum width of the
source images and the sum of the heights of the source images.

You could do your own merge image make up and position the images as
need be so the height and width calculations may not be relevant in
your case. In any case you'd need a canvas with dimensions suitable to
contain all the source images in whatever positions you wish to place
them.

Hope this helps.
                                String[] vFilename;
                                int vImageCount;

                                ...

                                Bitmap[] vSourceBitmaps = new 
Bitmap[vImageCount];
                                int vWidth = 0;
                                int vHeight = 0;

                                //Read bitmaps from files
                                for (int i = 0; i <= vImageCount; i++) {
                                        vSourceBitmaps[i] = 
BitmapFactory.decodeFile(vFileName[i]);
                                        vWidth = vSourceBitmaps[i].getWidth() > 
vWidth ? vSourceBitmaps
[i].getWidth() : vWidth;
                                        vHeight += 
vSourceBitmaps[i].getHeight();
                                }

                                //Merging begins here
                                Bitmap vTargetBitmap = 
Bitmap.createBitmap(vWidth, vHeight,
Bitmap.Config.ARGB_8888);
                                Canvas vCanvas = new Canvas(vTargetBitmap);
                                int vInsertY = 0;
                                for (int i = 0; i < vImageCount; i++) {
                                        vCanvas.drawBitmap(vSourceBitmaps[i], 
(float)0f, (float)vInsertY,
null);
                                        vInsertY += 
vSourceBitmaps[i].getHeight();
                                }


On Sep 15, 4:41 pm, chan <[email protected]> wrote:
> can you give some sample codes for merge several images into a one
> single image..
> Thank you advance

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to