PXcursorImages* = ptr XcursorImages
XcursorImages* = object
nimage*: cint #* number of images */
images*: seq[ PXcursorImage] #* array of XcursorImage pointers */
name*: cstring #* name used to load images */
proc XcursorFilenameLoadAllImages*( filename:cstring): PxcursorImages
{.libxcursor.}
Run
This is following some c code for learning purposes which dumps the Xcursor
file to a series of png images
var
xcIs: PXcursorImages
name = "sailboat"
xcIs = name.cstring.XcursorFilenameLoadALLImages( )
Run
And works as expected, so that xcIs.images is iterable
PXcursorImage* = ptr XcursorImage
XcursorImage* = object
version*: XcursorUInt #* version of the image data */
size*: XcursorDim #* nominal size for matching */
width*: XcursorDim #* actual width */
height*: XcursorDim #* actual height */
xhot*: XcursorDim #* hot spot x (must be inside image) */
yhot*: XcursorDim #* hot spot y (must be inside image) */
delay*: XcursorUInt #* animation delay to next frame (ms) */
pixels*: PXcursorPixel #* pointer to pixels */
var p: PXcursorImage
for i in 0..< xcIs.nimage:
p = xcIs.images[ i]
echo repr( p)
Run
But the iteration only sort of works. The output gives three good repr( p)
followed by two nils. This is because the nim loop **starts at i == 2** ,
missing the two smallest images. This has so far always been the case
irrespective of image file (always though with 5 numimage) and irrespective of
platform ubuntu arm64, void (muscl) amd_64.
Am I miss-messing with pointers? And if so why does it compile and part work?