Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split image to 2 parts? [closed]

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)

like image 927
tebitoq Avatar asked Jan 21 '26 01:01

tebitoq


1 Answers

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.

like image 54
Michell Bak Avatar answered Jan 23 '26 14:01

Michell Bak