|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.mimetypes.image.ImageSizer
A class which is capable of reading an image and spitting out its
size. Child classes should implement the computeImageSize(java.lang.String)
method
in order to provide image-format-specific functionality.
This class and its subclasses are used in the
MimeType
class.
Note that the only legal way to obtain an instance of this class
is to call ImageSizerFactory.getImageSizer(java.lang.String)
Field Summary | |
static String |
versionId
|
Constructor Summary | |
protected |
ImageSizer()
This constructor is protected since the only way to get an instance of the ImageSizer is to call ImageSizerFactory.getImageSizer(java.lang.String) |
Method Summary | |
Dimension |
computeImageSize(File file)
Construct a new ImageSizer. |
Dimension |
computeImageSize(String path)
Read a file from the filesystem and try to determine its size |
abstract Dimension |
computeSize(DataInputStream in)
Read the input stream, determine the size of the image, and return it |
static Dimension |
getScaledSize(Dimension d,
int maxWidth,
int maxHeight)
Scale width and height down to fit within the specified dimensions. |
static Dimension |
getScaledSize(int width,
int height,
int maxWidth,
int maxHeight)
Scale the specified dimensions down to fit within the maximum dimensions. |
protected static short |
toShort(byte highOrder,
byte lowOrder)
Utility method to convert 2 bytes to a short integer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
protected ImageSizer()
ImageSizerFactory.getImageSizer(java.lang.String)
Method Detail |
public Dimension computeImageSize(String path) throws IOException
path
- The path of the file to read
Dimension
which will hold the size of an image
IOException
public Dimension computeImageSize(File file) throws IOException
file
- The fike to read
IOException
public static Dimension getScaledSize(Dimension d, int maxWidth, int maxHeight)
d
- a Dimension
which holds the size of the imagemaxWidth
- the maximum widthmaxHeight
- the maximum heightpublic static Dimension getScaledSize(int width, int height, int maxWidth, int maxHeight)
width
- The current widthheight
- The current heightmaxWidth
- the maximum widthmaxHeight
- the maximum heightpublic abstract Dimension computeSize(DataInputStream in) throws IOException
in
- The InputStream to read
IOException
protected static short toShort(byte highOrder, byte lowOrder)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |