Andres
Andres

Reputation: 51

Android: Is there a way to split a byte[] image into two and then strech them?

I have a byte[] with an Image that I have to divide into two separate ones and then strech them to end up with two squared images. I'll post a picture to better illustrate:

example

I was able to get the fisrst half working, I suspect I have problems with the second one because I need the header right? I tried copying it from the fitst half (I read the first 623 bytes where the header, and I was able to kind of display it but it looks wierd, different colors and missing a strip)

The streching part I have no Idea how to acomplish, is it possible? meybe I need to convert the byte[] into someting else to be able to preocess it?

I'll appreciate any help! thanks.

Upvotes: 1

Views: 157

Answers (1)

ControlAltDel
ControlAltDel

Reputation: 35096

You can use Java Graphics2D to accomplish this.

  1. Create 2 new Images in Java
  2. Use Image.getGraphics(), and draw height = 0 - 1/2 height on the first. Use Graphics2D.scale or .transform to stretch.
  3. Same with bottom half. You will probably need a y transform for doing the bottom half

Upvotes: 1

Related Questions