Package de.jcm.discordgamesdk
Class ImageManager
java.lang.Object
de.jcm.discordgamesdk.ImageManager
Manager to receive information about images and the image data itself.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidfetch(ImageHandle handle, boolean refresh, BiConsumer<Result, ImageHandle> callback) Prepares an image to later retrieve it.getAsBufferedImage(ImageHandle handle) Obtains the image dimensions fromgetDimensions(ImageHandle)and then constructs aBufferedImageusinggetAsBufferedImage(ImageHandle, ImageDimensions).getAsBufferedImage(ImageHandle handle, ImageDimensions dimensions) Deprecated.byte[]getData(ImageHandle handle, int length) Gets the image data for a given image.byte[]getData(ImageHandle handle, ImageDimensions dimensions) Gets the image data for a given image.getDimensions(ImageHandle handle) Fetches the dimensions (size) of an image.
-
Method Details
-
fetch
Prepares an image to later retrieve it.- Parameters:
handle- Handle identifying the imagerefresh- whether to refresh the (possibly) cached imagecallback- Callback to handle result and returned handle- See Also:
-
getDimensions
Fetches the dimensions (size) of an image.- Parameters:
handle- Handle identifying the image- Returns:
- The fetches dimensions
- Throws:
GameSDKException- if something went wrong fetching the image dimensions- See Also:
-
getData
Gets the image data for a given image.
The data is automatically put in a Java byte array.
The length of this array and thus the length of the allocated space is automatically calculated based on the dimensions.
- Parameters:
handle- Handle identifying the imagedimensions- Dimensions of the image- Returns:
- The image data
- Throws:
GameSDKException- if something went wrong fetching the image data- See Also:
-
getData
Gets the image data for a given image.
The data is automatically put in a Java byte array of the given length.
Prefer
getData(ImageHandle, ImageDimensions)and retrieve the dimensions withgetDimensions(ImageHandle).- Parameters:
handle- Handle identifying the imagelength- Length of the image data, should bewidth*height*4- Returns:
- The image data
- Throws:
GameSDKException- if something went wrong fetching the image data- See Also:
-
getAsBufferedImage
Deprecated.Gets the image data for a give image with
getData(ImageHandle, ImageDimensions)and writes it into aBufferedImage's raster.- Parameters:
handle- Handle identifying the imagedimensions- Dimensions of the image- Returns:
- A BufferedImage containing the image data
- Throws:
GameSDKException- if something went wrong fetching the image data
-
getAsBufferedImage
Obtains the image dimensions from
getDimensions(ImageHandle)and then constructs aBufferedImageusinggetAsBufferedImage(ImageHandle, ImageDimensions).- Parameters:
handle- Handle identifying the image- Returns:
- A BufferedImage containing the image data
- Throws:
GameSDKException- if something went wrong fetching the image dimensions or data
-