Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image copying for custom color types #38

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ <h1>JourneyMap ${version} for Minecraft ${mcversion}</h1>

<p>New in ${version}</p>
<ul>
<li>Fixed: Minimap not always showing full map tiles.</li>
<li>Fixed: Some PNGs fail to resize.</li>
<li>Chore: Update buildscript.</li>
</ul>
15 changes: 13 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ accessTransformersFile = journeymap_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false

# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =

# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false

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

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

# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =

# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
Expand Down Expand Up @@ -149,7 +160,7 @@ curseForgeProjectId = 32274
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations = tool:journeymap-tools
curseForgeRelations = tool\:journeymap-tools

# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.17'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.30'
}
18 changes: 10 additions & 8 deletions src/main/java/journeymap/client/render/texture/TextureCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package journeymap.client.render.texture;

import javax.imageio.ImageTypeSpecifier;
import journeymap.client.io.FileHandler;
import journeymap.client.io.IconSetFileHandler;
import journeymap.client.io.RegionImageHandler;
Expand Down Expand Up @@ -36,11 +37,11 @@
*/
public class TextureCache
{
private final Map<Name, TextureImpl> namedTextures = Collections.synchronizedMap(new HashMap<Name, TextureImpl>(Name.values().length + (Name.values().length / 2) + 1));
//private final Map<String, TextureImpl> customTextures = Collections.synchronizedMap(new HashMap<String, TextureImpl>(3));
private final Map<String, TextureImpl> playerSkins = Collections.synchronizedMap(new HashMap<String, TextureImpl>());
private final Map<String, TextureImpl> entityIcons = Collections.synchronizedMap(new HashMap<String, TextureImpl>());
private final Map<String, TextureImpl> themeImages = Collections.synchronizedMap(new HashMap<String, TextureImpl>());
private final Map<Name, TextureImpl> namedTextures = Collections.synchronizedMap(new HashMap<>(Name.values().length + (Name.values().length / 2) + 1));
Comment on lines -39 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

//private final Map<String, TextureImpl> customTextures = Collections.synchronizedMap(new HashMap<>(3));
private final Map<String, TextureImpl> playerSkins = Collections.synchronizedMap(new HashMap<>());
private final Map<String, TextureImpl> entityIcons = Collections.synchronizedMap(new HashMap<>());
private final Map<String, TextureImpl> themeImages = Collections.synchronizedMap(new HashMap<>());

private ThreadPoolExecutor texExec = new ThreadPoolExecutor(2, 4, 15L, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(8), new JMThreadFactory("texture"), new ThreadPoolExecutor.CallerRunsPolicy());
Expand Down Expand Up @@ -322,7 +323,7 @@ public TextureImpl getThemeTexture(Theme theme, String iconPath, int width, int
{
if (alpha < 1f || img.getWidth() != width || img.getHeight() != height)
{
BufferedImage tmp = new BufferedImage(width, height, img.getType());
BufferedImage tmp = ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(width, height);
Graphics2D g = tmp.createGraphics();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
Expand Down Expand Up @@ -363,7 +364,7 @@ public TextureImpl getScaledCopy(String texName, TextureImpl original, int width
{
if (alpha < 1f || img.getWidth() != width || img.getHeight() != height)
{
BufferedImage tmp = new BufferedImage(width, height, img.getType());
BufferedImage tmp = ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(width, height);
Graphics2D g = tmp.createGraphics();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
Expand Down Expand Up @@ -424,7 +425,8 @@ public Void call() throws Exception
BufferedImage img = downloadSkin(username);
if (img != null)
{
final BufferedImage scaledImage = new BufferedImage(24, 24, img.getType());
final BufferedImage scaledImage =
ImageTypeSpecifier.createFromRenderedImage(img).createBufferedImage(24, 24);
final Graphics2D g = RegionImageHandler.initRenderingHints(scaledImage.createGraphics());
g.drawImage(img, 0, 0, 24, 24, null);
g.dispose();
Expand Down
Loading