|Drawing transparent images to windows
|Page 1 of 1|
|Author:||BackupUser [ Tue Nov 13, 2001 1:58 am ]|
Restored from previous forum. Originally posted by Shagwana.
Right, been a while since i last run pure . But here I am trying to code my 2d map editor init!. I have figured out how to draw images using the drawimage() command and how to have them inverted with the drawingmode() command. The next problem i have is;
How do I draw transparent images to windows? nb : not alfa images!. Say for example I have a game sprite on a blue background (0,0,255). I want to be able to draw the said image to a window, and not have the blue colour drawn at all!.
I have tryed setting the background color to 0,0,255 (using backcolour())then drawing the image using a drawingmode(1), which should in theroy work , but dont!.
What follows is some example code of my problem, what i am trying to do is to get the blue circle to be see through - so that i can see the text that is behind in the circle.
If OpenWindow(0, 100, 100, 300, 200, $10CF0000, "2D Drawing Test")
; Create an offscreen image, with a green circle in it.
; It will be displayed later
If CreateImage(1, 100, 100)
; If LoadImage(1,"image1.bmp")
FrontColour(255,255,255) ;White colour
FrontColour(0,0,255) ;Blue that i want to make see-through
Circle(50, 50, 30)
; This is the 'event loop'. All the user actions are processed here.
; It's very easy to understand: when an action occurs, the EventID
; isn't 0 and we just have to see what have happened...
EventID.l = WaitWindowEvent()
Until EventID 0
If EventID = #PB_EventRepaint ; If the user has resized the window or anything, we will repaint our graphic
Until EventID = #PB_EventCloseWindow ; If the user has pressed on the close button
End ; All the opened windows are closed automatically by PureBasic
; Some 2D graphics functions...
BackColour(0,0,255) ; Change the text back and front colour
DrawText("Hello, background drawn")
DrawText("Hello, only text")
DrawText("THIS SHOULD BE VISABLE")
DrawImage(ImageID(), 50, 50) ; Display our image !
StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
|Page 1 of 1||All times are UTC + 1 hour|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group