summaryrefslogtreecommitdiff
path: root/src/resources/image.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-02-27 00:59:15 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-02-27 00:59:15 +0000
commit500676abe3e03d63c192663db78d5d1f963c18f4 (patch)
treeb623f6aa5fdbf3b08639830e5ea19104d390f364 /src/resources/image.cpp
parenteedd5a3dea2061d247c82b4d912d5f82327668c6 (diff)
downloadmana-client-500676abe3e03d63c192663db78d5d1f963c18f4.tar.gz
mana-client-500676abe3e03d63c192663db78d5d1f963c18f4.tar.bz2
mana-client-500676abe3e03d63c192663db78d5d1f963c18f4.tar.xz
mana-client-500676abe3e03d63c192663db78d5d1f963c18f4.zip
Functions create() and fillWithColor() into image class.
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r--src/resources/image.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index d30d6c92..cefb9d88 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -44,6 +44,11 @@ Image::Image(GLuint image, int width, int height, int texWidth, int texHeight):
alpha = 1.0f;
}
+Image::Image():image(image)
+{
+ alpha = 1.0f;
+}
+
Image::~Image()
{
unload();
@@ -361,7 +366,30 @@ float Image::getAlpha()
return alpha;
}
+bool Image::create(int width, int height)
+{
+ image = SDL_AllocSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0);
+ if ( image )
+ return true;
+ else
+ return false;
+}
+void Image::fillWithColor(unsigned char red, unsigned char green, unsigned blue)
+{
+ Uint32 boxColor = SDL_MapRGB(SDL_GetVideoSurface()->format, red, green, blue);
+ if ( image )
+ {
+ SDL_Rect sourceRect;
+ sourceRect.x = sourceRect.y = 0;
+ sourceRect.w = image->w;
+ sourceRect.h = image->h;
+ SDL_FillRect(image, &sourceRect, boxColor);
+ }
+}
+
+//============================================================================
+// SubImage Class
//============================================================================
#ifndef USE_OPENGL