1package de.ur.mi.oop.graphics;
3import de.ur.mi.oop.utils.FileHelper;
4import de.ur.mi.oop.utils.GraphicsHelper;
6import javax.imageio.ImageIO;
7import java.awt.image.BufferedImage;
9import java.io.IOException;
16 private double rotationAngle;
18 private BufferedImage image;
28 public Image(
float x,
float y, String filePath) {
31 this.rotationAngle = 0;
33 super.setWidth(image.getWidth());
34 super.setHeight(image.getHeight());
48 int[][] pixels =
new int[image.getHeight()][image.getWidth()];
49 for (
int x = 0; x < image.getWidth(); x++) {
50 for (
int y = 0; y < image.getHeight(); y++) {
51 pixels[y][x] = image.getRGB(x, y);
58 for (
int x = 0; x < image.getWidth(); x++) {
59 for (
int y = 0; y < image.getHeight(); y++) {
60 image.setRGB(x, y, pixels[y][x]);
66 super.setWidth(width);
71 super.setHeight(height);
81 public void setWidth(
float width,
boolean smooth) {
82 super.setWidth(width);
92 public void setHeight(
float height,
boolean smooth) {
93 super.setHeight(height);
97 private void rescale(
boolean smooth) {
101 private void loadImage(String filePath) {
103 File file = FileHelper.loadFile(filePath);
104 image = ImageIO.read(file);
105 }
catch (IOException e) {
122 return rotationAngle;
131 return Math.toRadians(rotationAngle);
141 rotationAngle = angle;
void setWidth(float width, boolean smooth)
void setRotationAngle(double angle)
Image(float x, float y, String filePath)
double getRotationAngleInRadians()
Point getRotationOrigin()
void setWidth(float width)
void setHeight(float height, boolean smooth)
void setHeight(float height)
double getRotationAngle()
void setPixelArray(int[][] pixels)
static BufferedImage resizeImage(BufferedImage image, int newWidth, int newHeight)
double MAX_ROTATION_ANGLE
double MIN_ROTATION_ANGLE