1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 /* 24 * This code is based on Broken Sword 2.5 engine 25 * 26 * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer 27 * 28 * Licensed under GNU GPL v2 29 * 30 */ 31 32 /* 33 BS_Image 34 -------- 35 36 Autor: Malte Thiesen 37 */ 38 39 #ifndef SWORD25_IMAGE_H 40 #define SWORD25_IMAGE_H 41 42 // Includes 43 #include "sword25/kernel/common.h" 44 #include "common/rect.h" 45 #include "sword25/gfx/graphicengine.h" 46 #include "graphics/transparent_surface.h" 47 48 namespace Sword25 { 49 50 class RectangleList; 51 52 class Image { 53 public: ~Image()54 virtual ~Image() {} 55 56 //@{ 57 /** @name Accessor methods */ 58 59 /** 60 @brief Returns the width of the image in pixels 61 */ 62 virtual int getWidth() const = 0; 63 64 /** 65 @brief Returns the height of the image in pixels 66 */ 67 virtual int getHeight() const = 0; 68 69 //@} 70 71 //@{ 72 /** @name Render methodes */ 73 74 /** 75 @brief renders the image in the framebuffer 76 @param pDest a pointer to the target image. In most cases this is the framebuffer. 77 @param PosX the position on the X-axis in the target image in pixels where the image is supposed to be rendered.<br> 78 The default value is 0. 79 @param PosY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.<br> 80 The default value is 0. 81 @param Flipping how the the image should be flipped.<br> 82 The default value is Graphics::FLIP_NONE (no flipping) 83 @param pSrcPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.<br> 84 This referes to the unflipped and unscaled image.<br> 85 The default value is NULL. 86 @param Color an ARGB color value, which determines the parameters for the color modulation und alpha blending.<br> 87 The alpha component of the color determines the alpha blending parameter (0 = no covering, 255 = full covering).<br> 88 The color components determines the color for color modulation.<br> 89 The default value is BS_ARGB(255, 255, 255, 255) (full covering, no color modulation). 90 The macros BS_RGB and BS_ARGB can be used for the creation of the color value. 91 @param Width the output width of the screen section. 92 The images will be scaled if the output width of the screen section differs from the image section.<br> 93 The value -1 determines that the image should not be scaled.<br> 94 The default value is -1. 95 @param Width the output height of the screen section. 96 The images will be scaled if the output width of the screen section differs from the image section.<br> 97 The value -1 determines that the image should not be scaled.<br> 98 The default value is -1. 99 @return returns false if the rendering failed. 100 @remark Not all blitting operations of all BS_Image classes are supported.<br> 101 More information can be find in the class description of BS_Image and the following methodes: 102 - IsBlitTarget() 103 - IsScalingAllowed() 104 - IsFillingAllowed() 105 - IsAlphaAllowed() 106 - IsColorModulationAllowed() 107 - IsSetContentAllowed() 108 */ 109 virtual bool blit(int posX = 0, int posY = 0, 110 int flipping = Graphics::FLIP_NONE, 111 Common::Rect *pPartRect = NULL, 112 uint color = BS_ARGB(255, 255, 255, 255), 113 int width = -1, int height = -1, 114 RectangleList *updateRects = 0) = 0; 115 116 /** 117 @brief fills a rectangular section of the image with a color. 118 @param pFillRect Pointer on Common::Rect which specifies the section of the image which is supposed to be filled. If the whole image has to be filled this value is NULL.<br> 119 The default value is NULL. 120 @param Color the 32 Bit color value for filling the image section. 121 @remark It is possible to create transparent rectangulars by using a color with alpha value not equal to 255. 122 @remark Independent from the color format of the image, it must be given a 32 bit color value. The macros BS_RGB and BS_ARGB can be used for the creation of the color value. 123 @remark If the rectangular is not completely inside the screen area, it will be automatically trimmed. 124 */ 125 virtual bool fill(const Common::Rect *pFillRect = 0, uint color = BS_RGB(0, 0, 0)) = 0; 126 127 /** 128 @brief Fills the content of the image with pixel data. 129 @param Pixeldata a vector which cotains the pixel data. They must be present in the color format of the image and there must be enough data available for filling the whole image. 130 @param Offset the offset in Byte in Pixeldata-Vector on which the first pixel to write is located.<br> 131 The default value is 0. 132 @param Stride the distance in Byte between the end of line and the beginning of a new line in Pixeldata-Vector.<br> 133 The default value is 0. 134 @return returns false, if the call failed. 135 @remark A call of this methode is only allowd if IsSetContentAllowed() returns true. 136 */ 137 virtual bool setContent(const byte *pixeldata, uint size, uint offset, uint stride) = 0; 138 139 /** 140 @brief Reads out a pixel of the image. 141 @param X the X-coordinate of the pixel. 142 @param Y the y-coordinate of the pixel. 143 @return Returns the 32-bit color value of the pixel at the given position. 144 @remark This methode should not be used in no way to read out bigger parts of the image because the method is very slow. The method is rather intended for reading out single pixels of the image.. 145 */ 146 virtual uint getPixel(int x, int y) = 0; 147 148 //@{ 149 /** @name Information methodes */ 150 151 /** 152 @brief Checks, if it is allowed to call BS_Image Blit(). 153 @return Returns false, if a Blit() call is not allowed at this object. 154 */ 155 virtual bool isBlitSource() const = 0; 156 157 /** 158 @brief Checks, if the BS_Image can be a target image for a Blit call. 159 @return Returns false, if a Blit() call with this object as an target is not allowed. 160 */ 161 virtual bool isBlitTarget() const = 0; 162 163 /** 164 @brief Returns true, if the BS_Image is allowed to be scaled by a Blit() call. 165 */ 166 virtual bool isScalingAllowed() const = 0; 167 168 /** 169 @brief Returns true, if the BS_Image is allowed to be filled by a Fill() call. 170 */ 171 virtual bool isFillingAllowed() const = 0; 172 173 /** 174 @brief Returns true, if the BS_Image is allowed to be displayed with an alpha value. 175 */ 176 virtual bool isAlphaAllowed() const = 0; 177 178 /** 179 @brief Return true, if the BS_Image is allowed to be displayed with color modulation by a Blit() call 180 */ 181 virtual bool isColorModulationAllowed() const = 0; 182 183 /** 184 @brief Returns true, if the content of the BS_Image is allowed to be replaced by call of SetContent(). 185 */ 186 virtual bool isSetContentAllowed() const = 0; 187 isSolid()188 virtual bool isSolid() const { return false; } 189 190 //@} 191 }; 192 193 } // End of namespace Sword25 194 195 #endif 196