2 // Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (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
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 // Test case for BitmapData ActionScript class
20 // compile this test case with Ming makeswf, and then
21 // execute it like this gnash -1 -r 0 -v out.swf
23 rcsid
="$Id: BitmapData.as,v 1.3 2008/06/20 13:28:56 bwy Exp $";
28 #if OUTPUT_VERSION
< 8
30 check_equals
(typeof(flash
), 'undefined');
36 Bitmap = flash
.display
.BitmapData;
37 check_equals
(typeof(Bitmap), 'function');
38 check_equals
(typeof(Bitmap.prototype
), 'object');
39 check
(Bitmap.prototype
.hasOwnProperty
('applyFilter'));
40 check
(Bitmap.prototype
.hasOwnProperty
('clone'));
41 check
(Bitmap.prototype
.hasOwnProperty
('colorTransform'));
42 check
(Bitmap.prototype
.hasOwnProperty
('copyChannel'));
43 check
(Bitmap.prototype
.hasOwnProperty
('copyPixels'));
44 check
(Bitmap.prototype
.hasOwnProperty
('dispose'));
45 check
(Bitmap.prototype
.hasOwnProperty
('draw'));
46 check
(Bitmap.prototype
.hasOwnProperty
('fillRect'));
47 check
(Bitmap.prototype
.hasOwnProperty
('floodFill'));
48 check
(Bitmap.prototype
.hasOwnProperty
('generateFilterRect'));
49 check
(Bitmap.prototype
.hasOwnProperty
('getColorBoundsRect'));
50 check
(Bitmap.prototype
.hasOwnProperty
('getPixel'));
51 check
(Bitmap.prototype
.hasOwnProperty
('getPixel32'));
52 check
(Bitmap.prototype
.hasOwnProperty
('hitTest'));
53 check
(Bitmap.prototype
.hasOwnProperty
('merge'));
54 check
(Bitmap.prototype
.hasOwnProperty
('noise'));
55 check
(Bitmap.prototype
.hasOwnProperty
('paletteMap'));
56 check
(Bitmap.prototype
.hasOwnProperty
('perlinNoise'));
57 check
(Bitmap.prototype
.hasOwnProperty
('pixelDissolve'));
58 check
(Bitmap.prototype
.hasOwnProperty
('scroll'));
59 check
(Bitmap.prototype
.hasOwnProperty
('setPixel'));
60 check
(Bitmap.prototype
.hasOwnProperty
('setPixel32'));
61 check
(Bitmap.prototype
.hasOwnProperty
('threshold'));
62 check
(Bitmap.prototype
.hasOwnProperty
("height"));
63 check
(Bitmap.prototype
.hasOwnProperty
("width"));
64 check
(Bitmap.prototype
.hasOwnProperty
("rectangle"));
65 check
(Bitmap.prototype
.hasOwnProperty
("transparent"));
67 check
(Bitmap.hasOwnProperty
("RED_CHANNEL"));
68 check
(Bitmap.hasOwnProperty
("GREEN_CHANNEL"));
69 check
(Bitmap.hasOwnProperty
("BLUE_CHANNEL"));
70 check
(Bitmap.hasOwnProperty
("ALPHA_CHANNEL"));
72 check
(!Bitmap.prototype
.hasOwnProperty
('loadBitmap'));
73 check
(Bitmap.hasOwnProperty
('loadBitmap'));
75 Rectangle = flash
.geom
.Rectangle;
77 //-------------------------------------------------------------
79 //-------------------------------------------------------------
82 check_equals
(typeof(bmp
), "undefined");
84 bmp
= new Bitmap(10, 10);
85 check_equals
(typeof(bmp
), 'object');
86 check
(bmp
instanceof Bitmap);
87 check
(!bmp
.hasOwnProperty
("height"));
88 check
(!bmp
.hasOwnProperty
("width"));
89 check
(!bmp
.hasOwnProperty
("rectangle"));
90 check
(!bmp
.hasOwnProperty
("transparent"));
91 check_equals
(bmp
.height
, 10);
92 check_equals
(bmp
.width
, 10);
93 check_equals
(bmp
.transparent
, true);
94 check_equals
(bmp
.rectangle
.toString
(), "(x=0, y=0, w=10, h=10)");
95 check
(bmp
.rectangle instanceOf flash
.geom
.Rectangle);
96 check_equals
(bmp
.getPixel
(1, 1), 16777215);
97 check_equals
(bmp
.getPixel
(9, 9), 16777215);
98 check_equals
(bmp
.getPixel32
(1, 1), -1);
100 bmp
= new Bitmap(10, 10, true);
101 check_equals
(bmp
.getPixel32
(1, 1), -1);
102 bmp
= new Bitmap(10, 10, false);
103 check_equals
(bmp
.getPixel32
(1, 1), -1);
106 bmp
= new Bitmap(20, 30, false, 0xeeddee);
107 check_equals
(bmp
.height
, 30);
108 check_equals
(bmp
.width
, 20);
109 check_equals
(bmp
.transparent
, false);
110 check_equals
(bmp
.rectangle
.toString
(), "(x=0, y=0, w=20, h=30)");
111 check_equals
(bmp
.getPixel
(1, 1), 0xeeddee);
112 check_equals
(bmp
.getPixel32
(1, 1), -1122834);
116 check_equals
(bmp
.getPixel
(50, 1), 0);
117 check_equals
(bmp
.getPixel
(0, 0), 15654382);
118 check_equals
(bmp
.getPixel
(-2, -5), 0);
120 // 0,0 is inside, 20, 30 outside a 20x30 bitmap.
121 check_equals
(bmp
.getPixel
(20, 30), 0);
124 // 2880 is the maximum, 1 the minimum. Returns
125 // undefined if the dimensions are invalid.
126 bmp
= new Bitmap(10000, 3);
127 check_equals
(typeof(bmp
), "undefined");
128 check_equals
(bmp
.height
, undefined);
130 bmp
= new Bitmap(0, 10000);
131 check_equals
(bmp
, undefined);
132 check_equals
(bmp
.height
, undefined);
134 bmp
= new Bitmap(2880, 2880);
135 check_equals
(typeof(bmp
), "object");
136 check_equals
(bmp
.height
, 2880);
138 bmp
= new Bitmap(2880, 2881);
139 check_equals
(typeof(bmp
), "undefined");
140 check_equals
(bmp
.height
, undefined);
142 bmp
= new Bitmap(0, 2880);
143 check_equals
(bmp
, undefined);
144 check_equals
(bmp
.height
, undefined);
146 bmp
= new Bitmap(2879, 2879);
147 check_equals
(typeof(bmp
), "object");
148 check_equals
(bmp
.height
, 2879);
150 bmp
= new Bitmap(0, 2879);
151 check_equals
(bmp
, undefined);
152 check_equals
(bmp
.height
, undefined);
154 bmp
= new Bitmap(-1, 10, false, 0xff);
155 check_equals
(bmp
, undefined);
156 check_equals
(bmp
.height
, undefined);
158 // --------------------
159 // setPixel, setPixel32
160 // --------------------
162 tr
= new Bitmap(30, 30, true);
163 ntr
= new Bitmap(30, 30, false);
165 // Premultiplication?
166 tr
.setPixel32
(2, 2, 0x44);
167 xcheck_equals
(tr
.getPixel
(2, 2), 0x00);
168 xcheck_equals
(tr
.getPixel32
(2, 2), 0);
170 // Premultiplication?
171 tr
.setPixel32
(2, 2, 0x220000aa);
172 xcheck_equals
(tr
.getPixel
(2, 2), 0xac);
173 xcheck_equals
(tr
.getPixel32
(2, 2), 0x220000ac);
175 tr
.setPixel32
(2, 2, 0xff0000aa);
176 check_equals
(tr
.getPixel
(2, 2), 0xaa);
177 check_equals
(tr
.getPixel32
(2, 2), -16777046);
179 tr
.setPixel
(3, 3, 0xff);
180 check_equals
(tr
.getPixel
(3, 3), 0xff);
181 check_equals
(tr
.getPixel32
(3, 3), -16776961);
183 // Premultiplication?
184 tr
.setPixel32
(4, 4, 0x44444444);
185 xcheck_equals
(tr
.getPixel
(4, 4), 0x434343);
186 xcheck_equals
(tr
.getPixel32
(4, 4), 0x44434343);
188 tr
.setPixel32
(4, 4, 0x10101010);
189 check_equals
(tr
.getPixel
(4, 4), 0x101010);
190 check_equals
(tr
.getPixel32
(4, 4), 0x10101010);
192 // Premultiplication?
193 tr
.setPixel32
(4, 4, 0x43434343);
194 xcheck_equals
(tr
.getPixel
(4, 4), 0x444444);
195 xcheck_equals
(tr
.getPixel32
(4, 4), 0x43444444);
197 ntr
.setPixel
(5, 5, 0xff);
198 check_equals
(ntr
.getPixel
(5, 5), 0xff);
199 check_equals
(ntr
.getPixel32
(5, 5), -16776961);
201 ntr
.setPixel32
(6, 6, 0x44444444);
202 check_equals
(ntr
.getPixel
(6, 6), 0x444444);
203 check_equals
(ntr
.getPixel32
(6, 6), -12303292);
209 bmp
= new Bitmap(20, 20, false);
210 bmp
.floodFill
(10, 10, 0x0000ff00);
212 check_equals
(bmp
.getPixel
(10, 10), 0x0000ff00);
213 bmp
.floodFill
(5, 5, 0x000000ff);
214 check_equals
(bmp
.getPixel
(10, 0), 0x000000ff);
216 mc
= this.createEmptyMovieClip
("mc", this.getNextHighestDepth
());
217 mc
.attachBitmap
(bmp
, this.getNextHighestDepth
());
219 b
= new Bitmap(200, 200, false, 0xffffff);
220 b
.fillRect
(new Rectangle(10, 10, 10, 10), 0x00ff00);
221 b
.fillRect
(new Rectangle(50, 20, 10, 10), 0x00ff00);
222 b
.fillRect
(new Rectangle(50, 70, 20, 20), 0x00ff00);
223 b
.fillRect
(new Rectangle(50, 70, 20, 20), 0x00ff00);
225 b
.fillRect
(new Rectangle(120, 100, 10, 10), 0x0000ff);
226 b
.fillRect
(new Rectangle(130, 90, 10, 10), 0xffff00);
227 b
.fillRect
(new Rectangle(140, 100, 10, 10), 0x00ffff);
228 b
.fillRect
(new Rectangle(130, 110, 10, 10), 0xff00ff);
230 check_equals
(b
.getPixel
(1, 1), 0xffffff);
231 check_equals
(b
.getPixel
(135, 105), 0xffffff);
233 // This is done twice deliberately to make sure Gnash doesn't hang!
234 b
.floodFill
(0, 0, 0);
235 b
.floodFill
(0, 0, 0);
236 check_equals
(b
.getPixel
(1, 1), 0x0);
237 check_equals
(b
.getPixel
(190, 190), 0x0);
238 check_equals
(b
.getPixel
(135, 105), 0xffffff);
240 b
.floodFill
(135, 105, 0xee1111);
241 check_equals
(b
.getPixel
(1, 1), 0x0);
242 check_equals
(b
.getPixel
(190, 190), 0x0);
243 check_equals
(b
.getPixel
(135, 105), 0xee1111);
245 mc2
= this.createEmptyMovieClip
("mc2", this.getNextHighestDepth
());
246 mc2
.attachBitmap
(b
, this.getNextHighestDepth
());
252 bmp
= new Bitmap(20, 20, false);
253 r
= new Rectangle(2, 2, 5, 5);
254 bmp
.fillRect
(r
, 0xff1100);
255 check_equals
(bmp
.getPixel
(1, 1), 0xffffff);
256 check_equals
(bmp
.getPixel
(2, 2), 0xff1100);
257 check_equals
(bmp
.getPixel
(2, 5), 0xff1100);
258 check_equals
(bmp
.getPixel
(5, 2), 0xff1100);
259 check_equals
(bmp
.getPixel
(2, 6), 0xff1100);
260 check_equals
(bmp
.getPixel
(6, 6), 0xff1100);
261 check_equals
(bmp
.getPixel
(6, 7), 0xffffff);
262 check_equals
(bmp
.getPixel
(7, 6), 0xffffff);
264 r
= new Rectangle(-2, -2, 8, 8);
265 bmp
.fillRect
(r
, 0x00ff00);
266 check_equals
(bmp
.getPixel
(1, 1), 0x00ff00);
269 r
= new Rectangle(18, 18, -4, -4);
270 bmp
.fillRect
(r
, 0x0000ff);
271 check_equals
(bmp
.getPixel
(7, 6), 0xffffff);
273 r
= new Rectangle(18, 18, 200, 200);
274 bmp
.fillRect
(r
, 0x0000ff);
275 check_equals
(bmp
.getPixel
(19,19), 0x0000ff);
277 // Doesn't have to be a rectangle
278 g
= {x
: 15, y
: 15, width
: 2, height
: 2};
279 bmp
.fillRect
(g
, 0xff00ff);
280 check_equals
(bmp
.getPixel
(16, 16), 0xff00ff);
282 // Transparency (this bitmap is not transparent).
283 g
= {x
: 18, y
: 2, width
: 7, height
: 7};
284 bmp
.fillRect
(g
, 0xddff00ff);
285 check_equals
(bmp
.getPixel32
(18, 2), -65281);
287 mc
.attachBitmap
(bmp
, this.getNextHighestDepth
());
289 // Transparency (transparent bitmap). Fill just obliterates
290 // what was there, even if it's transparent.
291 bmp
= new Bitmap(20, 20, true);
292 r
= new Rectangle(1, 1, 10, 10);
293 bmp
.fillRect
(r
, 0xff00ff00);
294 r
= new Rectangle(2, 2, 9, 9);
295 bmp
.fillRect
(r
, 0x99ff1100);
296 check_equals
(bmp
.getPixel32
(3, 3), -1711337216);
298 mc
.attachBitmap
(bmp
, this.getNextHighestDepth
());
301 check_equals
(bmp
.height
, -1);
302 check_equals
(bmp
.width
, -1);
303 check_equals
(bmp
.transparent
, -1);
304 check_equals
(typeof(bmp
.rectangle
), "number");
305 check_equals
(bmp
.rectangle
, -1);
306 check_equals
(bmp
.rectangle
.toString
(), "-1");
308 check
(bmp instanceOf
Bitmap);
310 check_equals
(bmp
.height
, -1);
312 bmp
= new Bitmap(20, 10, true);
313 backup
= flash
.geom
.Rectangle;
314 flash
.geom
.Rectangle = 2;
315 check_equals
(bmp
.rectangle
, -1);
317 flash
.geom
.Rectangle = function (x
, y
, w
, h
)
324 check_equals
(bmp
.rectangle
.toString
(), "[object Object]");
326 flash
.geom
.Rectangle = function (x
, y
, w
, h
)
329 check_equals
(bmp
.rectangle
.toString
(), "[object Object]");
331 flash
.geom
.Rectangle = function ()
334 check_equals
(bmp
.rectangle
.toString
(), "[object Object]");
336 flash
.geom
.Rectangle = backup
;
337 check_equals
(bmp
.rectangle
.toString
(), "(x=0, y=0, w=20, h=10)");
343 // First we check that all user-defined transformations are ignored.
345 // Note: at the corners of these tests antialiasing makes a difference. The
346 // value can vary according to the transformation of the clip. We're not
347 // really interested in the exact values of anti-aliased pixels.
349 d
= _root
.createEmptyMovieClip
("tar", 600);
350 d
.beginFill
(0x00ff00);
358 d
.beginFill
(0xff0000);
365 // 100x100, no transparency
366 b
= new Bitmap(100, 100, false);
368 check_equals
(b
.getPixel
(1, 1), 0xffffff);
369 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
370 check_equals
(b
.getPixel
(19, 20), 0xffffff);
371 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
372 check_equals
(b
.getPixel
(50, 25), 0xffffff);
373 check_equals
(b
.getPixel
(55, 55), 0xff0000);
377 check_equals
(b
.getPixel
(1, 1), 0xffffff);
378 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
379 check_equals
(b
.getPixel
(19, 20), 0xffffff);
380 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
381 check_equals
(b
.getPixel
(50, 25), 0xffffff);
382 check_equals
(b
.getPixel
(55, 55), 0xff0000);
384 // User-defined translation makes no difference.
387 check_equals
(b
.getPixel
(1, 1), 0xffffff);
388 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
389 check_equals
(b
.getPixel
(19, 20), 0xffffff);
390 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
391 check_equals
(b
.getPixel
(50, 25), 0xffffff);
392 check_equals
(b
.getPixel
(55, 55), 0xff0000);
394 // User defined transform makes no difference.
397 check_equals
(b
.getPixel
(1, 1), 0xffffff);
398 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
399 check_equals
(b
.getPixel
(19, 20), 0xffffff);
400 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
401 check_equals
(b
.getPixel
(50, 25), 0xffffff);
402 check_equals
(b
.getPixel
(55, 55), 0xff0000);
404 // User defined transform makes no difference.
407 check_equals
(b
.getPixel
(1, 1), 0xffffff);
408 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
409 check_equals
(b
.getPixel
(19, 20), 0xffffff);
410 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
411 check_equals
(b
.getPixel
(50, 25), 0xffffff);
412 check_equals
(b
.getPixel
(55, 55), 0xff0000);
414 // Color transform the old way (no difference).
415 c
= new Color("_level0.tar");
417 check_equals
(b
.getPixel
(1, 1), 0xffffff);
418 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
419 check_equals
(b
.getPixel
(19, 20), 0xffffff);
420 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
421 check_equals
(b
.getPixel
(50, 25), 0xffffff);
422 check_equals
(b
.getPixel
(55, 55), 0xff0000);
424 // Color transform the new way.
425 var tr
= d
.transform
;
426 tr
.colorTransform
= new flash
.geom
.ColorTransform(0.5, 0.5, 0.5, 0.5, 34, 34, 34, 34);
428 check_equals
(b
.getPixel
(1, 1), 0xffffff);
429 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
430 check_equals
(b
.getPixel
(19, 20), 0xffffff);
431 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
432 check_equals
(b
.getPixel
(50, 25), 0xffffff);
433 check_equals
(b
.getPixel
(55, 55), 0xff0000);
435 dom
= new flash
.geom
.Matrix();
436 dom
.rotate
(Math.PI
/ 4);
439 check_equals
(b
.getPixel
(1, 1), 0xffffff);
440 check_equals
(b
.getPixel
(21, 21), 0x00ff00);
441 check_equals
(b
.getPixel
(19, 20), 0xffffff);
442 check_equals
(b
.getPixel
(79, 79), 0x00ff00);
443 check_equals
(b
.getPixel
(50, 25), 0xffffff);
444 check_equals
(b
.getPixel
(55, 55), 0xff0000);
446 // Test behaviour of BitmapData.draw with masks.
448 // 1. The MovieClip is drawn with the custom transform
449 // 2. The mask is drawn with its current transform
450 near
= function(bitmap
, x
, y
, val
) {
452 col
= bitmap
.getPixel
(x
, y
);
453 col_r
= (col
& 0xff0000) >> 16;
454 col_g
= (col
& 0xff00) >> 8;
455 col_b
= (col
& 0xff);
456 val_r
= (val
& 0xff0000) >> 16;
457 val_g
= (val
& 0xff00) >> 8;
458 val_b
= (val
& 0xff);
459 if (Math.abs
(col_r
- val_r
) > tol
) return false;
460 if (Math.abs
(col_b
- val_b
) > tol
) return false;
461 if (Math.abs
(col_g
- val_g
) > tol
) return false;
465 mc
= _root
.createEmptyMovieClip
("mc", 1009);
466 a
= mc
.createEmptyMovieClip
("a", 1090);
467 b
= mc
.createEmptyMovieClip
("b", 1091);
469 mask
= _root
.createEmptyMovieClip
("mask", 1150);
504 // Only for visual checking.
505 disp
= _root
.createEmptyMovieClip
("disp", 1300);
511 // Mask and MovieClip with neutral transform
512 bm
= new flash
.display
.BitmapData(50, 50, false);
515 // A square of the green stripe is visible.
516 check
(near
(bm
, 5, 5, 0xffffff));
517 check
(near
(bm
, 5, 15, 0xffffff));
518 check
(near
(bm
, 5, 25, 0xffffff));
519 check
(near
(bm
, 15, 5, 0xffffff));
520 check
(near
(bm
, 15, 15, 0x00ff00));
521 check
(near
(bm
, 15, 25, 0xffffff));
522 check
(near
(bm
, 25, 5, 0xffffff));
523 check
(near
(bm
, 25, 15, 0xffffff));
524 check
(near
(bm
, 25, 25, 0xffffff));
526 // Mask with neutral transform, MovieClip with different transform
530 bm
= new flash
.display
.BitmapData(50, 50, false);
533 // A square of the green stripe is visible.
534 check
(near
(bm
, 5, 5, 0xffffff));
535 check
(near
(bm
, 5, 15, 0xffffff));
536 check
(near
(bm
, 5, 25, 0xffffff));
537 check
(near
(bm
, 15, 5, 0xffffff));
538 xcheck
(near
(bm
, 15, 15, 0x00ff00));
539 check
(near
(bm
, 15, 25, 0xffffff));
540 check
(near
(bm
, 25, 5, 0xffffff));
541 check
(near
(bm
, 25, 15, 0xffffff));
542 check
(near
(bm
, 25, 25, 0xffffff));
544 disp
.attachBitmap
(bm
, 400);
546 // Mask with different transform, MovieClip with different transform
548 bm
= new flash
.display
.BitmapData(50, 50, false);
551 // A square of the blue stripe is visible.
552 check
(near
(bm
, 5, 5, 0xffffff));
553 check
(near
(bm
, 5, 15, 0xffffff));
554 check
(near
(bm
, 5, 25, 0xffffff));
555 check
(near
(bm
, 15, 5, 0xffffff));
556 check
(near
(bm
, 15, 15, 0xffffff));
557 check
(near
(bm
, 15, 25, 0xffffff));
558 check
(near
(bm
, 25, 5, 0xffffff));
559 xcheck
(near
(bm
, 25, 15, 0x0000ff));
560 check
(near
(bm
, 25, 25, 0xffffff));
562 bm
= new flash
.display
.BitmapData(50, 50, false);
563 bm
.draw
(mc
, new flash
.geom
.Matrix(1, 0, 0, 1, 5, 5));
565 // A bit of the blue and green blue stripe is visible.
566 check
(near
(bm
, 5, 5, 0xffffff));
567 check
(near
(bm
, 5, 15, 0xffffff));
568 check
(near
(bm
, 5, 25, 0xffffff));
569 check
(near
(bm
, 15, 5, 0xffffff));
570 check
(near
(bm
, 15, 15, 0xffffff));
571 check
(near
(bm
, 15, 25, 0xffffff));
572 check
(near
(bm
, 25, 5, 0xffffff));
573 xcheck
(near
(bm
, 23, 15, 0x00ff00));
574 xcheck
(near
(bm
, 25, 15, 0x0000ff));
575 check
(near
(bm
, 25, 25, 0xffffff));
577 bm
= new flash
.display
.BitmapData(10, 10, true, 0x5010eeff);
578 xcheck_equals
(bm
.getPixel32
(5, 5), 0x5010efff);
580 bm
= new flash
.display
.BitmapData(10, 10, true, 0xee11efff);
581 check_equals
(bm
.getPixel32
(5, 5), -300814337);
583 bm
= new flash
.display
.BitmapData(10, 10, true, 0x00011010);
584 check_equals
(bm
.getPixel32
(5, 5), 0x00000000);
586 bm
= new flash
.display
.BitmapData(10, 10, true, 0x0000ffff);
587 check_equals
(bm
.getPixel32
(5, 5), 0x00000000);
589 bm
= new flash
.display
.BitmapData(10, 10, true, 0x000000ff);
590 check_equals
(bm
.getPixel32
(5, 5), 0x00000000);
592 bm
= new flash
.display
.BitmapData(10, 10, true, 0x010000ff);
593 check_equals
(bm
.getPixel32
(5, 5), 0x010000ff);
595 bm
= new flash
.display
.BitmapData(10, 10, true, 0x300000ff);
596 check_equals
(bm
.getPixel32
(5, 5), 0x300000ff);
598 bm
= new flash
.display
.BitmapData(10, 10, true, 0x30ffffff);
599 check_equals
(bm
.getPixel32
(5, 5), 0x30ffffff);
603 orig
= new flash
.display
.BitmapData(10, 10, false, 0x00ff10);
605 orig
.setPixel
(5, 5, 0x0000ff);
607 // Cloning doesn't clone non-native properties.
609 check_equals
(cl
.a
, undefined);
610 check_equals
(cl
.width
, 10);
611 check_equals
(cl
.height
, 10);
612 check_equals
(cl
.getPixel
(2, 2), 0x00ff10);
613 check_equals
(cl
.getPixel
(5, 5), 0x0000ff);
614 check_equals
(typeof(cl
.__proto__
), "object");
615 check_equals
(cl
.__proto__
, orig
.__proto__
);
616 check_equals
(typeof(cl
.constructor
), "function");
617 check_equals
(cl
.constructor
, orig
.constructor
);
619 // The constructor is irrelevant.
620 orig
.constructor
= 10;
621 check_equals
(orig
.constructor
, 10);
623 check_equals
(typeof(cl
.__proto__
), "object");
624 check_equals
(typeof(cl
.constructor
), "function");
626 // The prototype is important.
628 check_equals
(orig
.__proto__
, 8);
630 check_equals
(cl
.__proto__
, undefined);
631 check_equals
(cl
.constructor
, undefined);
633 // What kind of prototype makes this work?
636 o
.clone
= flash
.display
.BitmapData.prototype
.clone
;
640 o
.getPixel
= flash
.display
.BitmapData.prototype
.getPixel
;
643 check_equals
(cl
.__proto__
, o
);
644 check_equals
(cl
.constructor
, 25);
645 check_equals
(cl
.width
, 20);
646 check_equals
(cl
.height
, 21);
647 cl
.__proto__
= flash
.display
.BitmapData.prototype
;
648 check_equals
(cl
.width
, 10);
649 check_equals
(cl
.height
, 10);
651 e
= flash
.display
.BitmapData.prototype
;
653 flash
.display
.BitmapData.prototype
= 8;
654 check_equals
(flash
.display
.BitmapData.prototype
, 8);
656 check_equals
(typeof(cl
.__proto__
), "object");
657 check_equals
(typeof(cl
.constructor
), "function");
659 // The constructor property comes from the original __proto__.
663 check_equals
(typeof(cl
.__proto__
), "object");
664 check_equals
(cl
.constructor
, 98);
666 // Restore to original state!
668 flash
.display
.BitmapData.prototype
= e
;
670 //-------------------------------------------------------------
672 //-------------------------------------------------------------
676 #endif
// OUTPUT_VERSION >= 8