actionscript 3 - AS3 BitmapData Threshold Bug -


the bitmapdata class has threshold method allows check how many pixels satisfy condition (e.g. "<=",">","=="); method not appear work when alpha channel in threshold in range (0,ff), although works on extremes 0 , ff. code used test:

bd = new bitmapdata(16,16,true,0); var i:int = 0; var x:int, y:int; (var a:uint = 0x0; a<=0xff; a++){     x = math.floor(i/16);     y = - x*16; //  trace(x,y);     var col:uint = combineargb(a,0xaa,0xbb,0xcc);     trace('set: '+col.tostring(16));     bd.setpixel32(x,y,col);     var getp:uint = bd.getpixel32(x,y);     trace('get: '+getp.tostring(16));     trace('test threshold @ '+getp.tostring(16)+': '+bd.threshold(bd,bd.rect, new point(),  "==", getp,getp));      i++;  } 

so create 16x16 bitmap data , fill argb value such 1aaabbcc ffaabbcc. as3 not set colours same values requested, manipulated version of them. nevertheless, if set pixel, , use threshold method find value of pixel, work when alpha ff or 0:

set: aabbcc get: 0 test threshold @ 0: 256 // because initialized pixels 0 set: 1aabbcc get: 1ffffff test threshold @ 1ffffff: 0   set: feaabbcc get: feaabbcc test threshold @ feaabbcc: 0 set: ffaabbcc get: ffaabbcc test threshold @ ffaabbcc: 1 

surely if can pixel getpixel32, should same threshold? rule follows:

((pixelvalue & mask) operation (threshold & mask))

mask 0xffffffff default.

trace((0xfeaabbcc & 0xffffffff) == (0xfeaabbcc & 0xffffffff)); // true 

related: post


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -