runelite-client: Use BufferedImage where applicable
All of these places would crash at runtime should they be given a non-buffered image due to calling methods without a null ImageObserver
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
package net.runelite.client.plugins.cooking;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -37,7 +37,7 @@ final class FermentTimer extends InfoBox
|
||||
|
||||
private Instant fermentTime;
|
||||
|
||||
FermentTimer(Image image, Plugin plugin)
|
||||
FermentTimer(BufferedImage image, Plugin plugin)
|
||||
{
|
||||
super(image, plugin);
|
||||
reset();
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.client.plugins.statusbars;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MenuEntry;
|
||||
@@ -83,7 +83,7 @@ class StatusBarsOverlay extends Overlay
|
||||
private final TextComponent textComponent = new TextComponent();
|
||||
private final ItemStatChangesService itemStatService;
|
||||
|
||||
private final Image prayerImage;
|
||||
private final BufferedImage prayerImage;
|
||||
|
||||
@Inject
|
||||
private StatusBarsOverlay(Client client, StatusBarsConfig config, SkillIconManager skillIconManager, ItemStatChangesService itemstatservice)
|
||||
@@ -225,7 +225,7 @@ class StatusBarsOverlay extends Overlay
|
||||
|
||||
if (config.enableSkillIcon() || config.enableCounter())
|
||||
{
|
||||
final Image healthImage = skillIconManager.getSkillImage(Skill.HITPOINTS, true);
|
||||
final BufferedImage healthImage = skillIconManager.getSkillImage(Skill.HITPOINTS, true);
|
||||
final int counterHealth = client.getBoostedSkillLevel(Skill.HITPOINTS);
|
||||
final int counterPrayer = client.getBoostedSkillLevel(Skill.PRAYER);
|
||||
final String counterHealthText = Integer.toString(counterHealth);
|
||||
@@ -294,7 +294,7 @@ class StatusBarsOverlay extends Overlay
|
||||
return (int) Math.round(ratio * size);
|
||||
}
|
||||
|
||||
private void renderIconsAndCounters(Graphics2D graphics, int x, int y, Image image, String counterText, int counterPadding)
|
||||
private void renderIconsAndCounters(Graphics2D graphics, int x, int y, BufferedImage image, String counterText, int counterPadding)
|
||||
{
|
||||
final int widthOfCounter = graphics.getFontMetrics().stringWidth(counterText);
|
||||
final int centerText = (WIDTH - PADDING) / 2 - (widthOfCounter / 2);
|
||||
|
||||
@@ -29,9 +29,9 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
@@ -53,7 +53,7 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
|
||||
private String text;
|
||||
private Color color = Color.WHITE;
|
||||
private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR;
|
||||
private Image image;
|
||||
private BufferedImage image;
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
package net.runelite.client.ui.overlay.infobox;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -38,11 +38,11 @@ public abstract class InfoBox
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Image image;
|
||||
private BufferedImage image;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private Image scaledImage;
|
||||
private BufferedImage scaledImage;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter
|
||||
@@ -52,7 +52,7 @@ public abstract class InfoBox
|
||||
@Setter
|
||||
private String tooltip;
|
||||
|
||||
public InfoBox(Image image, Plugin plugin)
|
||||
public InfoBox(BufferedImage image, Plugin plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
setImage(image);
|
||||
|
||||
@@ -27,7 +27,6 @@ package net.runelite.client.ui.overlay.infobox;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -126,8 +125,8 @@ public class InfoBoxManager
|
||||
}
|
||||
|
||||
// Set scaled InfoBox image
|
||||
final Image image = infoBox.getImage();
|
||||
Image resultImage = image;
|
||||
final BufferedImage image = infoBox.getImage();
|
||||
BufferedImage resultImage = image;
|
||||
final double width = image.getWidth(null);
|
||||
final double height = image.getHeight(null);
|
||||
final double size = Math.max(2, runeLiteConfig.infoBoxSize()); // Limit size to 2 as that is minimum size not causing breakage
|
||||
|
||||
Reference in New Issue
Block a user