package franck.cameraapp; import android.graphics.Bitmap; /** * The model of the camera app. * * @author Franck van Breugel */ public class Model { private Bitmap bitmap; /** * Initializes this model with the given bitmap. * * @param bitmap bitmap of this model. */ public Model(Bitmap bitmap) { this.bitmap = bitmap; } /** * Returns the bitmap of this model. * * @return bitmap of this model. */ public Bitmap getBitmap() { return this.bitmap; } /** * Reflects the bitmap of this model along the y-axis. */ public void reflectY() { final int WIDTH = this.bitmap.getWidth(); final int HEIGHT = this.bitmap.getHeight(); Bitmap reflection = Bitmap.createBitmap(WIDTH, HEIGHT, this.bitmap.getConfig()); for (int x = 0; x < WIDTH; x++) { for (int y = 0; y < HEIGHT; y++) { int color = this.bitmap.getPixel(x, y); reflection.setPixel(WIDTH - 1 -x, y, color); } } this.bitmap = reflection; } }