1
/* ScummVM - Graphic Adventure Engine
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.
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.
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.
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.
27
* This code is based on Broken Sword 2.5 engine
29
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
31
* Licensed under GNU GPL v2
35
#include "sword25/package/packagemanager.h"
36
#include "sword25/gfx/image/pngloader.h"
37
#include "sword25/gfx/image/swimage.h"
41
SWImage::SWImage(const Common::String &filename, bool &result) :
47
PackageManager *pPackage = Kernel::getInstance()->getPackage();
53
pFileData = pPackage->getFile(filename, &fileSize);
55
error("File \"%s\" could not be loaded.", filename.c_str());
59
// Determine image properties
61
if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
62
error("Could not read image properties.");
66
// Uncompress the image
67
byte *pUncompressedData;
68
if (!PNGLoader::decodeImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) {
69
error("Could not decode image.");
76
_imageDataPtr = (uint *)pUncompressedData;
83
delete[] _imageDataPtr;
87
bool SWImage::blit(int posX, int posY,
89
Common::Rect *pPartRect,
91
int width, int height) {
92
error("Blit() is not supported.");
96
bool SWImage::fill(const Common::Rect *pFillRect, uint color) {
97
error("Fill() is not supported.");
101
bool SWImage::setContent(const byte *pixeldata, uint size, uint offset, uint stride) {
102
error("SetContent() is not supported.");
106
uint SWImage::getPixel(int x, int y) {
107
assert(x >= 0 && x < _width);
108
assert(y >= 0 && y < _height);
110
return _imageDataPtr[_width * y + x];
113
} // End of namespace Sword25