CopyImage
CopyImage SourceImage, Destimage
 
Parameters:

    SourceImage = The Index of the image you wish to copy
    Destimage = The index of the image that you'd like to copy this image to
Returns: NONE
 

      CopyImage will duplicate an one image to another.



FACTS:


      * If the DestImage index already exists, the existing image will be replaced.

      * The copied output image will the of the same type as the source. (See GetImageType )




Mini Tutorial #1:


      In this version the code has manually predetermined the destination image for CopyImage. See bellow for a more dynamic approach.


  
; Make an Image 200x by 100y in size
  CreateImage 1,200,100
  
; Tell PB to redirect all drawing command to draw  upon this image and now the screen..
  RenderToImage 1
  
; Draw some random circles on the image
  For lp=1 To 10
     Circle Rnd(200),Rnd(100),Rnd(10) ,Rnd(1)
  Next lp
  
; Redirect ALL Drawing o the screen
  RenderToScreen
  
; Clear the Screen to a blue colour
  Cls RGB(0,0,255)
  
; Draw our previously created image to the screen
  DrawImage 1,300,100,0
  
  
; Copy Image #1 to #2.  Since Image #2 doesn't exist, PB will create it
; for us.
  CopyImage 1,2
  
; Now Render the newly copied image 2 to the screen.
  DrawImage 2,300,300,0
  
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  






Mini Tutorial #2:


This version is basically the same, expect it uses the NewImage + GetFreeImage commands to make PB handle the media resources dynamically.

  
; Make an Image 200x by 100y in size
  SrcImage=NewImage(200,100)
  
; Tell PB to redirect all drawing command to draw  upon this image and now the screen..
  RenderToImage SrcImage
  
; Draw some random circles on the image
  For lp=1 To 10
     Circle Rnd(200),Rnd(100),Rnd(10) ,Rnd(1)
  Next lp
  
; Redirect ALL Drawing o the screen
  RenderToScreen
  
; Clear the Screen to a blue colour
  Cls 255
  
; Draw our previously created image to the screen
  DrawImage SrcImage,300,100,0
  
  
; Request a free image handle for the destination image
  DestImage=GetFreeImage()
  
; Copy Image Src to the Dest image.
  CopyImage SrcImage,DestImage
  
; Now Render the newly copied image 2 to the screen.
  DrawImage DestImage,300,300,0
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  
  





 
Related Info: CopyRect | CreateImage | DeleteImage | GetFreeImage | Images | LoadImage | NewFxImage | NewImage :
 


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