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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user