📄 writing image files.htm
字号:
valign="top"><TR valign="top">
<HR>
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>com.sun.media.jai.codec.PNGEncodeParam </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>int filterRow(byte[] currRow, byte[] prevRow,
byte[][] scratchRows, int bytesPerRow, int bytesPerPixel)
<P></P></LI></UL></PRE>
<DL><A name=54138>
<DT>
<DD>returns the type of filtering to be used on a row of an image.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD rowSpan=5><EM>Parameters</EM>:<EM></EM>
<P></P>
<TD><CODE>currRow</CODE>
<P></P>
<TD>The current row as an array of <CODE>byte</CODE>s of length at
least <CODE>bytesPerRow</CODE> + <CODE>bytesPerPixel</CODE>. The pixel
data starts at index <CODE>bytesPerPixel</CODE>; the initial
<CODE>bytesPerPixel</CODE> bytes are zero.
<P></P>
<TR vAlign=top>
<TD><CODE>prevRow</CODE>
<P></P>
<TD>The current row as an array of <CODE>byte</CODE>s. The pixel data
starts at index <CODE>bytesPerPixel</CODE>; the initial
<CODE>bytesPerPixel</CODE> bytes are zero.
<P></P>
<TR vAlign=top>
<TD><CODE>scratchRows</CODE>
<P></P>
<TD>An array of 5 <CODE>byte</CODE> arrays of length at least
<CODE>bytesPerRow</CODE> + <CODE>bytesPerPixel</CODE>, usable to hold
temporary results. The filtered row will be returned as one of the
entries of this array. The returned filtered data should start at
index <CODE>bytesPerPixel</CODE>; The initial
<CODE>bytesPerPixel</CODE> bytes are not used.
<P></P>
<TR vAlign=top>
<TD><CODE>bytesPerRow</CODE>
<P></P>
<TD>The number of bytes in the image row. This value will always be
greater than 0.
<P></P>
<TR vAlign=top>
<TD><CODE>bytesPerPixel</CODE>
<P></P>
<TD>The number of bytes representing a single pixel, rounded up to an
integer. This is the <CODE>bpp</CODE> parameter described in the PNG
specification.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><A name=53673>
<H3>13.6.3 <IMG src="Writing Image Files.files/space.gif">Bit
Depth</H3></A>The PNG specification identifies the following bit depth
restrictions for each of the color types:
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B><A name=53677><I>Table 13-4 </I><IMG
src="Writing Image Files.files/sm-blank.gif" border=0> PNG Bit Depth
Restrictions </A></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TH><A name=53683>Color Type </A>
<TH><A name=53685>Allowed Bit Depths </A>
<TH><A name=53687>Description </A>
<TR vAlign=top>
<TD><A name=53689>0</A><BR>
<TD><A name=53691>1, 2, 4, 8, 16</A><BR>
<TD><A name=53693>Grayscale. Each pixel is a grayscale sample.</A><BR>
<TR vAlign=top>
<TD><A name=53695>2</A><BR>
<TD><A name=53697>8, 16</A><BR>
<TD><A name=53699>Truecolor (RGB) without alpha. Each pixel is an RGB
triple.</A><BR>
<TR vAlign=top>
<TD><A name=53701>3</A><BR>
<TD><A name=53703>1, 2, 4, 8</A><BR>
<TD><A name=53705>Indexed color (Palette). Each pixel is a palette
index.</A><BR>
<TR vAlign=top>
<TD><A name=53707>4</A><BR>
<TD><A name=53709>8, 16</A><BR>
<TD><A name=53711>Grayscale with alpha. Each pixel is a grayscale sample
followed by an alpha sample.</A><BR>
<TR vAlign=top>
<TD><A name=53713>6</A><BR>
<TD><A name=53715>8, 16</A><BR>
<TD><A name=53717>Truecolor (RGB) with alpha. Each pixel is an RGB
triple followed by an alpha sample.</A><BR></TR></TBODY></TABLE>
<P>The bit depth is specified by the <CODE>setBithDepth</CODE> method in the
class type.
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>com.sun.media.jai.codec.PNGEncodeParam.Palette </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>void setBitDepth(int bitDepth)
<P></P></LI></UL></PRE>
<DL><A name=53723>
<DT>
<DD>sets the desired bit depth for a palette image. The bit depth must be 1,
2, 4, or 8. </A>
<P></P></DD></DL>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>com.sun.media.jai.codec.PNGEncodeParam.Gray </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>public void setBitDepth(int bitDepth)
<P></P></LI></UL></PRE>
<DL><A name=57396>
<DT>
<DD>sets the desired bit depth for a grayscale image. The bit depth must be
1, 2, 4, 8, or 16. </A>
<P></P></DD></DL>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>com.sun.media.jai.codec.PNGEncodeParam.RGB </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>void setBitDepth(int bitDepth)
<P></P></LI></UL></PRE>
<DL><A name=53729>
<DT>
<DD>sets the desired bit depth for an RGB image. The bit depth must be 8 or
16. </A>
<P></P></DD></DL><A name=53730>
<H3>13.6.4 <IMG src="Writing Image Files.files/space.gif">Interlaced Data
Order</H3></A>The interlaced data order indicates the transmission order of
the image data. Two settings are currently allowed: no interlace and Adam7
interlace. With interlacing turned off, pixels are stored sequentially from
left to right, and scanlines sequentially from top to bottom. Adam7
interlacing (named after its author, Adam M. Costello), consists of seven
distinct passes over the image; each pass transmits a subset of the pixels in
the image.
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>com.sun.media.jai.codec.PNGEncodeParam </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>void setInterlacing(boolean useInterlacing)
<P></P></LI></UL></PRE>
<DL><A name=53736>
<DT>
<DD>turns Adam7 interlacing on or off. </A>
<P></P></DD></DL><PRE><UL>
<LI>boolean getInterlacing()
<P></P></LI></UL></PRE>
<DL><A name=53738>
<DT>
<DD>returns <CODE>true</CODE> if Adam7 interlacing will be used. </A>
<P></P></DD></DL><A name=53779>
<H3>13.6.5 <IMG src="Writing Image Files.files/space.gif">PLTE Chunk for
Palette Images</H3></A>The PLTE chunk provides the palette information palette
or indexed-color images. The PLTE chunk must be supplied for all palette
(color type 3) images and is optional for RGB (color type 2 and 6) images.
<P>The PLTE chunk contains from 1 to 256 palette entries, each a three-byte
series of the alternating red, green, and blue values, as follows:
<P>
<UL>
<LI>Red: one byte (0 = black, 255 = red)
<P></P></LI></UL>
<UL>
<LI>Green: one byte (0 = black, 255 = green)
<P></P></LI></UL>
<UL>
<LI>Blue: one byte (0 = black, 255 = blue)
<P></P></LI></UL>The number of elements in the palette must be a multiple of
3, between 3 and 768 (3 x 256). The first entry in the palette is referenced
by pixel value 0, the second by pixel value 1, and so on.
<P>For RGB (color type 2 and 6) images, the PLTE chunk, if included, provides
a suggested set of from 1 to 256 colors to which the RGB image can be
quantized in case the viewing system cannot display RGB directly.
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>com.sun.media.jai.codec.PNGEncodeParam </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>void setPalette(int[] rgb)
<P></P></LI></UL></PRE>
<DL><A name=53819>
<DT>
<DD>sets the RGB palette of the image to be encoded.
<P>
<TABLE cellPadding=3 border=3>
<CAPTION><FONT size=-1><B></B></FONT></CAPTION>
<TBODY>
<TR vAlign=top>
<TD><EM>Parameters</EM>:<EM></EM>
<P></P>
<TD><CODE>rgb</CODE>
<P></P>
<TD>An array of <CODE>int</CODE>s.
<P></P></TR></TBODY></TABLE></A>
<P></P></DD></DL><PRE><UL>
<LI>int[] getPalette()
<P></P></LI></UL></PRE>
<DL><A name=53855>
<DT>
<DD>returns the current RGB palette. </A>
<P></P></DD></DL><PRE><UL>
<LI>void unsetPalette()
<P></P></LI></UL></PRE>
<DL><A name=53865>
<DT>
<DD>suppresses the PLTE chunk from being output. </A>
<P></P></DD></DL><PRE><UL>
<LI>boolean isPaletteSet()
<P></P></LI></UL></PRE>
<DL><A name=53875>
<DT>
<DD>returns true if a PLTE chunk will be output. </A>
<P></P></DD></DL><A name=53197>
<H3>13.6.6 <IMG src="Writing Image Files.files/space.gif">Ancillary Chunk
Specifications</H3></A>All ancillary PNG chunks are optional but are
recommended. Most of the PNG chunks can be specified prior to encoding the
image by <CODE>set</CODE> methods in the <CODE>PNGEncodeParam</CODE> class.
The chunks that can be set and the methods used to set them are described in
the following paragraphs.
<P><A name=51917>
<H4>13.6.6.1 <IMG src="Writing Image Files.files/space.gif">Background Color
(bKGD Chunk)</H4></A>Methods are provided to set and read the suggested
background color, which is encoded by the bKGD chunk.
<P>For Palette (indexed color) images, the bKGD chunk contains a single value,
which is the palette index of the color to be used as the background.
<P>For Grayscale images, the bKGD chunk contains a single value, which is the
gray level to be used as the background. The range of values is 0 to
2<SUP>bitdepth</SUP> - 1.
<P>For RGB (truecolor) images, the bKGD chunk contains three values, one each
for red, green, and blue. Each value has the range of 0 to
2<SUP>bitdepth</SUP> - 1.
<P>
<TABLE border=0>
<TBODY>
<TR>
<TD><IMG src="Writing Image Files.files/cistine.gif"></TD>
<TD>
<HR>
<B>API:</B> <CODE>com.sun.media.jai.codec.PNGEncodeParam.Palette </CODE>
<HR>
</TD></TR></TBODY></TABLE><PRE><UL>
<LI>void setBackgroundPaletteIndex(int index)
<P></P></LI></UL></PRE>
<DL><A name=51955>
<DT>
<DD>sets the palette index of the suggested background color. </A>
<P></P></DD></
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -