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()
StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )
StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )
Last edited by Axeman on Sat Dec 18, 2021 11:16 pm, edited 1 time in total.
-
- Addict
- Posts: 1310
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )
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.
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.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
- pf shadoko
- Enthusiast
- Posts: 385
- Joined: Thu Jul 09, 2015 9:07 am
Re: StartVectorDrawing( ArrayVectorOutput(MyVectorArray()) ) and StartDrawing( ArrayOutput(MyArray()) )
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()
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()) )
@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.
Last edited by Demivec on Sun Dec 19, 2021 4:52 am, edited 1 time in total.