Every pixel within a mutable image is always fully opaque. Immutable images may contain a combination of fully opaque pixels (alpha = 2bitdepth - 1)
, fully transparent pixels (alpha = 0
), and semitransparent pixels (0 < alpha < 2bitdepth - 1
), where bitdepth is the number of bits per sample in the source data.
Implementations must support storage, processing, and rendering of fully opaque pixels and fully transparent pixels in immutable images. When creating an image from source data (whether from a PNG file or from an array of ARGB data), a fully opaque pixel in the source data must always result in a fully opaque pixel in the new image, and a fully transparent pixel in the source data must always result in a fully transparent pixel in the new image.
The required treatment of semitransparent pixel data depends upon whether the implementation supports alpha blending at rendering time. If the implementation supports alpha blending, a semitransparent pixel in the source data must result in a semitransparent pixel in the new image. The resulting alpha value may be modified to accommodate the number of levels of semitransparency supported by the platform. (See the {@link Display#numAlphaLevels() Display.numAlphaLevels()} method.) If animplementation does not support alpha blending, any semitransparent pixels in the source data must be replaced with fully transparent pixels in the new image.
Implementations are required to support images stored in the PNG format, as specified by the PNG (Portable Network Graphics) Specification, Version 1.0. All conforming MIDP implementations are also conformant to the minimum set of requirements given by the PNG Specification. MIDP implementations also must conform to additional requirements given here with respect to handling of PNG images. Note that the requirements listed here take precedence over any conflicting recommendations given in the PNG Specification.
All of the 'critical' chunks specified by PNG must be supported. The paragraphs below describe these critical chunks.
The IHDR chunk. MIDP devices must handle the following values in the IHDR chunk:
Image
object must match the dimensions of the PNG image. That is, the values returned by {@link #getWidth() getWidth()} and {@link #getHeight() getHeight()}and the rendered width and height must equal the width and height specified in the IHDR chunk.4
& 6
(grayscale with alpha and RGB with alpha, respectively) the alpha channel must be decoded. Any pixels with an alpha value of zero must be treated as transparent. Any pixels with an alpha value of 255
(for images with 8
bits per sample) or 65535
(for images with 16
bits per sample) must be treated as opaque. If rendering with alpha blending is supported, any pixels with intermediate alpha values must be carried through to the resulting image. If alpha blending is not supported, any pixels with intermediate alpha values must be replaced with fully transparent pixels.0
(deflate) is the only supported compression method. This method utilizes the "zlib" compression scheme, which is also used for jar files; thus, the decompression (inflate) code may be shared between the jar decoding and PNG decoding implementations. As noted in the PNG specification, the compressed data stream may comprised internally of both compressed and uncompressed (raw) data. 0
) that is an adaptive filtering scheme with five basic filter types. Filtering is essential for optimal compression since it allows the deflate algorithm to exploit spatial similarities within the image. Therefore, MIDP devices must support all five filter types defined by filter method 0
.0
(None) or interlace method 1
(Adam7). Image loading in MIDP is synchronous and cannot be overlapped with image rendering, and so there is no advantage for an application to use interlace method 1
. Support for decoding interlaced images is required for compatibility with PNG and for the convenience of developers who may already have interlaced images available.The PLTE chunk. Palette-based images must be supported.
The IDAT chunk. Image data may be encoded using any of the 5
filter types defined by filter method 0
(None, Sub, Up, Average, Paeth).
The IEND chunk. This chunk must be found in order for the image to be considered valid.
PNG defines several 'ancillary' chunks that may be present in a PNG image but are not critical for image decoding.
The tRNS chunk. All implementations must support the tRNS chunk. This chunk is used to implement transparency without providing alpha channel data for each pixel. For color types 0
and 2
, a particular gray or RGB value is defined to be a transparent pixel. In this case, the implementation must treat pixels with this value as fully transparent. Pixel value comparison must be based on the actual pixel values using the original sample depth; that is, this comparison must be performed before the pixel values are resampled to reflect the display capabilities of the device. For color type 3
(indexed color), 8
-bit alpha values are potentially provided for each entry in the color palette. In this case, the implementation must treat pixels with an alpha value of 0
as fully transparent, and it must treat pixels with an alpha value of 255
as fully opaque. If rendering with alpha blending is supported, any pixels with intermediate alpha values must be carried through to the resulting image. If alpha blending is not supported, any pixels with intermediate alpha values must be replaced with fully transparent pixels.
The implementation may (but is not required to) support any of the other ancillary chunks. The implementation must silently ignore any unsupported ancillary chunks that it encounters. The currently defined optional ancillary chunks are:
cHRM gAMA hIST iCCP iTXt pHYs sBIT sPLT sRGB tEXt tIME zTXt
PNG (Portable Network Graphics) Specification, Version 1.0. W3C Recommendation, October 1, 1996. http://www.w3.org/TR/REC-png.html. Also available as RFC 2083, http://www.ietf.org/rfc/rfc2083.txt.
@since MIDP 1.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|