Hi blue
I have created a lot multi use functions
Primary this make many things very simple
Look as sample
Code: Select all
CopyContent_BF(source_ID, destination_ID, output_x=0, output_y=0) ; Move a content from image to image
; Canvas to canvas, canvas to image, image to canvas, PB sprite to canvas
; Canvas to PB sprite, PB sprite to image, image to PB sprite (same sized)
; For output on screen set ActivateScreenOutput_BF(1) - then a destination_ID is not needed
The Grab functions above in this thread have maked me many trouble, so, mostly i use this functions to time not
For my is urgent : I will make all functions bullet proof, with the simplest handling
Mostly from my functions can output at the same on all available destinations, for screen output you can set simple a flag
Look, this is a typical selection part
Code: Select all
If IsImage(input_ID) ; check for image
image=1
ElseIf IsSprite(input_ID) ; Check for PB sprite
sprite=1
ElseIf Not IsGadget(input_ID) ; Check for canvas
ProcedureReturn -17
EndIf
If image
output_width=ImageWidth(input_ID)-1
output_height=ImageHeight(input_ID)-1
ElseIf sprite
sprite_w_h(input_ID, @sprite_w_h)
output_width=sprite_w_h\sprite_w-1
output_height=sprite_w_h\sprite_h-1
Else
output_width=GadgetWidth(input_ID)-1
output_height=GadgetHeight(input_ID)-1
EndIf
If x<0 : x=0 : EndIf
If y<0 : y=0 : EndIf
If x>output_width : x=output_width : EndIf
If y>output_height : y=output_height : EndIf
If xx>output_width : xx=output_width : EndIf
If yy>output_height : yy=output_height : EndIf
If x>xx : x=xx : EndIf
If y>yy : y=yy : EndIf
If image
result=StartDrawing(ImageOutput(input_ID))
ElseIf sprite
result=StartDrawing(SpriteOutput(input_ID))
Else
result=StartDrawing(CanvasOutput(input_ID))
EndIf
Or so
Code: Select all
If screen_output
mode=1
image_width_1=ScreenWidth()
image_height_1=ScreenHeight()
Else
If IsImage(output_ID) ; check for image
image=1
image_width_1=ImageWidth(output_ID)
image_height_1=ImageHeight(output_ID)
ElseIf IsSprite(output_ID) ; Check for PB sprite
sprite=1
sprite_w_h(output_ID, @sprite_w_h)
image_width_1=sprite_w_h\sprite_w
image_height_1=sprite_w_h\sprite_h
ElseIf IsGadget(output_ID) ; Check for canvas
image_width_1=GadgetWidth(output_ID)
image_height_1=GadgetHeight(output_ID)
Else
ProcedureReturn -11
EndIf
EndIf
If mode<>-1
If IsImage(texture_ID)
texture_width_=ImageWidth(texture_ID)-1
texture_height_=ImageHeight(texture_ID)-1
Else
If IsSprite(texture_ID)
sprite_input=1
sprite_w_h(texture_ID, @sprite_w_h)
texture_width_=sprite_w_h\sprite_w-1
texture_height_=sprite_w_h\sprite_h-1
ElseIf IsGadget(texture_ID)
canvas_input=1
texture_width_=GadgetWidth(texture_ID)-1
texture_height_=GadgetHeight(texture_ID)-1
Else
ProcedureReturn -17
EndIf
EndIf
EndIf
If texture_width>image_width_1-texture_x Or texture_width<1
texture_width=image_width_1-texture_x
EndIf
If texture_height>image_height_1-texture_y Or texture_height<1
texture_height=image_height_1-texture_y
EndIf
image_width=image_width_1-1
image_height=image_height_1-1
A output on a Window is never a good idea, so i support this not
Its also never needed, a better way is ever available
Regards Werner