ImageViewPort
ImageViewPort ImageNumber, X1, Y1, X2, Y2
 
Parameters:

    ImageNumber = The identifier of this image
    X1 = The top left hand X position of the viewport
    Y1 = The top left hand Y position of the viewport
    X2 = The bottom right hand X position of the viewport
    Y2 = The bottom right hand Y position of the viewport
Returns: NONE
 

      ImageViewPort defines the rendering boundaries of an image. These boundaries only take effect when the image is being rendered to, not when it's drawn.

      The Viewport is the clipping boundary for the image. Normally when you draw to an image or the screen, our graphics will be clipped to the image/screen edges. What a viewport does, is it allows you to choose a section of the screen/image that you'd like all future drawing operations to be clipped against. This allows us to render graphics to a certain area within an image, without damaging the pixels outside the area.




FACTS:


      * By default an images viewport will be set to 0,0 to ImageWidth,ImageHeight

      * Viewport regions can not exceeed the size of the image.

      * Applying a ViewPort to an Image only takes effect when the Image is being rendered to ! (see: RenderToImage)

      * To draw a section of image see CopyRect, TextureQuad





Mini Tutorial:


      Create an image, change it's viewport, and show the effects of the change.

  
  
; First Create an image, colour it blue and draw a red circle on it..
  size = 200
  CreateImage 1,Size,Size
  RenderToImage 1
  
; Clear the Image to the bluey colour
  Cls RGB(0,100,255)
  
; Set the Images Viewport (clipping area) so that it's  50 pixels inside it's size
  ImageViewPort 1,50,50,Size-50,size-50
  
; Clear the image (clipped to the view port) to a green colour
  Cls RGB(0,200,0)
  
; Draw a bunch of circles to this image..
  For lp =0 To 100
     CircleC Rnd(Size),Rnd(Size),Rnd(10),1,RndRGB()
  Next
  
; redirect all drawing to the Screen
  RenderToScreen
  
  
;  Draw this image as a solid image.
  DrawImage 1,100,100,0
  
; Display the Pixel coordinates of the images Viewport
  Print "Images ViewPort X1:"+Str$(GetImageViewPortX1(1))
  Print "Images ViewPort Y1:"+Str$(GetImageViewPortY1(1))
  Print "Images ViewPort X2:"+Str$(GetImageViewPortX2(1))
  Print "Images ViewPort Y2:"+Str$(GetImageViewPortY2(1))
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  
  


This example would output.

  
  Images ViewPort X1: 50
  Images ViewPort Y1: 50
  Images ViewPort X2: 150
  Images ViewPort Y2: 150
  


 
Related Info: GetImageViewPortX1 | GetImageViewPortX2 | GetImageViewPortY1 | GetImageViewPortY2 :
 


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