Hi! I was noticing that, when you use a graphics function, such as Put, you can either choose to have the screen/window as the target or a buffer. To choose the screen, you simply omit the target parameter. Now, there's one problem with this and maybe it's already solved, but I don't know. Suppose I want to create a procedure that will sometimes output to the screen and sometimes to a buffer, then what I would need would be a variable target. I can easily use a variable target between buffers, but how can I represent the screen as a buffer?
The function ScreenPtr points directly to the contents of the screen and does not provide an "image" like you would create with ImageCreate, so I can't do something like: Put ScreenPtr, (x, y), myimage, PSet. It'd be convenient if a null pointer, given as a target, would cause the functions to redirect to the screen, for instance.
So far, the workaround I can think of is to make my procedure always write to an image buffer and then, optionally, Put the buffer on top of the screen, but that's kind of wasteful. Any ideas?
Graphics target, screen or buffer
Re: Graphics target, screen or buffer
I think that the screen is selected if the buffer pointer (target) is omitted or also if its value is null.xlucas wrote:Suppose I want to create a procedure that will sometimes output to the screen and sometimes to a buffer, then what I would need would be a variable target. I can easily use a variable target between buffers, but how can I represent the screen as a buffer?
Re: Graphics target, screen or buffer
Null is OK, 0 is ignored.
But to keep it straightforward perhaps
EDIT :More straightforward
But to keep it straightforward perhaps
EDIT :More straightforward
Code: Select all
screen 19,32
sub Poot(x as long,y as long,im as any ptr, byref im2 as any ptr=0)
put im2,(x,y),im,pset
end sub
'an image
dim as any ptr i=imagecreate(200,200,rgb(0,100,200))
circle i,(100,100),50,rgb(200,0,0),,,,f
line i,(0,0)-(199,199),0,b
Poot(50,50,i) 'normal put
print "Press a key"
sleep
' 3 new images
dim as any ptr z(1 to 3)
for n as long=1 to 3
z(n)=imagecreate(250,250,rgb(200,n*50,0))
Poot(5,5,i,z(n))
next
for n as long=1 to 3
Poot((n-1)*250,300,z(n))
next
sleep
imagedestroy i
for n as long=1 to 3
imagedestroy z(n)
next
Re: Graphics target, screen or buffer
Oh! It works! Great :D