Question: Getting dimensions and pixels of loaded image
emenel opened this issue · 3 comments
Hi!
I'm just started to experiment with Sketch and love the approach. I can't find documentation for working with images, so maybe I'm missing something?
Is there a way to load an image inside a sketch (I'm using load-resource
at the moment) and then get its dimensions to use inside the sketch?
And is there a way to work with the pixel data from the image (like in Processing or similar)?
Thank you!
I haven't tried it, but this class has accessor methods image-width
and image-height
, you could try calling those on the image resource!
https://github.com/vydd/sketch/blob/master/src/resources.lisp#L15-L18
It's not in the documentation, but a canvas object has recently been added to the API that lets you address individual pixels. Here's an example that uses it:
https://github.com/vydd/sketch/blob/master/examples/stars.lisp
I just confirmed that image-width
and image-height
work, but they're not exported from the sketch package, so you'd have to use sketch::image-width
to access them.
Thanks so much @Kevinpgalligan. I had been away, but just had a moment to try this and it seems to work like I wanted. Thanks again!