Skip to content

Commit e6e30ab

Browse files
authored
Fix image copying for custom color types (#38)
* Switch to ImageTypeSpecifier to copy images * Update changelog.html * Update buildscript * Update changelog.html
1 parent b102afd commit e6e30ab

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

doc/changelog.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ <h1>JourneyMap ${version} for Minecraft ${mcversion}</h1>
2323

2424
<p>New in ${version}</p>
2525
<ul>
26-
<li>Fixed: Minimap not always showing full map tiles.</li>
26+
<li>Fixed: Some PNGs fail to resize.</li>
27+
<li>Chore: Update buildscript.</li>
2728
</ul>

gradle.properties

+13-2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ accessTransformersFile = journeymap_at.cfg
7979
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
8080
usesMixins = false
8181

82+
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
83+
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
84+
# Mixin classes will have access to "main" classes, but not the other way around.
85+
separateMixinSourceSet =
86+
8287
# Adds some debug arguments like verbose output and class export.
8388
usesMixinDebug = false
8489

@@ -111,9 +116,15 @@ minimizeShadowedDependencies = false
111116
# If disabled, won't rename the shadowed classes.
112117
relocateShadowedDependencies = true
113118

114-
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
119+
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
115120
includeWellKnownRepositories = true
116121

122+
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
123+
# list of strings, with the acceptable keys being(case does not matter):
124+
# cursemaven
125+
# modrinth
126+
excludeWellKnownRepositories =
127+
117128
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
118129
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
119130
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
@@ -149,7 +160,7 @@ curseForgeProjectId = 32274
149160
# and the name is the CurseForge project slug of the other mod.
150161
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
151162
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
152-
curseForgeRelations = tool:journeymap-tools
163+
curseForgeRelations = tool\:journeymap-tools
153164

154165
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
155166
# projects. New projects should not use this parameter.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ pluginManagement {
1717
}
1818

1919
plugins {
20-
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.17'
20+
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.30'
2121
}

src/main/java/journeymap/client/render/texture/TextureCache.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package journeymap.client.render.texture;
77

8+
import javax.imageio.ImageTypeSpecifier;
89
import journeymap.client.io.FileHandler;
910
import journeymap.client.io.IconSetFileHandler;
1011
import journeymap.client.io.RegionImageHandler;
@@ -36,11 +37,11 @@
3637
*/
3738
public class TextureCache
3839
{
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<>());
4445

4546
private ThreadPoolExecutor texExec = new ThreadPoolExecutor(2, 4, 15L, TimeUnit.SECONDS,
4647
new ArrayBlockingQueue<Runnable>(8), new JMThreadFactory("texture"), new ThreadPoolExecutor.CallerRunsPolicy());
@@ -322,7 +323,7 @@ public TextureImpl getThemeTexture(Theme theme, String iconPath, int width, int
322323
{
323324
if (alpha < 1f || img.getWidth() != width || img.getHeight() != height)
324325
{
325-
BufferedImage tmp = new BufferedImage(width, height, img.getType());
326+
BufferedImage tmp = ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(width, height);
326327
Graphics2D g = tmp.createGraphics();
327328
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
328329
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
@@ -363,7 +364,7 @@ public TextureImpl getScaledCopy(String texName, TextureImpl original, int width
363364
{
364365
if (alpha < 1f || img.getWidth() != width || img.getHeight() != height)
365366
{
366-
BufferedImage tmp = new BufferedImage(width, height, img.getType());
367+
BufferedImage tmp = ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(width, height);
367368
Graphics2D g = tmp.createGraphics();
368369
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
369370
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
@@ -424,7 +425,8 @@ public Void call() throws Exception
424425
BufferedImage img = downloadSkin(username);
425426
if (img != null)
426427
{
427-
final BufferedImage scaledImage = new BufferedImage(24, 24, img.getType());
428+
final BufferedImage scaledImage =
429+
ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(24, 24);
428430
final Graphics2D g = RegionImageHandler.initRenderingHints(scaledImage.createGraphics());
429431
g.drawImage(img, 0, 0, 24, 24, null);
430432
g.dispose();

0 commit comments

Comments
 (0)