One way you could do it is by using a template image with two colours to specify the oval you want to cut/copy.
One colour for the actual circle, the other for the remainder of the image rectangle.
Then with a bit of jiggery pokery using the SetMaskColor before and after grabbing the pixmap, you'll have your round snippet! :)
SuperStrict
Graphics 640,480
'Mouse location variables
Local mx:Int, my:Int
'Set the masking color for the first bit to pink
SetMaskColor 255,0,255
'Load the required images, first up, the background
Local background:TImage = LoadImage("Sunset.jpg") ' Taken from My Pictures/Sample Pictures
'Load up the 'snapper' circle, which contains only two colours, one for the oval, and one for the outer
'part of the circle.
Local snapperCircle:TImage = LoadImage("ovalSnap.bmp")
'Get the size of the image
Local snapperWidth:Int = ImageWidth(snapperCircle)
Local snapperHeight:Int = ImageHeight(snapperCircle)
'Variable to store if the user has clicked the mouse
Local clicked:Byte = False
'Change the cls color
SetClsColor 100,100,255
Repeat
Cls
'Pickup mouse location
mx = MouseX()
my = MouseY()
'Checked to see if the user has clicked the button
If clicked = False
'If not, draw the background
DrawImage background,0,0
'Check for input
If MouseHit(1)
'Let the app know if the user has clicked the mouse
clicked = True
'Quickly draw the snapperCircle
DrawImage snapperCircle,mx,my
'Create a pixmap
Local pixmap:TPixmap = CreatePixmap(snapperWidth,snapperHeight,PF_RGB888)
'Grab the pixmap from the background
pixmap = GrabPixmap(mx,my,snapperWidth,snapperHeight)
'Set the mask colour to the same as the outer colour in the 'snapperCircle' TImage
SetMaskColor 128,0,128
'Load the pixmap into original 'snapperCircle' TImage
snapperCircle = LoadImage(pixmap)
End If
End If
'Draw the snapperCircle at the mouse location
DrawImage snapperCircle,mx,my
Flip
Until KeyDown(KEY_ESCAPE)
End
Download with media: http://dabz.syntaxbomb.com/Files/ovalSnap.zip
You may be able to resize the snapper template with scaling, or even use various pre-created template sizes, or build them in ze codez!
All it takes is to think outside the box, erm, I mean, circle! ;) hehehe
Dabz
|