It is currently Tue Jan 26, 2021 5:00 pm

All times are UTC + 1 hour

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject:
PostPosted: Tue Nov 13, 2001 1:58 am 
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
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")     
    If StartDrawing(ImageOutput())
      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
      Gosub SomeGraphics

  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

  Locate(10, 10)
  DrawText("Hello, background drawn")
  Locate(10, 30)
  DrawText("Hello, only text")
  Locate(10, 90)

  DrawImage(ImageID(), 50, 50) ; Display our image !

  StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !


Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye