how to merge an array of bitmap together in one bitmap ?

Problems with Canvas, OpenGL, etc...

how to merge an array of bitmap together in one bitmap ?

Postby freeaks » Mon Jun 28, 2010 5:25 am

hi there,

how can i merge together in one single bitmap the content of a bitmap array ?

here's my render method:

Code: Select all
//here's what i have:
for (int x = 0; x < MapLoader.width; x++) {
  for (int y = 0; y < MapLoader.height; y++) {
    g.drawBitmap( picSource[x][y], posX, posY, BitmapPaint);
  }
}

//and here's what i'd like to have:
g.drawBitmap( picDest, posX, posY, BitmapPaint);


i would like to itterate through picSource[x][y] grab all the bitmap and put them all in picDest.
note that no bitmap contained in the picSource[][] array is located a the same position ..
there's no bitmap on top of any other, they're just displayed in a grid
each is a 32x32 bitmap in a 4x3 grid for example..
each its own spot on the grid ..

thanks for the help
freeaks
Freshman
Freshman
 
Posts: 6
Joined: Mon Jun 28, 2010 5:16 am

Top

Re: how to merge an array of bitmap together in one bitmap ?

Postby mark@project8games.com » Mon Jun 28, 2010 7:44 pm

You could try something like this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. int width = 32 x 4; // 4 across
  2. int height = 32 x 3; // 3 down
  3. //create big bitmap
  4. Bitmap pictDest = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
  5. //create canvas of bitmap to draw to
  6. Canvas canvas = new Canvas(bitmap);
  7.  
  8. //draw each little image onto pictdest
  9. for (int x = 0; x < MapLoader.width; x++) {
  10.     for (int y = 0; y < MapLoader.height; y++) {
  11.         canvas.drawBitmap( picSource[x][y], posX, posY, BitmapPaint);
  12.     }
  13. }
  14.  
  15.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Re: how to merge an array of bitmap together in one bitmap ?

Postby freeaks » Tue Jun 29, 2010 5:20 am

thanks for the help,
it worked :)
i didn't know i could do it like this .. everything drawn in the temp canvas gets saved into Bitmap picDest

so later on in my "normal" render method all i have to do is draw picDest the usual way, without the need of bitmap array or loops , its perfect thanks !
freeaks
Freshman
Freshman
 
Posts: 6
Joined: Mon Jun 28, 2010 5:16 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest