Package pl.edu.icm.unity.attr
Class UnityImage
java.lang.Object
pl.edu.icm.unity.attr.UnityImage
Class providing Image related information and operations.
Currently supports JPG, GIF and PNG image types.
- Author:
- R. Ledzinski
-
Constructor Summary
ConstructorDescriptionUnityImage
(byte[] rawData, ImageType type) UnityImage
(BufferedImage bufferedImage, ImageType type) UnityImage
(String serializedObject) UnityImage
(Path path) -
Method Summary
Modifier and TypeMethodDescriptionvoid
deserialize
(String stringRepresentation) int
byte[]
getImage()
byte[]
getScaledDownImage
(int maxWidth, int maxHeight) Recreate the image to match given maximum width and height keeping current aspect ratio.getType()
int
getWidth()
void
scaleDown
(int maxWidth, int maxHeight) Recreate the image to match given maximum width and height keeping current aspect ratio.void
Updates object's fields, if given buffer contains data that may be converted to image.
-
Constructor Details
-
UnityImage
- Throws:
IOException
-
UnityImage
-
UnityImage
-
UnityImage
- Throws:
IOException
-
-
Method Details
-
getImage
public byte[] getImage() -
getScaledDownImage
public byte[] getScaledDownImage(int maxWidth, int maxHeight) Recreate the image to match given maximum width and height keeping current aspect ratio. If image already fits the size no action in taken. Method returns new byte array - current object is not modified.- Parameters:
maxWidth
-maxHeight
-
-
getBufferedImage
-
getType
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
setImage
Updates object's fields, if given buffer contains data that may be converted to image. If not possible to convert object remains unchanged.- Parameters:
image
- Byte array containing image data.
-
scaleDown
public void scaleDown(int maxWidth, int maxHeight) Recreate the image to match given maximum width and height keeping current aspect ratio. If image already fits the size no action in taken.- Parameters:
maxWidth
-maxHeight
-
-
serialize
-
deserialize
- Throws:
IOException
-