public class ICOFile extends Object implements Comparable
ICO file with one or more embedded bitmaps representing icons in various resolutions. An ICO file essentially is a format that glues together a couple of bitmaps into a single file.
This code uses file format information gleaned from:
winicontoppm.c - read a MS Windows .ico file and write portable pixmap(s)
Copyright (C) 2000 by Lee Benfield - lee@recoil.org
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty.
Addendum for Java code by Christian Treber:
The rules for the Java adaption are the same as stated above for the C version.
Notes: All code in 1:10h. Realized stuff is little endian. At 2:30h: Debugged, got stuck on wrong determination of row length in 8 BPP images. Got black images until I set the alpha channel... Put some more effort into supporting mask; all in all I would say this took me 4:00h. Had to add another 4:00h for research into 24 and 32 BPP.
Constructor and Description |
---|
ICOFile(byte[] pBuffer)
Create ICOFile from a byte array.
|
ICOFile(InputStream pInput)
Create ICO file from an input stream.
|
ICOFile(String pFileName)
Create ICOFile object from an ICO file.
|
ICOFile(String pFileName,
AbstractDecoder pFileDecoder)
Create ICO file.
|
ICOFile(URL pURL)
Create ICO file from an URL.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Object pOther) |
BitmapDescriptor |
getDescriptor(int pDescriptorNo)
Get the speicified BitmapDescriptor.
|
List<BitmapDescriptor> |
getDescriptors()
Get the list of BitmapDescriptors contained in the ICO file.
|
String |
getFileName() |
int |
getImageCount()
Get the number of contained images.
|
List<Image> |
getImages()
Get all contained images (comfort method).
|
int |
getReserved() |
int |
getType()
Get the image type.
|
String |
toString() |
public ICOFile(String pFileName) throws IOException
getDescriptors()
to
access the icon(s). Yes, ICO files might contain more than one icon).pFileName
- Name of the file to read.IOException
public ICOFile(InputStream pInput) throws IOException
pInput
- IOException
public ICOFile(URL pURL) throws IOException
pURL
- IOException
public ICOFile(byte[] pBuffer) throws IOException
pBuffer
- IOException
public ICOFile(String pFileName, AbstractDecoder pFileDecoder) throws IOException
pFileName
- Just serves as information for toString() output; input is
obtained through pFileDecoder.pFileDecoder
- Decoder to read from.IOException
- If anything goes wrong with reading from the decoder.public int compareTo(Object pOther)
compareTo
in interface Comparable
public List<Image> getImages()
public List<BitmapDescriptor> getDescriptors()
BitmapDescriptor
in same order as in the ICO file
(use methods on ICOEntry to get the actual images).public BitmapDescriptor getDescriptor(int pDescriptorNo)
pDescriptorNo
- Number of the descriptor to get.public int getType()
public int getImageCount()
public String getFileName()
public int getReserved()
TV-Browser 2.7.6, Copyright (C) 04-2003 Martin Oberhauser (martin@tvbrowser.org)