2

I'm a beginner with android. I want to divide a bitmap image into chunks and then display the image in the same way but divided.

Edit:

This code has worked for me

Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height)

tebitoq
  • 165
  • 1
  • 13
  • 2
    Stackoverflow is for asking specific programmers questions. People are reluctant to write whole code examples. – Peter Knego Aug 29 '11 at 19:43
  • 1
    Yes, please ask specific questions. What you want to do is possible. What part are you having trouble with? – i_am_jorf Aug 29 '11 at 19:50

1 Answers1

12

Here's some pseudo code, that I hope you can use:

Bitmap originalBm = BitmapFactory.decodeFile("fileUrl"); // Let's say this bitmap is 300 x 600 pixels
Bitmap bm1 = Bitmap.createBitmap(originalBm, 0, 0, originalBm.getWidth(), (originalBm.getHeight() / 2));
Bitmap bm2 = Bitmap.createBitmap(originalBm, 0, (originalBm.getHeight() / 2), originalBm.getWidth(), (originalBm.getHeight() / 2));

So, basically - bm1 is the first half and bm2 is the second half. Both will be 300 x 300 pixels.

Fahim
  • 12,198
  • 5
  • 39
  • 57
Michell Bak
  • 13,182
  • 11
  • 64
  • 121
  • http://www.fr4gus.com/2011/03/16/bitmap-crop-en-android/ thank you very much for the reply, i found this one the web. which would be better – tebitoq Aug 31 '11 at 13:55