Package overit.geocall.ux.util
Class Picture
java.lang.Object
overit.geocall.servlet.MultipartRaw
overit.geocall.servlet.Raw
overit.geocall.ux.util.Picture
- All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable,Serializable
public class Picture
extends overit.geocall.servlet.Raw
implements Serializable, com.esotericsoftware.kryo.KryoSerializable
This class implements a Picture object
- See Also:
-
Field Summary
FieldsFields inherited from class overit.geocall.servlet.MultipartRaw
_autoCache, _caches, _compression -
Constructor Summary
ConstructorsConstructorDescriptionPicture(byte[] bb) Creates a new Picture object starting from the byte array passed as parameter to obtain a BufferedImagePicture(BufferedImage bi) Creates a new Picture object starting from theBufferedImagepassed as parameterPicture(InputStream is) Creates a new Picture object, reading theInputStreampassed as parameter to obtain a BufferedImage -
Method Summary
Modifier and TypeMethodDescriptionvoidcropAndScale(Color bkg, int x1, int y1, int x2, int y2, int w, int h) Makes the crop and scale transformations on the imageReturns theBufferedImagecreated constructing the Picture objectReturns the format of the Picture object (seesetFormat(java.lang.String, float))intReturns the height of theBufferedImagecreated constructing the Picture objectintgetWidth()Returns the width of theBufferedImagecreated constructing the Picture objectvoidoutput(OutputStream os) Writes the image stream on theOutputStreamvoidread(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) voidSets the format of the Picture objectbyte[]Returns an array of byte of the image element of the Picture objectvoidwrite(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) voidWrites the image into theFilepassed as parameterMethods inherited from class overit.geocall.servlet.Raw
getContentType, output, outputMethods inherited from class overit.geocall.servlet.MultipartRaw
enableCompression, getAutoCache, getCompress, getCompression, output, setAutoCache
-
Field Details
-
_format
-
_quality
protected float _quality
-
-
Constructor Details
-
Picture
Creates a new Picture object, reading theInputStreampassed as parameter to obtain a BufferedImage- Parameters:
is- TheInputStreamto read- Throws:
IOException- If an error occur during reading an exception is raised
-
Picture
Creates a new Picture object starting from the byte array passed as parameter to obtain a BufferedImage- Parameters:
bb- The byte array to read- Throws:
IOException- If an error occur during reading, an exception is raised
-
Picture
Creates a new Picture object starting from theBufferedImagepassed as parameter- Parameters:
bi- TheBufferedImageused to create the object
-
-
Method Details
-
setFormat
Sets the format of the Picture object- Parameters:
format- Can be "png" that is the default value, or "jpg"quality- The compression quality, a float value between 0 and 1; if the format is "png" the quality is lossless
-
getFormat
Returns the format of the Picture object (seesetFormat(java.lang.String, float))- Returns:
- The string that defines the format of the Picture object
-
getBufferedImage
Returns theBufferedImagecreated constructing the Picture object- Returns:
- The
BufferedImage
-
getWidth
public int getWidth()Returns the width of theBufferedImagecreated constructing the Picture object- Returns:
- The int value that defines the width of the Picture
-
getHeight
public int getHeight()Returns the height of theBufferedImagecreated constructing the Picture object- Returns:
- The int value that defines the height of the Picture
-
cropAndScale
public void cropAndScale(Color bkg, int x1, int y1, int x2, int y2, int w, int h) throws IOException Makes the crop and scale transformations on the image- Parameters:
bkg- The background color to use in the toolx1- The first x coordinate for the cropy1- The second x coordinate for the cropx2- The first y coordinate for the cropy2- The second y coordinate for the cropw- The width for the scalingh- The height for the scaling- Throws:
IOException- If an error occur during the transformations, an exception is raised
-
getContentType
- Specified by:
getContentTypein classoverit.geocall.servlet.Raw
-
output
Writes the image stream on theOutputStream- Specified by:
outputin classoverit.geocall.servlet.Raw- Parameters:
os- TheOutputStream- Throws:
IOException- If there is an error, an IOException is thrown
-
toByteArray
Returns an array of byte of the image element of the Picture object- Returns:
- The array of byte of the image element of the Picture object
- Throws:
IOException- If there is an error, an IOException is thrown
-
write
Writes the image into theFilepassed as parameter- Parameters:
f- The file to write- Throws:
IOException- If there is an error in writing, an IOException is thrown
-
write
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) - Specified by:
writein interfacecom.esotericsoftware.kryo.KryoSerializable- Overrides:
writein classoverit.geocall.servlet.MultipartRaw
-
read
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) - Specified by:
readin interfacecom.esotericsoftware.kryo.KryoSerializable- Overrides:
readin classoverit.geocall.servlet.MultipartRaw
-