Allow ItemManager to be ran off the client thread

This allows the ItemManager to return a blank BufferedImage if it's not called on the client thread. This also makes it not render the image until the cache has been downloaded
This commit is contained in:
Max Weber
2018-04-11 03:39:28 -06:00
parent d680c91c19
commit b3fa9a5e49
4 changed files with 146 additions and 14 deletions

View File

@@ -35,12 +35,28 @@ public abstract class RSSpritePixelsMixin implements RSSpritePixels
@Inject
@Override
public BufferedImage toBufferedImage()
{
BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
toBufferedImage(img);
return img;
}
@Inject
@Override
public void toBufferedImage(BufferedImage img)
{
int width = getWidth();
int height = getHeight();
if (img.getWidth() != width || img.getHeight() != height)
{
throw new IllegalArgumentException("Image bounds do not match SpritePixels");
}
int[] pixels = getPixels();
int[] transPixels = new int[pixels.length];
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
for (int i = 0; i < pixels.length; i++)
{
@@ -51,6 +67,5 @@ public abstract class RSSpritePixelsMixin implements RSSpritePixels
}
img.setRGB(0, 0, width, height, transPixels, 0, width);
return img;
}
}