creaturesImage work: add mutableCopy and tint methods to the base class (and change...
[openc2e.git] / creaturesImage.h
blobd99d565a130b830ee4438e671e5ee7c96f0ba6e6
1 /*
2 * creaturesImage.h
3 * openc2e
5 * Created by Alyssa Milburn on Sat May 22 2004.
6 * Copyright (c) 2004-2008 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef _CREATURESIMAGE_H
21 #define _CREATURESIMAGE_H
23 #include <string>
24 #include <fstream>
25 #include <cassert>
26 #include <boost/shared_ptr.hpp>
28 enum imageformat { if_paletted, if_16bit, if_16bitcompressed, if_32bit };
30 unsigned int bitDepthOf(imageformat f);
32 class creaturesImage {
33 friend class fileSwapper;
35 protected:
36 unsigned int m_numframes;
37 unsigned short *widths, *heights;
38 void **buffers;
39 bool is_565;
40 imageformat imgformat;
41 bool is_mutable;
43 std::ifstream *stream;
44 std::string name;
46 public:
47 creaturesImage(std::string n = std::string()) { stream = 0; name = n; }
48 virtual ~creaturesImage() { if (stream) delete stream; }
49 bool is565() { return is_565; }
50 imageformat format() { return imgformat; }
51 unsigned int numframes() { return m_numframes; }
52 unsigned int width(unsigned int frame) { return widths[frame]; }
53 unsigned int height(unsigned int frame) { return heights[frame]; }
54 void *data(unsigned int frame) { return buffers[frame]; }
55 std::string getName() { return name; }
57 virtual bool transparentAt(unsigned int frame, unsigned int x, unsigned int y);
58 virtual boost::shared_ptr<creaturesImage> mutableCopy();
59 virtual void tint(unsigned char r, unsigned char g, unsigned char b, unsigned char rotation, unsigned char swap);
62 #endif
63 /* vim: set noet: */