1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// BitmapData_as.h: ActionScript "BitmapData" class, for Gnash.
//
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#ifndef GNASH_ASOBJ_BITMAPDATA_H
#define GNASH_ASOBJ_BITMAPDATA_H
#ifdef HAVE_CONFIG_H
#include "gnashconfig.h"
#endif
#include "smart_ptr.h"
#include "as_object.h"
namespace gnash {
class as_function;
class as_object;
class BitmapData_as: public as_object
{
typedef std::vector<boost::uint32_t> BitmapArray;
public:
// The constructor sets the fill colour and the
// immutable size of the bitmap, as well as whether
// it can handle transparency or not.
BitmapData_as(size_t width, size_t height,
bool transparent, boost::uint32_t fillColor);
size_t getWidth() const { return _width; }
size_t getHeight() const { return _height; }
bool isTransparent() const { return _transparent; }
const BitmapArray& getBitmapData() const
{
return _bitmapData;
}
// Returns an unsigned int representation of the pixel
// at (x, y) either with or without transparency.
boost::int32_t getPixel(int x, int y, bool transparency) const;
// Fill the bitmap with a colour starting at x, y
void fillRect(int x, int y, int w, int h, boost::uint32_t color);
// Free the bitmap data (clear the array)
void dispose();
private:
// The width of the image, max 2880. This is immutable.
const size_t _width;
// The height of the image, max 2880. This is immutable.
const size_t _height;
// Whether the image is transparent. This is immutable.
const bool _transparent;
// A static array of 32-bit values holding the actual bitmap data.
// The maximum size is 2880 x 2880 * 4 bytes = 33177600 bytes.
BitmapArray _bitmapData;
};
/// Initialize the global BitmapData class
void BitmapData_class_init(as_object& global);
as_function* getFlashDisplayBitmapDataConstructor();
} // end of gnash namespace
// __GNASH_ASOBJ_BITMAPDATA_H__
#endif
|