pixel_format.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_display.h"
00035 #include "pixel_format_type.h"
00036 
00040 class CL_API_DISPLAY CL_PixelFormat
00041 {
00044 
00045 public:
00055         CL_PixelFormat();
00056 
00060         CL_PixelFormat(const CL_PixelFormat &copy);
00061 
00062         CL_PixelFormat(
00063                 int depth,
00064                 unsigned int red_mask,
00065                 unsigned int green_mask,
00066                 unsigned int blue_mask,
00067                 unsigned int alpha_mask = 0,
00068                 bool use_colorkey = false,
00069                 unsigned int colorkey = 0,
00070                 CL_PixelFormatType type = pixelformat_rgba);
00071 
00075 
00076 public:
00078         bool operator ==(const CL_PixelFormat &other) const;
00079 
00081         bool operator !=(const CL_PixelFormat &other) const;
00082 
00084         CL_PixelFormatType get_type() const { return type; }
00085 
00087         bool has_colorkey() const { return colorkey_enabled; }
00088 
00090         int get_depth() const { return depth; }
00091 
00093         unsigned int get_colorkey() const { return colorkey; }
00094 
00096         unsigned int get_red_mask() const { return red_mask; }
00097 
00099         unsigned int get_green_mask() const { return green_mask; }
00100 
00102         unsigned int get_blue_mask() const { return blue_mask; }
00103 
00105         unsigned int get_alpha_mask() const { return alpha_mask; }
00106 
00110 
00111 public:
00113 
00119         static CL_PixelFormat rgba8888;
00120 
00122 
00128         static CL_PixelFormat argb8888;
00129 
00131 
00136         static CL_PixelFormat rgb888;
00137 
00139 
00145         static CL_PixelFormat rgba4444;
00146 
00148 
00154         static CL_PixelFormat rgb555;
00155 
00157 
00163         static CL_PixelFormat rgb565;
00164 
00166 
00172         static CL_PixelFormat abgr8888;
00173 
00175 
00180         static CL_PixelFormat bgr888;
00181 
00183 
00189         static CL_PixelFormat abgr4444;
00190 
00192 
00198         static CL_PixelFormat bgr555;
00199 
00201 
00207         static CL_PixelFormat bgr565;
00208 
00210         static int get_mask_shift(unsigned int mask);
00211 
00213         static int get_mask_bits(unsigned int mask);
00214 
00216         static unsigned int get_bitmask(int bits, int shift);
00217 
00221 
00222 public:
00224         void set_type(CL_PixelFormatType new_type) { type = new_type; }
00225 
00227         void enable_colorkey(bool enable = true) { colorkey_enabled = enable; }
00228 
00230         void set_colorkey(unsigned int i) { colorkey = i; }
00231 
00233         void set_depth(int i) { depth = i; }
00234 
00236         void set_red_mask(unsigned int i) { red_mask = i; }
00237 
00239         void set_green_mask(unsigned int i) { green_mask = i; }
00240 
00242         void set_blue_mask(unsigned int i) { blue_mask = i; }
00243 
00245         void set_alpha_mask(unsigned int i) { alpha_mask = i; }
00246 
00250 
00251 private:
00253         CL_PixelFormatType type;
00254 
00256         bool colorkey_enabled;
00257 
00259         unsigned int colorkey;
00260 
00262         unsigned int red_mask;
00263 
00265         unsigned int green_mask;
00266 
00268         unsigned int blue_mask;
00269 
00271         unsigned int alpha_mask;
00272 
00274         int depth;
00276 };
00277 

Generated on Thu Dec 3 02:39:30 2009 for ClanLib by  doxygen 1.4.6