|
5 | 5 |
|
6 | 6 | package journeymap.client.render.texture;
|
7 | 7 |
|
| 8 | +import javax.imageio.ImageTypeSpecifier; |
8 | 9 | import journeymap.client.io.FileHandler;
|
9 | 10 | import journeymap.client.io.IconSetFileHandler;
|
10 | 11 | import journeymap.client.io.RegionImageHandler;
|
|
36 | 37 | */
|
37 | 38 | public class TextureCache
|
38 | 39 | {
|
39 |
| - private final Map<Name, TextureImpl> namedTextures = Collections.synchronizedMap(new HashMap<Name, TextureImpl>(Name.values().length + (Name.values().length / 2) + 1)); |
40 |
| - //private final Map<String, TextureImpl> customTextures = Collections.synchronizedMap(new HashMap<String, TextureImpl>(3)); |
41 |
| - private final Map<String, TextureImpl> playerSkins = Collections.synchronizedMap(new HashMap<String, TextureImpl>()); |
42 |
| - private final Map<String, TextureImpl> entityIcons = Collections.synchronizedMap(new HashMap<String, TextureImpl>()); |
43 |
| - private final Map<String, TextureImpl> themeImages = Collections.synchronizedMap(new HashMap<String, TextureImpl>()); |
| 40 | + private final Map<Name, TextureImpl> namedTextures = Collections.synchronizedMap(new HashMap<>(Name.values().length + (Name.values().length / 2) + 1)); |
| 41 | + //private final Map<String, TextureImpl> customTextures = Collections.synchronizedMap(new HashMap<>(3)); |
| 42 | + private final Map<String, TextureImpl> playerSkins = Collections.synchronizedMap(new HashMap<>()); |
| 43 | + private final Map<String, TextureImpl> entityIcons = Collections.synchronizedMap(new HashMap<>()); |
| 44 | + private final Map<String, TextureImpl> themeImages = Collections.synchronizedMap(new HashMap<>()); |
44 | 45 |
|
45 | 46 | private ThreadPoolExecutor texExec = new ThreadPoolExecutor(2, 4, 15L, TimeUnit.SECONDS,
|
46 | 47 | new ArrayBlockingQueue<Runnable>(8), new JMThreadFactory("texture"), new ThreadPoolExecutor.CallerRunsPolicy());
|
@@ -322,7 +323,7 @@ public TextureImpl getThemeTexture(Theme theme, String iconPath, int width, int
|
322 | 323 | {
|
323 | 324 | if (alpha < 1f || img.getWidth() != width || img.getHeight() != height)
|
324 | 325 | {
|
325 |
| - BufferedImage tmp = new BufferedImage(width, height, img.getType()); |
| 326 | + BufferedImage tmp = ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(width, height); |
326 | 327 | Graphics2D g = tmp.createGraphics();
|
327 | 328 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
328 | 329 | g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
@@ -363,7 +364,7 @@ public TextureImpl getScaledCopy(String texName, TextureImpl original, int width
|
363 | 364 | {
|
364 | 365 | if (alpha < 1f || img.getWidth() != width || img.getHeight() != height)
|
365 | 366 | {
|
366 |
| - BufferedImage tmp = new BufferedImage(width, height, img.getType()); |
| 367 | + BufferedImage tmp = ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(width, height); |
367 | 368 | Graphics2D g = tmp.createGraphics();
|
368 | 369 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
369 | 370 | g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
@@ -424,7 +425,8 @@ public Void call() throws Exception
|
424 | 425 | BufferedImage img = downloadSkin(username);
|
425 | 426 | if (img != null)
|
426 | 427 | {
|
427 |
| - final BufferedImage scaledImage = new BufferedImage(24, 24, img.getType()); |
| 428 | + final BufferedImage scaledImage = |
| 429 | + ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(24, 24); |
428 | 430 | final Graphics2D g = RegionImageHandler.initRenderingHints(scaledImage.createGraphics());
|
429 | 431 | g.drawImage(img, 0, 0, 24, 24, null);
|
430 | 432 | g.dispose();
|
|
0 commit comments