Page 1 of 1

StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )

Posted: Sat Dec 18, 2021 2:26 am
by Axeman
I often find myself having to copy image data to an array so that I can work with it more effectively. Sometimes this requires the resulting data to be copied back to an image so that the 2D drawing and vector drawing libraries can be used to draw to it. It would simplify things if those libraries could work directly with arrays as their output. This would also help with some Point() and Plot() operations that require an array to be used as an intermediary, as you can read directly from the array without the need for Point().

Example

Dim MyArray.l( x, y )
StartDrawing( ArrayOutput(MyArray()) )
; Draw to the array here.
StopDrawing()

Dim MyVectorArray.l( x, y )
StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) )
; Draw to the array here.
StopVectorDrawing()

Re: StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )

Posted: Sat Dec 18, 2021 4:05 pm
by collectordave
May help.

When I want to save paths when vector drawing I use path segments which gives a string representation of the current path which you can save to a string array or list.

These can easily be reproduced by AdPathSegments.

Re: StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )

Posted: Sat Dec 18, 2021 6:33 pm
by pf shadoko
for my part, I use DrawingBuffer()

to convert the array into an image (32 bit)

dim bmp.l(dy-1,dx-1)
StartDrawing(TextureOutput(tex)):CopyMemory(@bmp(0,0),DrawingBuffer(),dx*dy*4):StopDrawing()

to convert the array into an image (32 bit)

StartDrawing(TextureOutput(tex)):CopyMemory(DrawingBuffer(),@bmp(0,0),dx*dy*4):StopDrawing()

Re: StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )

Posted: Sat Dec 18, 2021 9:00 pm
by Demivec
@pf shadoko: The method you use looks to have some slight problems. You don't seem to have a large enough memory space in the array bmp(). The total space needed would be DrawingBufferPitch() * dy. You don't account for any possible padding bytes at the end of each line in the image. You use instead the minimum possible amount (without padding bytes) but I don't think you can depend on that.