Interface ImageServletResponse
-
- All Superinterfaces:
javax.servlet.ServletResponse
public interface ImageServletResponse extends javax.servlet.ServletResponseImageServletResponse.The request attributes regarding image size and source region (AOI) are used in the decoding process, and must be set before the first invocation of
getImage()to have any effect.- Version:
- $Id: ImageServletResponse.java#4 $
- Author:
- Harald Kuhr
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringATTRIB_AOIRequest attribute of typeRectanglecontrolling image source region (area of interest).static java.lang.StringATTRIB_AOI_PERCENTRequest attribute of typeBooleancontrolling image AOI.static java.lang.StringATTRIB_AOI_UNIFORMRequest attribute of typeBooleancontrolling image AOI.static java.lang.StringATTRIB_BG_COLORRequest attribute of typeColorcontrolling background color for any transparent/translucent areas of the image.static java.lang.StringATTRIB_IMAGE_RESAMPLE_ALGORITHMRequest attribute of typeIntegercontrolling image resample algorithm.static java.lang.StringATTRIB_OUTPUT_QUALITYRequest attribute of typeFloatcontrolling image output compression/quality.static java.lang.StringATTRIB_READ_SUBSAMPLING_FACTORRequest attribute of typeDoublecontrolling image read subsampling factor.static java.lang.StringATTRIB_SIZERequest attribute of typeDimensioncontrolling image size.static java.lang.StringATTRIB_SIZE_PERCENTRequest attribute of typeBooleancontrolling image sizing.static java.lang.StringATTRIB_SIZE_UNIFORMRequest attribute of typeBooleancontrolling image sizing.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidflush()Writes the image to the originalServletOutputStream.java.awt.image.BufferedImagegetImage()Gets the decoded image from the response.java.lang.StringgetOutputContentType()Gets the image format for this response, such as "image/gif" or "image/jpeg".voidsetImage(java.awt.image.RenderedImage pImage)Sets the image for this response.voidsetOutputContentType(java.lang.String pImageFormat)Sets the image format for this response, such as "image/gif" or "image/jpeg".-
Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale
-
-
-
-
Field Detail
-
ATTRIB_SIZE
static final java.lang.String ATTRIB_SIZE
Request attribute of typeDimensioncontrolling image size. If eitherwidthorheightis negative, the size is computed, using uniform scaling. Else, ifSIZE_UNIFORMistrue, the size will be computed to the largest possible area (with correct aspect ratio) fitting inside the target area. Otherwise, the image is scaled to the given size, with no regard to aspect ratio.Defaults to
null(original image size).- See Also:
- Constant Field Values
-
ATTRIB_SIZE_UNIFORM
static final java.lang.String ATTRIB_SIZE_UNIFORM
Request attribute of typeBooleancontrolling image sizing.Defaults to
Boolean.TRUE.- See Also:
- Constant Field Values
-
ATTRIB_SIZE_PERCENT
static final java.lang.String ATTRIB_SIZE_PERCENT
Request attribute of typeBooleancontrolling image sizing.Defaults to
Boolean.FALSE.- See Also:
- Constant Field Values
-
ATTRIB_AOI
static final java.lang.String ATTRIB_AOI
Request attribute of typeRectanglecontrolling image source region (area of interest).Defaults to
null(the entire image).- See Also:
- Constant Field Values
-
ATTRIB_AOI_UNIFORM
static final java.lang.String ATTRIB_AOI_UNIFORM
Request attribute of typeBooleancontrolling image AOI.Defaults to
Boolean.FALSE.- See Also:
- Constant Field Values
-
ATTRIB_AOI_PERCENT
static final java.lang.String ATTRIB_AOI_PERCENT
Request attribute of typeBooleancontrolling image AOI.Defaults to
Boolean.FALSE.- See Also:
- Constant Field Values
-
ATTRIB_BG_COLOR
static final java.lang.String ATTRIB_BG_COLOR
Request attribute of typeColorcontrolling background color for any transparent/translucent areas of the image.Defaults to
null(keeps the transparent areas transparent).- See Also:
- Constant Field Values
-
ATTRIB_OUTPUT_QUALITY
static final java.lang.String ATTRIB_OUTPUT_QUALITY
Request attribute of typeFloatcontrolling image output compression/quality. Used for formats that accepts compression or quality settings, like JPEG (quality), PNG (compression only) etc.Defaults to
0.8ffor JPEG.- See Also:
- Constant Field Values
-
ATTRIB_READ_SUBSAMPLING_FACTOR
static final java.lang.String ATTRIB_READ_SUBSAMPLING_FACTOR
Request attribute of typeDoublecontrolling image read subsampling factor. Controls the maximum sample pixels in each direction, that is read per pixel in the output image, if the result will be downscaled. Larger values will result in better quality, at the expense of higher memory consumption and CPU usage. However, using values above3.0will usually not improve image quality. Legal values are in the range[1.0 .. positive infinity>.Defaults to
2.0.- See Also:
- Constant Field Values
-
ATTRIB_IMAGE_RESAMPLE_ALGORITHM
static final java.lang.String ATTRIB_IMAGE_RESAMPLE_ALGORITHM
Request attribute of typeIntegercontrolling image resample algorithm. Legal values areSCALE_DEFAULT,SCALE_FASTorSCALE_SMOOTH.Note: When using a value of
SCALE_FAST, you should also use a subsampling factor of1.0, for fast read/scale. Otherwise, use a subsampling factor of2.0for better quality.Defaults to
SCALE_DEFAULT.- See Also:
- Constant Field Values
-
-
Method Detail
-
getOutputContentType
java.lang.String getOutputContentType()
Gets the image format for this response, such as "image/gif" or "image/jpeg". If not set, the default format is that of the original image.- Returns:
- the image format for this response.
- See Also:
setOutputContentType(String)
-
setOutputContentType
void setOutputContentType(java.lang.String pImageFormat)
Sets the image format for this response, such as "image/gif" or "image/jpeg".As an example, a custom filter could do content negotiation based on the request header fields and write the image back in an appropriate format.
If not set, the default format is that of the original image.
- Parameters:
pImageFormat- the image format for this response.
-
flush
void flush() throws java.io.IOExceptionWrites the image to the originalServletOutputStream. If no format is set in this response, the image is encoded in the same format as the original image.- Throws:
java.io.IOException- if an I/O exception occurs during writing
-
getImage
java.awt.image.BufferedImage getImage() throws java.io.IOExceptionGets the decoded image from the response.- Returns:
- a
BufferedImageornullif the image could not be read. - Throws:
java.io.IOException- if an I/O exception occurs during reading
-
setImage
void setImage(java.awt.image.RenderedImage pImage)
Sets the image for this response.- Parameters:
pImage- the new response image.
-
-