TV-Browser 2.7.5 API

webplugin.aclib.image.ico
Class ICOFile

java.lang.Object
  extended by webplugin.aclib.image.ico.ICOFile
All Implemented Interfaces:
Comparable

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.

Author:
© Christian Treber, ct@ctreber.com

Constructor Summary
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.
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ICOFile

public ICOFile(String pFileName)
        throws IOException
Create ICOFile object from an ICO file. Use getDescriptors()to access the icon(s). Yes, ICO files might contain more than one icon).

Parameters:
pFileName - Name of the file to read.
Throws:
IOException

ICOFile

public ICOFile(InputStream pInput)
        throws IOException
Create ICO file from an input stream.

Parameters:
pInput -
Throws:
IOException

ICOFile

public ICOFile(URL pURL)
        throws IOException
Create ICO file from an URL.

Parameters:
pURL -
Throws:
IOException

ICOFile

public ICOFile(byte[] pBuffer)
        throws IOException
Create ICOFile from a byte array.

Parameters:
pBuffer -
Throws:
IOException

ICOFile

public ICOFile(String pFileName,
               AbstractDecoder pFileDecoder)
        throws IOException
Create ICO file.

Parameters:
pFileName - Just serves as information for toString() output; input is obtained through pFileDecoder.
pFileDecoder - Decoder to read from.
Throws:
IOException - If anything goes wrong with reading from the decoder.
Method Detail

compareTo

public int compareTo(Object pOther)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class Object

getImages

public List<Image> getImages()
Get all contained images (comfort method).

Returns:
Images (type Image).

getDescriptors

public List<BitmapDescriptor> getDescriptors()
Get the list of BitmapDescriptors contained in the ICO file.

Returns:
List of BitmapDescriptorin same order as in the ICO file (use methods on ICOEntry to get the actual images).

getDescriptor

public BitmapDescriptor getDescriptor(int pDescriptorNo)
Get the speicified BitmapDescriptor.

Parameters:
pDescriptorNo - Number of the descriptor to get.
Returns:
BitmapDescriptor.

getType

public int getType()
Get the image type.

Returns:
The image type (any ideas what that is?).

getImageCount

public int getImageCount()
Get the number of contained images.

Returns:
Number of contained images.

getFileName

public String getFileName()
Returns:
Source file name.

getReserved

public int getReserved()
Returns:
Returns the "reserved" value.

TV-Browser 2.7.5 API

TV-Browser 2.7.5, Copyright (C) 04-2003 Martin Oberhauser (martin@tvbrowser.org)