Class DIBImageReader
- java.lang.Object
-
- javax.imageio.ImageReader
-
- com.twelvemonkeys.imageio.ImageReaderBase
-
- com.twelvemonkeys.imageio.plugins.bmp.DIBImageReader
-
- Direct Known Subclasses:
CURImageReader
,ICOImageReader
abstract class DIBImageReader extends ImageReaderBase
ImageReader for Microsoft Windows ICO (icon) format. 1, 4, 8 bit palette support with bitmask transparency, and 16, 24 and 32 bit true color support with alpha. Also supports Windows Vista PNG encoded icons.- Version:
- $Id: ICOImageReader.java,v 1.0 25.feb.2006 00:29:44 haku Exp$
- See Also:
- BMP file format (Wikipedia), ICO file format (Wikipedia)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<DirectoryEntry,BitmapDescriptor>
descriptors
private Directory
directory
private java.util.Map<DirectoryEntry,DIBHeader>
headers
private javax.imageio.ImageReader
pngImageReader
-
Fields inherited from class com.twelvemonkeys.imageio.ImageReaderBase
imageInput
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DIBImageReader(javax.imageio.spi.ImageReaderSpi provider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
addImage(java.awt.Container parent, javax.imageio.ImageReader reader, int imageNo)
private static int
adjustToPadding(int width)
private static javax.swing.JFrame
createWindow(java.lang.String title)
private Directory
getDirectory()
(package private) DirectoryEntry
getEntry(int imageIndex)
private DIBHeader
getHeader(DirectoryEntry entry)
int
getHeight(int imageIndex)
java.util.Iterator<javax.imageio.ImageTypeSpecifier>
getImageTypes(int imageIndex)
private java.util.Iterator<javax.imageio.ImageTypeSpecifier>
getImageTypesPNG(DirectoryEntry entry)
int
getNumImages(boolean allowSearch)
Default implementation that always returns1
.private javax.imageio.ImageReader
getPNGReader()
int
getWidth(int imageIndex)
private javax.imageio.ImageReader
initPNGReader(DirectoryEntry entry)
private boolean
isPNG(DirectoryEntry entry)
static void
main(java.lang.String[] args)
java.awt.image.BufferedImage
read(int imageIndex, javax.imageio.ImageReadParam param)
private java.awt.image.BufferedImage
readBitmap(DirectoryEntry entry)
private void
readBitmap16(BitmapDescriptor bitmap)
private void
readBitmap24(BitmapDescriptor bitmap)
private void
readBitmap32(BitmapDescriptor bitmap)
private void
readBitmapIndexed(BitmapIndexed bitmap)
private void
readBitmapIndexed1(BitmapIndexed bitmap, boolean asMask)
private void
readBitmapIndexed4(BitmapIndexed bitmap)
private void
readBitmapIndexed8(BitmapIndexed bitmap)
private void
readColorMap(BitmapIndexed bitmap)
private void
readFileHeader()
private static void
readImagesInFile(java.lang.String fileName, javax.imageio.ImageReader reader, java.awt.Container container)
private java.awt.image.BufferedImage
readPNG(DirectoryEntry entry, javax.imageio.ImageReadParam param)
protected void
resetMembers()
Resets all member variables.-
Methods inherited from class com.twelvemonkeys.imageio.ImageReaderBase
assertInput, checkBounds, dispose, fakeAOI, fakeSubsampling, getDestination, getImageMetadata, getStreamMetadata, hasExplicitDestination, reset, setInput, showIt
-
Methods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
-
-
-
-
Field Detail
-
directory
private Directory directory
-
headers
private final java.util.Map<DirectoryEntry,DIBHeader> headers
-
descriptors
private final java.util.Map<DirectoryEntry,BitmapDescriptor> descriptors
-
pngImageReader
private javax.imageio.ImageReader pngImageReader
-
-
Method Detail
-
resetMembers
protected void resetMembers()
Description copied from class:ImageReaderBase
Resets all member variables. This method is by default invoked from:- Specified by:
resetMembers
in classImageReaderBase
-
getImageTypes
public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int imageIndex) throws java.io.IOException
- Specified by:
getImageTypes
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getNumImages
public int getNumImages(boolean allowSearch) throws java.io.IOException
Description copied from class:ImageReaderBase
Default implementation that always returns1
.- Overrides:
getNumImages
in classImageReaderBase
- Parameters:
allowSearch
- ignored, unless overridden- Returns:
1
, unless overridden- Throws:
java.io.IOException
- never, unless overridden
-
getWidth
public int getWidth(int imageIndex) throws java.io.IOException
- Specified by:
getWidth
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
getHeight
public int getHeight(int imageIndex) throws java.io.IOException
- Specified by:
getHeight
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
read
public java.awt.image.BufferedImage read(int imageIndex, javax.imageio.ImageReadParam param) throws java.io.IOException
- Specified by:
read
in classjavax.imageio.ImageReader
- Throws:
java.io.IOException
-
isPNG
private boolean isPNG(DirectoryEntry entry) throws java.io.IOException
- Throws:
java.io.IOException
-
readPNG
private java.awt.image.BufferedImage readPNG(DirectoryEntry entry, javax.imageio.ImageReadParam param) throws java.io.IOException
- Throws:
java.io.IOException
-
getImageTypesPNG
private java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypesPNG(DirectoryEntry entry) throws java.io.IOException
- Throws:
java.io.IOException
-
initPNGReader
private javax.imageio.ImageReader initPNGReader(DirectoryEntry entry) throws java.io.IOException
- Throws:
java.io.IOException
-
getPNGReader
private javax.imageio.ImageReader getPNGReader() throws javax.imageio.IIOException
- Throws:
javax.imageio.IIOException
-
getHeader
private DIBHeader getHeader(DirectoryEntry entry) throws java.io.IOException
- Throws:
java.io.IOException
-
readBitmap
private java.awt.image.BufferedImage readBitmap(DirectoryEntry entry) throws java.io.IOException
- Throws:
java.io.IOException
-
readBitmapIndexed
private void readBitmapIndexed(BitmapIndexed bitmap) throws java.io.IOException
- Throws:
java.io.IOException
-
readColorMap
private void readColorMap(BitmapIndexed bitmap) throws java.io.IOException
- Throws:
java.io.IOException
-
readBitmapIndexed1
private void readBitmapIndexed1(BitmapIndexed bitmap, boolean asMask) throws java.io.IOException
- Throws:
java.io.IOException
-
readBitmapIndexed4
private void readBitmapIndexed4(BitmapIndexed bitmap) throws java.io.IOException
- Throws:
java.io.IOException
-
readBitmapIndexed8
private void readBitmapIndexed8(BitmapIndexed bitmap) throws java.io.IOException
- Throws:
java.io.IOException
-
adjustToPadding
private static int adjustToPadding(int width)
- Parameters:
width
- Bytes per scan line (i.e., 1BPP, width = 9 -> bytes = 2)- Returns:
- padded width
-
readBitmap16
private void readBitmap16(BitmapDescriptor bitmap) throws java.io.IOException
- Throws:
java.io.IOException
-
readBitmap24
private void readBitmap24(BitmapDescriptor bitmap) throws java.io.IOException
- Throws:
java.io.IOException
-
readBitmap32
private void readBitmap32(BitmapDescriptor bitmap) throws java.io.IOException
- Throws:
java.io.IOException
-
getDirectory
private Directory getDirectory() throws java.io.IOException
- Throws:
java.io.IOException
-
readFileHeader
private void readFileHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
getEntry
final DirectoryEntry getEntry(int imageIndex) throws java.io.IOException
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
- Throws:
java.io.IOException
-
readImagesInFile
private static void readImagesInFile(java.lang.String fileName, javax.imageio.ImageReader reader, java.awt.Container container) throws java.io.IOException
- Throws:
java.io.IOException
-
createWindow
private static javax.swing.JFrame createWindow(java.lang.String title)
-
addImage
private static void addImage(java.awt.Container parent, javax.imageio.ImageReader reader, int imageNo) throws java.io.IOException
- Throws:
java.io.IOException
-
-