Back to index

lightning-sunbird  0.9+nobinonly
nsIconDecoder.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 2001
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Scott MacGregor <mscott@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef nsIconDecoder_h__
00041 #define nsIconDecoder_h__
00042 
00043 #include "imgIDecoder.h"
00044 
00045 #include "nsCOMPtr.h"
00046 
00047 #include "imgIContainer.h"
00048 #include "imgIDecoderObserver.h"
00049 #include "gfxIImageFrame.h"
00050 
00051 #define NS_ICONDECODER_CID                           \
00052 { /* FFC08380-256C-11d5-9905-001083010E9B */         \
00053      0xffc08380,                                     \
00054      0x256c,                                         \
00055      0x11d5,                                         \
00056     { 0x99, 0x5, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b }   \
00057 }
00058 
00059 
00061 // The icon decoder is a decoder specifically tailored for loading icons 
00062 // from the OS. We've defined our own little format to represent these icons
00063 // and this decoder takes that format and converts it into 24-bit RGB with alpha channel
00064 // support. It was modeled a bit off the PPM decoder.
00065 //
00066 // Assumptions about the decoder:
00067 // (1) We receive ALL of the data from the icon channel in one OnDataAvailable call. We don't
00068 //     support multiple ODA calls yet.
00069 // (2) the format of the incoming data is as follows:
00070 //     The first two bytes contain the width and the height of the icon. 
00071 //     The third byte contains the number of bits per pixel in the alpha
00072 //       channel (either 1 or 8).
00073 //     Followed by 3 bytes per pixel for the color bitmap row after row,
00074 //       from top to bottom, with pixels left to right within rows, and
00075 //       RGB order within pixels, in platform endianness.
00076 //     Followed by alpha data (1 or 8 bits per pixel, see above) in the
00077 //       same order as the RGB data, and also in platform endianness.
00078 //
00079 //
00081 
00082 class nsIconDecoder : public imgIDecoder
00083 {
00084 public:
00085   NS_DECL_ISUPPORTS
00086   NS_DECL_IMGIDECODER
00087 
00088   nsIconDecoder();
00089   virtual ~nsIconDecoder();
00090 
00091 private:
00092   nsCOMPtr<imgIContainer> mImage;
00093   nsCOMPtr<gfxIImageFrame> mFrame;
00094   nsCOMPtr<imgIDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
00095 };
00096 
00097 #endif // nsIconDecoder_h__