GUIScript: Make LoadSymbol return an object.
[gemrb.git] / gemrb / core / ImageMgr.cpp
blobc38c4866f43a2a2467191fc2aced8d4c0c37050d
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "ImageMgr.h"
23 #include "win32def.h"
25 #include "ImageFactory.h"
26 #include "Interface.h"
27 #include "Video.h"
29 const TypeID ImageMgr::ID = { "ImageMgr" };
31 ImageMgr::ImageMgr(void)
35 ImageMgr::~ImageMgr(void)
39 Bitmap* ImageMgr::GetBitmap()
41 unsigned int height = GetHeight();
42 unsigned int width = GetWidth();
43 Bitmap *data = new Bitmap(width, height);
45 printMessage("ImageMgr", "Don't know how to handle 24bit bitmap from ", WHITE);
46 printf( "%s...", str->filename );
47 printStatus( "ERROR", LIGHT_RED );
49 Sprite2D *spr = GetSprite2D();
51 for (unsigned int y = 0; y < height; y++) {
52 for (unsigned int x = 0; x < width; x++) {
53 data->SetAt(x,y, spr->GetPixel(x,y).r);
57 core->GetVideoDriver()->FreeSprite(spr);
59 return data;
62 Image* ImageMgr::GetImage()
64 unsigned int height = GetHeight();
65 unsigned int width = GetWidth();
66 Image *data = new Image(width, height);
68 Sprite2D *spr = GetSprite2D();
70 for (unsigned int y = 0; y < height; y++) {
71 for (unsigned int x = 0; x < width; x++) {
72 data->SetPixel(x,y, spr->GetPixel(x,y));
76 core->GetVideoDriver()->FreeSprite(spr);
78 return data;
81 void ImageMgr::GetPalette(int /*colors*/, Color* /*pal*/)
83 printMessage("ImageMgr", "Can't get non-existant palette from ", WHITE);
84 printf("%s... ", str->filename);
85 printStatus("ERROR", LIGHT_RED);
88 ImageFactory* ImageMgr::GetImageFactory(const char* ResRef)
90 ImageFactory* fact = new ImageFactory( ResRef, GetSprite2D() );
91 return fact;