1

I'm creating a puzzle game where the player can choose a picture and then the program splits it into multi-parts.

I tried to search on many posts answers for my problem, but all of them are talking about BufferedImage or Graphic components. I'm coding on android studio to export my application later, and BufferedImage, Graphics, and others are not known by android. So I think that I should use BitmapDrawable to manipulate my images.

public void initImage(int image) {
    this.base = setImage(puzzle.getApplicationContext(), image, 800, 800);
}

public BitmapDrawable setImage(final Context c, final int ressource, final int w, final int h)
{
    try {
        Drawable dr = c.getResources().getDrawable(ressource);
        Bitmap bitmap = ((BitmapDrawable) dr).getBitmap();
        return new BitmapDrawable(c.getResources(), Bitmap.createScaledBitmap(bitmap, w, h, true));
    } catch(ClassCastException cce) { cce.printStackTrace(); return null; }
}

@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    canvas.drawBitmap(this.base.getBitmap(), 0, 0, null);
}

I draw my first image, and now I want to split it into multi parts.

If anyone could help me, I would be very grateful. :)

Fishy
  • 1,275
  • 1
  • 12
  • 26
  • Look [this](https://stackoverflow.com/a/9841854/11271840). You just have to compute the coordinates of the part bitmap and do that the number of time you want – Kilarn123 Apr 24 '19 at 13:57

0 Answers0