Read from one, write to the other (source and target image).
As far as I know you can only access one at a time.

Code: Select all
CompilerIf #PB_Compiler_Thread = 0
MessageRequester( "OOPS!", "Please compile threadsafe And try again :)" )
CompilerEndIf
Structure ImageData
*address
size.i
EndStructure
Declare WorkerBee(*void)
CreateImage( 0, 256, 256, 24, RGB( 255, 0, 0 ) ) ; Image 0 is red
CreateImage( 1, 256, 256, 24, RGB( 0, 0, 255 ) ) ; Image 1 starts out blue
StartDrawing( ImageOutput(0) )
*imagedata.ImageData = AllocateMemory( SizeOf( ImageData ) )
With *imagedata
\address = DrawingBuffer()
\size = DrawingBufferPitch() * ImageHeight( 0 )
EndWith
tid = CreateThread( @WorkerBee(), *imagedata )
WaitThread( tid )
StopDrawing()
OpenWindow(0,0,0,256,256,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGadget(0, 0, 0, 256, 256, ImageID(1) ) ; Image 1 should show red now
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
Procedure WorkerBee(*this.ImageData)
StartDrawing( ImageOutput(1) )
*that = DrawingBuffer()
CopyMemory( *this\address, *that, *this\size )
StopDrawing()
EndProcedure
help wrote: If "Create thread-safe executable" is enabled in the compiler options then every thread has its own current drawing output, which means two threads can do drawing on separate outputs at the same time.
Speed and memory usage.Joris wrote:What are the benefits of being able to do this ?
(I don't understand netmaestro's sample quit well...)