DrawImage
DrawImage ImageNumber, Xpos, Ypos, TransparentFlag
 
Parameters:

    ImageNumber = The identifier of this image
    Xpos = The X coordinate to draw the image at
    Ypos = The Y coordinate to draw the image at
    TransparentFlag = This flag toggles if the image is rendered solid or transparent. (0=Solid, 1 for transparent)
Returns: NONE
 

      The DrawImage commands will render an image to the current surface. Generally the current surface will be the screen, but you can also draw images directly onto other images also.

      The command gives us two basic display options for rendering the image. Those being Solid or Transparent. Setting the TransparentFlag parameter to false (Zero) tells the rendering engine to draw every pixel in the image over the output surface. Once drawn this image will then cover whatever was on the surface previously.

      Alternatively we can choose to draw the image in transparent mode by setting the TransparentFlag parameter to True (value of one). In those modes the rendering engine only renders pixels to the output surface when the pixel doesn't match the Images Mask Colour (See ImageMaskColour ) or value of the alpha channel if the image is stored in AFX format.





FACTS:


     * DrawImage renders an image to current surface, except when the user either CaptureToScene, or CaptureToWorld are activated. In either situation the render request will be add to the scene or world queues.

     * DrawImage let's the user control the basic transparency when rendering, however how the transparency is defined actually comes from the type of image your rendering. So when you render an AFX image, each pixels alpha level is used, where as FX & Video images the Images Mask Colour. See Images GetImageType

     * You can DrawImages to create your own sprites, or using the built in the sprite system. For more on those see the Sprites tutorial.





Mini Tutorial:


      This small example shows how to create an image, draw random dots to it and then draw it at the mouses position.

  
  
; Limit the Speed of this program to
; run no faster than 50 frames per second.
  SetFPS 50
  
; Create an image 100x by 80y pixels in size,  using
; the Image number (Media Index) of #1
  CreateImage 1,100,80
  
  Do
     
   ; Clear the Screen to back   0 is = to the Rgb (0,0,0)
     Cls RGB(0,0,0)
     
   ; Instruct PlayBASIC to redirect all drawing
   ;  operations to Image Number #1
     RenderToImage  1
     
   ; Randomly Draw dots upon this surface..
     For lp=0 To Rnd(100)
        DotC Rnd(100),Rnd(80),RndRGB()
     Next lp
     
   ; Instruct PlayBASIC to redirect all drawing
   ; operations to the screen.
     RenderToScreen
     
   ; Draw Image Number #1 at the mouses current position
     DrawImage 1,MouseX(),MouseY(),0
     
   ; Display the screen and loop until the users
   ; presses the ESC key.
     Sync
  Loop
  



 
Related Info: DrawAlphaImage | DrawRotatedImage | GridImage | Images | RenderToImage | Sprites | TileImage :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com