MaskImage on an individual frame

BlitzPlus Forums/BlitzPlus Programming/MaskImage on an individual frame

I am loading a sequence of images and copying them into a Image that had the correct number of frames (created with CreateImage w,h,numFrames). In order to get the individual frames to carry over the transparency from the original image I first clear the frame to magenta before copying the new frame data over. Then I need to mask that frame. I cannot figure out anyway to do this with BlitzPlus. Any ideas would be appreciated.

Code snippet

Global gImages = 0
Const kNumInSeq = 52

Function LoadImages()

Local i

gImages = CreateImage 100,150,kNumInSeq

For i = 0 to kNumInSeq-1

LoadOneInSeq( i )

Next

; I am in graphics mode so reset the back buffer
SetBuffer BackBuffer()

End Function

Function LoadOneInSeq( index )

Local tempImage, hBuffer

; I am looping through the number of images
; here which is what index represents. Assume
; index is between 0 and 51

; Load in a graphic
tempImage = LoadImage Str(index)+".png"

; Set our buffer to the correct image frame
SetBuffer ImageBuffer( gImages,index )

; Set the clear color to magenta
ClsColor 255,0,255

; Clear my image buffer to magenta
Cls

; now draw the card image that I loaded into
; the current frame buffer
DrawImage tempImage, 0, 0

hBuffer = GraphicsBuffer()

; This does NOT work. Apparently hBuffer is
; Not a valid pointer to the image frame I want.
MaskImage hBuffer,255,0,255

FreeImage tempImage

End Function

I figured out a work around. Instead of using 255,0,255 for the clear color, I use black. Since this is automatically treated as transparency by Blitz I get the behavior I want. I didn't like that default use of 0,0,0 as transparency... Until now!

I always use black too: i dont know too much about the depths of MaskImage, but i figrue the less preparing that has to be done by me, the better.

Wouldn't you just use 'MaskImage gImages,255,0,255' at the end of the code instead of the 'hbuffer' stuff?

Yeah, (MaskImage only accepts image handles not buffers)
and when you paste the image, just use DrawBlock and the magenta will be acrried over(=>No Cls needed)