上个星期我的leader就要我看 这个东西了,由于一个星期都在做项目上的东西,没时间看,今天终于把那个事情完结了。。
来脑补一下这个事情:
他们项目组的JDK原来是JDK1.6,现在要用JDK1.7,然后呢,图像处理这一块有点问题。
JDK1.7将encoder,decoder类删除掉了,所以呢代码就有问题了,就要我帮助他们改一改。
今天终于好了!
言归正传,了解下JDK1.7和JDK1.6的差别吧:
encoder --> 写 write
decoder --> 读 read
static BufferedImage | read(File input)
Returns a
BufferedImage as the result of decoding a supplied
File with an
ImageReader chosen automatically from among those currently registered.
|
static BufferedImage | read(ImageInputStream stream)
Returns a
BufferedImage as the result of decoding a supplied
ImageInputStream with an
ImageReader chosen automatically from among those currently registered.
|
static BufferedImage | read(InputStream input)
Returns a
BufferedImage as the result of decoding a supplied
InputStream with an
ImageReader chosen automatically from among those currently registered.
|
static BufferedImage | read(URL input)
Returns a
BufferedImage as the result of decoding a supplied
URL with an
ImageReader chosen automatically from among those currently registered.
|
-
read
public static BufferedImage read(ImageInputStream stream) throws IOException
Returns aBufferedImage
as the result of decoding a suppliedImageInputStream
with anImageReader
chosen automatically from among those currently registered. If no registeredImageReader
claims to be able to read the stream,null
is returned.Unlike most other methods in this class, this method does close the provided
ImageInputStream
after the read operation has completed, unlessnull
is returned, in which case this method does not close the stream.-
Parameters:
-
stream
- anImageInputStream
to read from.
Returns:
-
a
BufferedImage
containing the decoded contents of the input, ornull
.
Throws:
-
IllegalArgumentException
- ifstream
isnull
. -
IOException
- if an error occurs during reading.
-
static boolean | write(RenderedImage im, String formatName, File output)
Writes an image using an arbitrary
ImageWriter that supports the given format to a
File .
|
static boolean | write(RenderedImage im, String formatName, ImageOutputStream output)
Writes an image using the an arbitrary
ImageWriter that supports the given format to an
ImageOutputStream .
|
static boolean | write(RenderedImage im, String formatName, OutputStream output)
Writes an image using an arbitrary
ImageWriter that supports the given format to an
OutputStream .
|
-
public static boolean write(RenderedImage im, String formatName, File output) throws IOException
Writes an image using an arbitraryImageWriter
that supports the given format to aFile
. If there is already aFile
present, its contents are discarded.-
Parameters:
-
im
- aRenderedImage
to be written. -
formatName
- aString
containg the informal name of the format. -
output
- aFile
to be written to.
Returns:
-
false
if no appropriate writer is found.
Throws:
-
IllegalArgumentException
- if any parameter isnull
. -
IOException
- if an error occurs during writing.
-