ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

transparent_surface.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRAPHICS_TRANSPARENTSURFACE_H
00024 #define GRAPHICS_TRANSPARENTSURFACE_H
00025 
00026 #include "graphics/surface.h"
00027 #include "graphics/transform_struct.h"
00028 
00029 /*
00030  * This code is based on Broken Sword 2.5 engine
00031  *
00032  * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
00033  *
00034  * Licensed under GNU GPL v2
00035  *
00036  */
00037 
00038 #ifdef SCUMM_LITTLE_ENDIAN
00039 #define TS_RGB(R,G,B)       ((0xff << 24) | ((R) << 16) | ((G) << 8) | (B))
00040 #define TS_ARGB(A,R,G,B)    (((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
00041 #else
00042 #define TS_RGB(R,G,B)       (((R) << 24) | ((G) << 16) | (B << 8) | 0xff)
00043 #define TS_ARGB(A,R,G,B)    (((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
00044 #endif
00045 
00046 namespace Graphics {
00047 
00048 // Enums
00052 enum FLIP_FLAGS {
00054     FLIP_NONE = 0,
00056     FLIP_H = 1,
00058     FLIP_V = 2,
00060     FLIP_HV = FLIP_H | FLIP_V,
00062     FLIP_VH = FLIP_H | FLIP_V
00063 };
00064 
00065 enum AlphaType {
00066     ALPHA_OPAQUE = 0,
00067     ALPHA_BINARY = 1,
00068     ALPHA_FULL = 2
00069 };
00070 
00071 enum TFilteringMode {
00072     FILTER_NEAREST = 0,
00073     FILTER_BILINEAR = 1
00074 };
00075 
00079 struct TransparentSurface : public Graphics::Surface {
00080     TransparentSurface();
00081     TransparentSurface(const Graphics::Surface &surf, bool copyData = false);
00082 
00091     static PixelFormat getSupportedPixelFormat() {
00092         return PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
00093     }
00094 
00095     void setColorKey(char r, char g, char b);
00096     void disableColorKey();
00097 
00125     Common::Rect blit(Graphics::Surface &target, int posX = 0, int posY = 0,
00126                       int flipping = FLIP_NONE,
00127                       Common::Rect *pPartRect = nullptr,
00128                       uint color = TS_ARGB(255, 255, 255, 255),
00129                       int width = -1, int height = -1,
00130                       TSpriteBlendMode blend = BLEND_NORMAL);
00131     Common::Rect blitClip(Graphics::Surface &target, Common::Rect clippingArea,
00132                         int posX = 0, int posY = 0,
00133                         int flipping = FLIP_NONE,
00134                         Common::Rect *pPartRect = nullptr,
00135                         uint color = TS_ARGB(255, 255, 255, 255),
00136                         int width = -1, int height = -1,
00137                         TSpriteBlendMode blend = BLEND_NORMAL);
00138 
00139     void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false);
00140 
00149     template <TFilteringMode filteringMode>
00150     TransparentSurface *scaleT(uint16 newWidth, uint16 newHeight) const;
00151 
00152     TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const;
00153 
00161     template <TFilteringMode filteringMode>
00162     TransparentSurface *rotoscaleT(const TransformStruct &transform) const;
00163 
00164     TransparentSurface *rotoscale(const TransformStruct &transform) const;
00165 
00166     TransparentSurface *convertTo(const PixelFormat &dstFormat, const byte *palette = 0) const;
00167 
00168     float getRatio() {
00169         if (!w)
00170             return 0;
00171 
00172         return h / (float)w;
00173     }
00174 
00175     AlphaType getAlphaMode() const;
00176     void setAlphaMode(AlphaType);
00177 private:
00178     AlphaType _alphaMode;
00179 
00180     template <typename Size>
00181     void scaleNN(int *scaleCacheX, TransparentSurface *target) const;
00182 };
00183 
00189 /*struct SharedPtrTransparentSurfaceDeleter {
00190     void operator()(TransparentSurface *ptr) {
00191         ptr->free();
00192         delete ptr;
00193     }
00194 };*/
00195 
00196 } // End of namespace Graphics
00197 
00198 
00199 #endif


Generated on Sat Jul 13 2019 05:01:17 for ResidualVM by doxygen 1.7.1
curved edge   curved edge