⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pngimage.java

📁 手机模拟器源代码,可以在网页上调用applet应用来摸拟手机,在线体验手机游戏和运用.可以在网页上自定义手机外观.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        return data.header.depth;    }    /**      * Gets the interlacing method used by this image.     * @see #getProperty     * @return one of the INTERLACE_TYPE_* constants.     */    public int getInterlaceType()    throws IOException {        readToData();        return data.header.interlace;     }    /**     * Gets the alpha and color properties of an image.     * An image can either be grayscale, grayscale with alpha channel,     * RGB, RGB with alpha channel, or paletted.     * @see #getProperty     * @return COLOR_TYPE_GRAY<br>     *         COLOR_TYPE_GRAY_ALPHA<br>     *         COLOR_TYPE_PALETTE<br>     *         COLOR_TYPE_RGB<br>     *         COLOR_TYPE_RGB_ALPHA     */    public int getColorType()    throws IOException    {        readToData();        return data.header.colorType;    }    /**      * Returns true if the image has an alpha channel.     * @see #getProperty     * @see #getColorType     */    public boolean hasAlphaChannel()    throws IOException    {        readToData();        return data.header.alphaUsed;     }    /**      * Returns true if the image is grayscale.     * @see #getProperty     * @see #getColorType     */    public boolean isGrayscale()    throws IOException    {        readToData();        return !data.header.colorUsed;    }    /**      * Returns true if the image is paletted.     * @see #getProperty     * @see #getColorType     */    public boolean isIndexedColor()    throws IOException    {        readToData();        return data.header.paletteUsed;    }    /**     * Gets a property of this image by name. If a property is not      * defined for a particular image, this method returns <code>null</code>.     * <p>     * <b>Note:</b> This method will only read up to the beginning of     * the image data unless the image data has already been read,     * either through the consumer/producer interface or by calling     * <code>getEverything</code>.     * <p>     * The following properties are guaranteed to be defined:     * <p>     * <center><table border=1 cellspacing=0 cellpadding=4 width="80%">     * <tr bgcolor="#E0E0E0"><td nowrap><b>Name</b></td><td nowrap><b>Type</b></td>     *     <td><b>Description</b></td></tr>     * <tr><td nowrap>"width"</td><td nowrap><code>Integer</code></td>     *     <td>Image width in pixels</td></tr>     * <tr><td nowrap>"height"</td><td nowrap><code>Integer</code></td>     *     <td>Image height in pixels</td></tr>     * <tr><td nowrap>"interlace type"</td><td nowrap><code>Integer</code></td>     *     <td>See <a href="#getInterlaceType">getInterlaceType</a></td></tr>     * <tr><td nowrap>"compression type"</td><td nowrap><code>Integer</code></td>     *     <td><code>COMPRESSION_TYPE_BASE</code></td></tr>     * <tr><td nowrap>"filter type"</td><td nowrap><code>Integer</code></td>     *     <td><code>FILTER_TYPE_BASE</code></td></tr>     * <tr><td nowrap>"color type"</td><td nowrap><code>Integer</code></td>     *     <td>See <a href="#getColorType">getColorType</a></td></tr>     * <tr><td nowrap>"bit depth"</td><td nowrap><code>Integer</code></td>     *     <td>1, 2, 4, 8, or 16 <sup><a href="#fn1">(1)</a></sup></td></tr>     * <tr><td nowrap>"gamma"</td><td nowrap><code>Long</code></td>     *     <td>File gamma * 100000 <sup><a href="#fn2">(2)</a></sup></td></tr>     * <tr valign=top><td nowrap>"significant bits"</td><td nowrap><code>byte[]</code></td>     *     <td>Significant bits per component: <br><nowrap><code>[r,g,b]</code></nowrap> or <nowrap><code>[r,g,b,alpha]</code></nowrap> <sup><a href="#fn3">(3)</a></sup></td></tr>     * </table></center>     * <center><table border=0 cellspacing=0 cellpadding=4 width="80%">     * <tr><td><b><sup><a name="fn1">1</a></sup></b> 16-bit pixel components are reduced to 8 bits<br>     *         <b><sup><a name="fn2">2</a></sup></b> Uses value from <code>sRGB</code> or <code>gAMA</code> chunks,      *         or default (<code>45455</code>)<br>     *         <b><sup><a name="fn3">3</a></sup></b> For grayscale images, <code>r == g == b</code></td></tr>     * </table></center>     * <p>     * The following properties are optional:<p>     * <center><table border=1 cellspacing=0 cellpadding=4 width="80%">     * <tr bgcolor="#E0E0E0"><td nowrap><b>Name</b></td><td nowrap><b>Type</b></td>     *     <td><b>Description</b></td></tr>     * <tr valign=top><td nowrap>"palette"</td><td nowrap><code>int[][]</td>     *     <td>Palette or suggested palette (PLTE chunk):<br>     *     <nowrap><code>[r,g,b][entry]</code></nowrap> or <nowrap><code>[r,g,b][entry]</code></nowrap></td></tr>     * <tr><td nowrap>"palette size"</td><td nowrap><code>Integer</td>     *     <td>Size of palette, 1 - 256</td></tr>     * <tr valign=top><td nowrap>"histogram"</td><td nowrap><code>int[]</td>     *     <td>Palette entry usage frequency</td></tr>     * <tr><td nowrap>"background"</td><td nowrap><code>java.awt.Color</td>     *     <td>Suggested background color</td></tr>     * <tr><td nowrap>"background low bytes"</td><td nowrap><code>java.awt.Color</td>     *     <td>The low (least significant) bytes of a 16-bit background color</td></tr>     * <tr><td nowrap>"background index"</td><td nowrap><code>Integer</td>     *     <td>The palette index of the suggested background color</td></tr>     * <tr><td nowrap>"time"</td><td nowrap><code>java.util.Date</code></td>     *     <td>Time of last image modification</td></tr>     * <tr><td nowrap>"pixel dimensions x"</td><td nowrap><code>Long</code></td>     *     <td>Pixels per unit, X axis</td></tr>     * <tr><td nowrap>"pixel dimensions y"</td><td nowrap><code>Long</code></td>     *     <td>Pixels per unit, Y axis</td></tr>     * <tr valign=top><td nowrap>"pixel dimensions unit"</td><td nowrap><code>Integer</code></td>     *     <td><code>UNIT_UNKNOWN</code> or <code>UNIT_METER</code></td></tr>     * <tr valign=top><td nowrap>"image position x"</td><td nowrap><code>Integer</code></td>     *     <td>Horizontal offset from left of page</td></tr>     * <tr valign=top><td nowrap>"image position y"</td><td nowrap><code>Integer</code></td>     *     <td>Vertical offset from top of page</td></tr>     * <tr valign=top><td nowrap>"image position unit"</td><td nowrap><code>Integer</code></td>     *     <td><code>UNIT_PIXEL</code> or <code>UNIT_MICROMETER</code></td></tr>     * <tr valign=top><td nowrap>"pixel scale x"</td><td nowrap><code>Double</code></td>     *     <td>Pixel width, physical scale of subject</td></tr>     * <tr valign=top><td nowrap>"pixel scale y"</td><td nowrap><code>Double</code></td>     *     <td>Pixel height, physical scale of subject</td></tr>     * <tr valign=top><td nowrap>"pixel scale unit"</td><td nowrap><code>Integer</code></td>     *     <td><code>UNIT_METER</code> or <code>UNIT_RADIAN</code></td></tr>     * <tr valign=top><td nowrap>"chromaticity xy"</td><td nowrap><code>long[][]</code></td>     *     <td>CIE x,y chromaticities * 100000: <nowrap><code>[white,r,g,b][x,y]</code></nowrap></td></tr>     * <tr valign=top><td nowrap>"chromaticity xyz"</td><td nowrap><code>double[][]</code></td>     *     <td>CIE XYZ chromaticities: <nowrap><code>[white,r,g,b][X,Y,Z]</code></nowrap></td></tr>     * <tr valign=top><td nowrap nowrap>"srgb rendering intent"</td><td nowrap><code>Integer</code></td><td>     *     <code> SRGB_PERCEPTUAL</code> or<br>     *     <code> SRGB_RELATIVE_COLORIMETRIC</code> or<br>     *     <code> SRGB_SATURATION_PRESERVING</code> or<br>     *     <code> SRGB_ABSOLUTE_COLORIMETRIC</code></td></tr>     * <tr><td nowrap>"icc profile name"</td><td nowrap><code>String</code></td>     *     <td>Internal ICC profile name </td></tr>     * <tr><td nowrap>"icc profile"</td><td nowrap><code>String</code></td>     *     <td>Uncompressed ICC profile </td></tr>     * <tr><td nowrap>"pixel calibration purpose"</td><td nowrap><code>String</code></td>     * <td> Equation identifier</td></tr>     * <tr><td nowrap>"pixel calibration x0"</td><td nowrap><code>Integer</code></td>     * <td> Lower limit of original sample range</td></tr>     * <tr><td nowrap>"pixel calibration x1"</td><td nowrap><code>Integer</code></td>     * <td> Upper limit of original sample range</td></tr>     * <tr valign=top><td nowrap>"pixel calibration type"</td><td nowrap><code>Integer</code></td>     * <td>      *     <code>0</code>: Linear mapping<br>     *     <code>1</code>: Base-e exponential mapping<br>     *     <code>2</code>: Arbitrary-base exponential mapping<br>     *     <code>3</code>: Hyperbolic mapping     * </td></tr>     * <tr><td nowrap>"pixel calibration n"</td><td nowrap><code>Integer</code></td>     * <td> Number of parameters</td></tr>     * <tr><td nowrap>"pixel calibration unit"</td><td nowrap><code>String</code></td>     * <td> Symbol or description of unit</td></tr>     * <tr><td nowrap>"pixel calibration parameters"</td><td nowrap><code>double[]</code></td>     * <td> &nbsp;</td></tr>     * <tr><td nowrap>"gif disposal method"</td><td nowrap><code>Integer</code></td>     * <td>See GIF89a Graphic Control Extension specification</td></tr>     * <tr><td nowrap>"gif user input flag"</td><td nowrap><code>Integer</code></td>     * <td>See GIF89a Graphic Control Extension specification</td></tr>     * <tr><td nowrap>"gif delay time"</td><td nowrap><code>Integer</code></td>     * <td>See GIF89a Graphic Control Extension specification</td></tr>     * <tr><td nowrap>"transparency"</td><td nowrap><code>java.awt.Color</td>     *     <td>Transparent color <sup><a href="#fn4">(4)</a></sup></td></tr>     * <tr><td nowrap>"transparency low bytes"</td><td nowrap><code>java.awt.Color</td>     *     <td>The low (least significant) bytes of a 16-bit transparency color <sup><a href="#fn4">(4)</a></sup></td></tr>     * <tr><td nowrap>"transparency size"</td><td nowrap><code>Integer</td>     *     <td>The number of palette entries with transparency information <sup><a href="#fn5">(5)</a></sup></td></tr>          * </table></center>     * <center><table border=0 cellspacing=0 cellpadding=4 width="80%">     * <tr><td><b><sup><a name="fn4">4</a></sup></b> Grayscale or truecolor images only<br>     *         <b><sup><a name="fn5">5</a></sup></b> Indexed-color images only</td></tr>     * </table></center>          * <p>     * In addition, certain common (but still optional) text chunks      * are available through the <code>getProperty</code> interface:<p>     * <center><table border=1 cellspacing=0 cellpadding=4 width="80%">     * <tr bgcolor="#E0E0E0"><td nowrap><b>Name</b></td><td nowrap><b>Type</b></td>     *     <td><b>Description</b></td></tr>     * <tr><td nowrap>"title"</td><td nowrap><code>TextChunk</code></td>     *     <td>Short (one line) title or caption for image</td></tr>     * <tr><td nowrap>"author"</td><td nowrap><code>TextChunk</code></td>     *     <td>Name of image's creator</td></tr>     * <tr><td nowrap>"description"</td><td nowrap><code>TextChunk</code></td>     *     <td>Description of image (possibly long)</td></tr>     * <tr><td nowrap>"copyright"</td><td nowrap><code>TextChunk</code></td>     *     <td>Copyright notice</td></tr>     * <tr><td nowrap>"creation time"</td><td nowrap><code>TextChunk</code></td>     *     <td>Time of original image creation</td></tr>     * <tr><td nowrap>"software"</td><td nowrap><code>TextChunk</code></td>     *     <td>Software used to create the image</td></tr>     * <tr><td nowrap>"disclaimer"</td><td nowrap><code>TextChunk</code></td>     *     <td>Legal disclaimer</td></tr>     * <tr><td nowrap>"warning"</td><td nowrap><code>TextChunk</code></td>     *     <td>Warning of nature of content</td></tr>     * <tr><td nowrap>"source"</td><td nowrap><code>TextChunk</code></td>     *     <td>Device used to create the image</td></tr>     * <tr><td nowrap>"comment"</td><td nowrap><code>TextChunk</code></td>     *     <td>Miscellaneous comment</td></tr>     * </table></center>     * @see #getEverything     * @see #getWidth     * @see #getHeight     * @see #getInterlaceType     * @see #getColorType     * @see #getTextChunk     * @see #getBackgroundColor     * @param name a property name     * @return the value of the named property.      */    public Object getProperty(String name)    throws IOException    {        readToData();        return data.properties.get(name);    }    /**     * Returns an <code>Enumeration</code> of the available properties.     * @see #getProperty     */    public Enumeration getProperties()    throws IOException    {        readToData();        return data.properties.keys();    }    /**     * Ensures that the entire PNG file has been read. No exceptions     * are throws; errors are available by calling <code>getErrors</code>.     * <p>     * <b>Note:</b> The consumer/producer interface automatically     * reads the entire PNG file. It usually is not necessary to call     * <code>getEverything</code> unless you do not need the actual     * image data.     * @see #getErrors     */    public void getEverything()    {        startProduction(new DummyImageConsumer());    }    public boolean hasChunk(String type)    {        return data.chunks.get(new Integer(Chunk.stringToType(type))) != null;    }    /**     * Register a <code>ChunkHandler</code> to handle a user defined     * chunk type.     * <p>     * The chunk type must be four characters, ancillary (lowercase first letter),     * and may not already be registered. You may register one of the supported      * ancillary chunk types (except <code>tRNS</code>) to override the standard behavior.     * @see ChunkHandler     * @param handler object to send chunk data to     * @param type chunk type     */    public static void registerChunk(ChunkHandler handler, String type)    throws PngException    {        if (type.length() < 4) {            throw new PngException("Invalid chunk type length.");        }        int type_int = Chunk.stringToType(type);        if (prototypes.containsKey(new Integer(type_int))) {            throw new PngException("Chunk type already registered.");        }        if ((type_int & 0x20000000) == 0) {            throw new PngException("Chunk must be ancillary.");        }        registerChunk(new UserChunk(handler, type_int));    }    /**     * Returns an <code>Enumeration</code> of the available suggested palette names.     * @see #getSuggestedPalette     */    public Enumeration getSuggestedPalettes()    throws IOException    {        readToData();        return data.palettes.keys();    }    /**     * Returns the suggested palette (sPLT chunk) specified by the      * palette name.     * @see #getSuggestedPalette     * @param name the name of the suggested palette     * @return <nowrap><code>[r,g,b,alpha,freq][entry]</code></nowrap>, or null if not present.     */    public int[][] getSuggestedPalette(String name)    throws IOException    {        readToData();        return (int[][])data.palettes.get(name);    }    /**     * Returns the specified text chunk.     * <p>     * <b>Note:</b> Text chunks may appear anywhere in the file. This     * method will only read up to the beginning of the image data     * unless the image data has already been read, either through the     * consumer/producer interface or by calling     * <code>getEverything</code>.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -