source: lost-perception/utils/DynamicImage.java

Last change on this file was ebd3538, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Initial commit. This codebase for the Lost Perception game was created by decompiling code from a jar file.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1package utils;
2
3import java.awt.image.ImageObserver;
4import java.awt.Image;
5import java.awt.Graphics;
6import java.awt.Color;
7import java.awt.image.BufferedImage;
8
9public class DynamicImage
10{
11 private String filePath;
12 private BufferedImage img;
13 private Color bg;
14 private Color shadow;
15
16 public DynamicImage(final String filePath) {
17 this.filePath = filePath;
18 this.img = null;
19 final Color color = null;
20 this.shadow = color;
21 this.bg = color;
22 }
23
24 public DynamicImage(final String filePath, final Color bg, final Color shadow) {
25 this.filePath = filePath;
26 this.img = null;
27 this.bg = bg;
28 this.shadow = shadow;
29 }
30
31 private void loadImg() {
32 if (this.bg == null) {
33 this.img = Utils.loadImg(this.filePath);
34 }
35 else {
36 this.img = Utils.loadTransImg(this.filePath, this.bg, this.shadow);
37 }
38 }
39
40 public int getHeight() {
41 if (this.img == null) {
42 this.loadImg();
43 }
44 return this.img.getHeight();
45 }
46
47 public int getWidth() {
48 if (this.img == null) {
49 this.loadImg();
50 }
51 return this.img.getWidth();
52 }
53
54 public void draw(final Graphics g, final int x, final int y) {
55 if (this.img == null) {
56 this.loadImg();
57 }
58 g.drawImage(this.img, x, y, null);
59 }
60
61 public void draw(final Graphics g, final int dx1, final int dy1, final int dx2, final int dy2, final int sx1, final int sy1, final int sx2, final int sy2) {
62 if (this.img == null) {
63 this.loadImg();
64 }
65 g.drawImage(this.img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
66 }
67}
Note: See TracBrowser for help on using the repository browser.