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>descriptorsprivate Directorydirectoryprivate java.util.Map<DirectoryEntry,DIBHeader>headersprivate javax.imageio.ImageReaderpngImageReader-
Fields inherited from class com.twelvemonkeys.imageio.ImageReaderBase
imageInput
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDIBImageReader(javax.imageio.spi.ImageReaderSpi provider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddImage(java.awt.Container parent, javax.imageio.ImageReader reader, int imageNo)private static intadjustToPadding(int width)private static javax.swing.JFramecreateWindow(java.lang.String title)private DirectorygetDirectory()(package private) DirectoryEntrygetEntry(int imageIndex)private DIBHeadergetHeader(DirectoryEntry entry)intgetHeight(int imageIndex)java.util.Iterator<javax.imageio.ImageTypeSpecifier>getImageTypes(int imageIndex)private java.util.Iterator<javax.imageio.ImageTypeSpecifier>getImageTypesPNG(DirectoryEntry entry)intgetNumImages(boolean allowSearch)Default implementation that always returns1.private javax.imageio.ImageReadergetPNGReader()intgetWidth(int imageIndex)private javax.imageio.ImageReaderinitPNGReader(DirectoryEntry entry)private booleanisPNG(DirectoryEntry entry)static voidmain(java.lang.String[] args)java.awt.image.BufferedImageread(int imageIndex, javax.imageio.ImageReadParam param)private java.awt.image.BufferedImagereadBitmap(DirectoryEntry entry)private voidreadBitmap16(BitmapDescriptor bitmap)private voidreadBitmap24(BitmapDescriptor bitmap)private voidreadBitmap32(BitmapDescriptor bitmap)private voidreadBitmapIndexed(BitmapIndexed bitmap)private voidreadBitmapIndexed1(BitmapIndexed bitmap, boolean asMask)private voidreadBitmapIndexed4(BitmapIndexed bitmap)private voidreadBitmapIndexed8(BitmapIndexed bitmap)private voidreadColorMap(BitmapIndexed bitmap)private voidreadFileHeader()private static voidreadImagesInFile(java.lang.String fileName, javax.imageio.ImageReader reader, java.awt.Container container)private java.awt.image.BufferedImagereadPNG(DirectoryEntry entry, javax.imageio.ImageReadParam param)protected voidresetMembers()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:ImageReaderBaseResets all member variables. This method is by default invoked from:- Specified by:
resetMembersin classImageReaderBase
-
getImageTypes
public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int imageIndex) throws java.io.IOException- Specified by:
getImageTypesin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getNumImages
public int getNumImages(boolean allowSearch) throws java.io.IOExceptionDescription copied from class:ImageReaderBaseDefault implementation that always returns1.- Overrides:
getNumImagesin 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:
getWidthin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getHeight
public int getHeight(int imageIndex) throws java.io.IOException- Specified by:
getHeightin 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:
readin 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
-
-