AaronCameron.net
I care not for your petty politics.
Not a Member? - Login or Create an Account
Tuesday the 22nd of May 2012 @ 02:08am
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cPixelFormat.h

Go to the documentation of this file.
00001 /************************************************************************
00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library
00003 Copyright (C) 2003  Aaron Cameron
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018 
00019 A copy of the GNU Lesser General Public License has been provided with
00020 this library in the file 'COPYING'.
00021 
00022 Contact information for the author of this library has been provided
00023 with this library in the file 'AUTHOR'.
00024 ************************************************************************/
00025 #ifndef _n2l4_cPixelFormat_H
00026 #define _n2l4_cPixelFormat_H
00027 
00028 #include "n2l/n2l.h"
00029 
00030 #include "SDL_video.h"
00031 
00032 struct SDL_PixelFormat;
00033 
00034 namespace n2l
00035 {
00036 
00037     class cPixelFormat
00038     {
00039     public:
00040         typedef tUbyte  tBitCount;
00041         typedef tUbyte  tByteCount;
00042         typedef tUint   tChannelMask;
00043         
00044 
00045         enum tChannel
00046         {
00047             Channel_Red =   0,
00048             Channel_Green = 1,
00049             Channel_Blue =  2,
00050             Channel_Alpha = 3,
00051             Channel_NChannel = 4    
00056         };
00057 
00058 
00059         static const tBitCount  nBitCount;
00060 
00061         cPixelFormat();
00062         cPixelFormat( const cPixelFormat &iFormat );
00063         cPixelFormat( const SDL_PixelFormat &iFormat );
00064 
00065         const tBitCount bitsPerPixel() const;
00066         const tByteCount bytesPerPixel() const;
00067         const tChannelMask channelMask( const tChannel iChannel ) const;
00068         const tBitCount channelLoss( const tChannel iChannel ) const;
00069         const tBitCount channelShift( const tChannel iChannel ) const;
00070         const tBitCount bitsForChannel( const tChannel iChannel ) const;
00071 
00072         // Alternate, batch get methods
00073         void channelMasks( tChannelMask &oRed, tChannelMask &oGreen,
00074             tChannelMask &oBlue, tChannelMask &oAlpha ) const;
00075 
00076         void channelLosses( tBitCount & oRed, tBitCount & oGreen,
00077             tBitCount &oBlue, tBitCount &oAlpha ) const;
00078 
00079         void channelShifts( tBitCount &oRed, tBitCount &oGreen,
00080             tBitCount &oBlue, tBitCount &oAlpha ) const;
00081         
00082         void assign( const cPixelFormat &iFormat );
00083 
00084         void clear();
00085 
00086         const tBool operator ==( const cPixelFormat &iFormat ) const;
00087         inline const tBool operator !=( const cPixelFormat &iFormat ) const {
00088             return !(*this == iFormat);
00089         }
00090 
00091         const tString asString() const;
00092 
00093     private:
00094         tBitCount mBitsPerPixel;
00095         tByteCount mBytesPerPixel;
00096         tChannelMask mCMask[Channel_NChannel];
00097         tBitCount mCShift[Channel_NChannel];
00098         tBitCount mCLoss[Channel_NChannel];
00099         tBitCount mBitsPerChannel[Channel_NChannel];
00100 
00101         void calculateChannelBitSizes();
00102 
00103     }; // class
00104 
00105 } // namespace n2l
00106 
00107 #endif
©2012 Aaron Cameron