Back to index

lightning-sunbird  0.9+nobinonly
nsXBMDecoder.h
Go to the documentation of this file.
00001 /* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4: */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Mozilla XBM Decoder.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Christian Biesinger <cbiesinger@web.de>.
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Aaron Kaluszka <ask@swva.net>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 
00040 #ifndef _nsXBMDecoder_h
00041 #define _nsXBMDecoder_h
00042 
00043 #include "nsCOMPtr.h"
00044 #include "imgIDecoder.h"
00045 #include "imgIContainer.h"
00046 #include "imgIDecoderObserver.h"
00047 #include "gfxIImageFrame.h"
00048 
00049 #define NS_XBMDECODER_CID \
00050 { /* {dbfd145d-3298-4f3c-902f-2c5e1a1494ce} */ \
00051   0xdbfd145d, \
00052   0x3298, \
00053   0x4f3c, \
00054   { 0x90, 0x2f, 0x2c, 0x5e, 0x1a, 0x14, 0x94, 0xce } \
00055 }
00056 
00057 class nsXBMDecoder : public imgIDecoder
00058 {
00059 public:
00060     NS_DECL_ISUPPORTS
00061     NS_DECL_IMGIDECODER
00062 
00063     nsXBMDecoder();
00064     virtual ~nsXBMDecoder();
00065 
00066     nsresult ProcessData(const char* aData, PRUint32 aCount);
00067 private:
00068     static NS_METHOD ReadSegCb(nsIInputStream* aIn, void* aClosure,
00069                                const char* aFromRawSegment, PRUint32 aToOffset,
00070                                PRUint32 aCount, PRUint32 *aWriteCount);
00071 
00072     nsCOMPtr<imgIDecoderObserver> mObserver;
00073 
00074     nsCOMPtr<imgIContainer> mImage;
00075     nsCOMPtr<gfxIImageFrame> mFrame;
00076 
00077     PRUint32 mCurRow;
00078     PRUint32 mCurCol;
00079 
00080     char* mBuf; // Holds the received data
00081     char* mPos;
00082     PRUint32 mBufSize; // number of bytes in mBuf
00083 
00084     PRUint32 mWidth;
00085     PRUint32 mHeight;
00086     PRUint32 mXHotspot;
00087     PRUint32 mYHotspot;
00088 
00089     PRUint8* mAlphaRow; // alpha data for the row
00090 
00091     PRPackedBool mIsCursor;
00092     PRPackedBool mIsX10; // X10 flavor XBM?
00093 
00094     enum {
00095         RECV_HEADER,
00096         RECV_SEEK,
00097         RECV_DATA,
00098         RECV_DONE
00099     } mState;
00100 };
00101 
00102 
00103 #endif