Package net.risingworld.api.objects
Class CustomImage
java.lang.Object
net.risingworld.api.objects.CustomImage
Represents a custom image (i.e a "poster").
Example: Find out who uploaded a particular custom image
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets an SHA1 hash of the raw image texture data.long
Gets the creation/upload date of the image as a timestamp in millisecondsGets the extension of the original image file (e.g ".png" or ".jpg" etc).int
Gets the height of the texture.long
getID()
Gets the global, unique ID of the custom image.long
Gets a timestamp in milliseconds representing the time when the last access to this image occurred.getName()
Gets the original file name of the image.int
Gets the database ID of the player who uploaded this image.byte[]
Gets the raw texture data, depending on the texture format (seegetTextureFormat()
).Gets the internal texture format.int[]
Gets the image pixel data.int
getWidth()
Gets the width of the texture.boolean
isValid()
Checks if this instance is still valid.void
setRawTextureData
(int width, int height, String format, byte[] data) Sets the raw texture data.
-
Method Details
-
getID
public long getID()Gets the global, unique ID of the custom image.- Returns:
- the unique image ID.
-
isValid
public boolean isValid()Checks if this instance is still valid.- Returns:
- true if the instance is valid, false if not.
-
getPlayerDbID
public int getPlayerDbID()Gets the database ID of the player who uploaded this image.- Returns:
- the player database ID who uploaded the image, or -1 if this image was not uploaded by a player.
-
getName
Gets the original file name of the image.- Returns:
- the original image file name.
-
getExtension
Gets the extension of the original image file (e.g ".png" or ".jpg" etc).- Returns:
- the original image extension.
-
getChecksum
Gets an SHA1 hash of the raw image texture data.- Returns:
- the checksum of the texture data.
-
getWidth
public int getWidth()Gets the width of the texture.- Returns:
- the texture width in pixels.
-
getHeight
public int getHeight()Gets the height of the texture.- Returns:
- the texture height in pixels.
-
getTextureFormat
Gets the internal texture format. Typically images are compressed, so the format is usually DXT1 (for images without alpha channel) or DXT5.- Returns:
- the internal texture format.
-
getCreationDate
public long getCreationDate()Gets the creation/upload date of the image as a timestamp in milliseconds- Returns:
- a timestamp (milliseconds) representing the original upload date of the image.
-
getLastAccess
public long getLastAccess()Gets a timestamp in milliseconds representing the time when the last access to this image occurred. Access via API is not taken into account.- Returns:
- a timestamp (milliseconds) representing the last access date of the image (e.g when a player requested the image etc).
-
getRawTextureData
public byte[] getRawTextureData()Gets the raw texture data, depending on the texture format (seegetTextureFormat()
). It typically also contains mipmaps.- Returns:
- the raw texture data.
-
setRawTextureData
Sets the raw texture data. It's highly recommendable to use a compressed texture format like DXT1 or DXT5.- Parameters:
width
- the new width of the texture.height
- the new height of the texture.format
- the texture data format.data
- the raw texture data.- Example: Copy texture data from one image to another
-
getTexturePixelData
public int[] getTexturePixelData()Gets the image pixel data. Note: This is a rather expensive call (because it internally parses and converts the texture data first), so it's recommendable to call this once and cache the result!- Returns:
- an int array containing the RGBA pixel data.
-