splitting an image

All your problems with Audio, Video and Images.

splitting an image

Postby zidsal » Tue Apr 26, 2011 5:38 pm

I've searched the web for help and although it looked like a solution it turned out to not work so good. For starters I'd like to say I've just jumped into android programming (this is my first day) I really learn by trial and error I'd like it that if you could help me you'd give me hints rather than paste the code in front of me.

my tileset
Image
the result
Image

the issues I'm having is 1. it is obviously not splitting the image in 32 by 32 bits. is what I'm trying to achieve is take my big image and split it into 9* smaller images of 32 by 32 portions. Secondary the image quality gets distorted and I can't work out why.
*I don't want to use a 9 patch as there will be more then 9 images soon just a fluke that atm I have 9 images

my code (evidently plagiarized from the internet)
Code: Select all
tilesetSliced = Bitmap.createScaledBitmap(bmp, 96, 96, true);
tileset[0] = Bitmap.createBitmap(tilesetSliced, 0, 0, 32, 32);
tileset[1] = Bitmap.createBitmap(tilesetSliced, 32, 0, 32, 32);
tileset[2] = Bitmap.createBitmap(tilesetSliced, 64, 0, 32, 32);
tileset[3] = Bitmap.createBitmap(tilesetSliced, 0, 32, 32, 32);
tileset[4] = Bitmap.createBitmap(tilesetSliced, 32, 32, 32, 32);   
tileset[5] =  Bitmap.createBitmap(tilesetSliced, 64, 32, 32, 32);   

I'll make it more efficent once I got it working >.< any help would be great

the on draw
Code: Select all
      
public void onDraw(Canvas canvas) {
  //update();
   for(int x=0; x<= mapWidth; x++){
          for(int y = 0; y <= mapHeight; y++){
                   canvas.drawBitmap(tileset[map[x][y]], x *32, y*32, null);
           }
     }
}
zidsal
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Apr 26, 2011 5:30 pm

Top

Re: splitting an image

Postby RTS Sys » Thu Jul 14, 2011 9:56 am

I think Trial and Error is the best way to sort problems. You will learn a lot and next time you will not have to do this. So just u need is proper logic's to guess the thing. Thanks.
RTS Sys
Freshman
Freshman
 
Posts: 7
Joined: Thu Jul 14, 2011 9:37 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 14 guests