source: last-defense/utils/DynamicImage.java@ ca2a854

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

Initial commit, code decompiled from a jar

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