prev | index | next

FLASH8 - Copy pixels
8
24
23555 bytes
1173 bytes
2005-10-19 00:00:00
2007-09-05 13:54:47
Oldes (oliva.david@seznam.cz)


Simple example how to use function copyPixels (fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects).

(swf8-copypixels.rswf)
background 255.255.255
bmp_picture: bitmap %bitmaps/holky.jpg
exportAssets [bmp_picture "picture"]
es: EmptySprite
picture: place es
doAction [
    bmpSource: flash.display.BitmapData.loadBitmap("picture")
    bmpTarget: make BitmapData! [400 300 false #FFFFFF]
    picture.attachBitmap(bmpTarget 1)
    
    copyPicturePart: func[][
        var rx: -30 + random 370
        var ry: -30 + random 270
        var w:  30 + random 30
        var h:  30 + random 30
        var srcRectangle: make Rectangle! [(rx) (ry) (rx + w) (ry + h)]
        var destPoint: make Point! [
            (rx + 5 - random 10)
            (ry + 5 - random 10)
        ]
        bmpTarget.copyPixels(
            bmpSource       ;sourceBitmap:BitmapData
            srcRectangle    ;sourceRect:Rectangle
            destPoint
        )
    ]
    copyPicturePart()
    int: setInterval(copyPicturePart 10)
]
showFrame
end