Simple Image Loading LibrarY
0.1.0
|
00001 /*********************************************************************** 00002 filename: SILLYImageContext.icpp 00003 created: 10 Jun 2006 00004 author: Olivier Delannoy 00005 00006 purpose: Inline definition for ImageContext 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 00031 // Start of section namespace SILLY 00032 namespace SILLY 00033 { 00034 00035 inline ImageContext::ImageContext(size_t width, size_t height) 00036 : d_pixels(0), d_length(0), d_width(width), d_height(height), d_currentOffset(0), d_format(PF_RGBA) 00037 { 00038 } 00039 00040 00041 inline ImageContext::~ImageContext() 00042 { 00043 } 00044 00045 00046 inline void ImageContext::setDestination(byte* pixels, size_t length, PixelFormat format) 00047 { 00048 d_pixels = pixels; 00049 d_length = length; 00050 d_currentOffset = 0; 00051 d_format = format; 00052 } 00053 00054 inline void ImageContext::setNextPixel(byte red, byte green, byte bleu, byte alpha) 00055 { 00056 //assert(d_currentOffset < d_length && "ASSERT: try to set a pixel outside of the image"); 00057 switch(d_format) 00058 { 00059 case PF_A1B5G5R5: 00060 // The hard part 00061 assert(0 && "ASSERT: Not yet implemented"); 00062 break; 00063 case PF_RGB: 00064 // Ignore alpha channel 00065 d_pixels[d_currentOffset++] = red; 00066 d_pixels[d_currentOffset++] = green; 00067 d_pixels[d_currentOffset++] = bleu; 00068 break; 00069 00070 case PF_RGBA: 00071 d_pixels[d_currentOffset++] = red; 00072 d_pixels[d_currentOffset++] = green; 00073 d_pixels[d_currentOffset++] = bleu; 00074 d_pixels[d_currentOffset++] = alpha; 00075 break; 00076 00077 } 00078 } 00079 inline size_t ImageContext::getWidth() const 00080 { 00081 return d_width; 00082 } 00083 00084 inline void ImageContext::setWidth(size_t width) 00085 { 00086 d_width = width; 00087 } 00088 00089 inline size_t ImageContext::getHeight() const 00090 { 00091 return d_height; 00092 } 00093 00094 inline void ImageContext::setHeight(size_t height) 00095 { 00096 d_height = height; 00097 } 00098 inline PixelFormat ImageContext::getPixelFormat() const 00099 { 00100 return d_format; 00101 } 00102 00103 } // End of section namespace SILLY 00104