The ScinImageBuffer class is designed to be analagous to the SuperCollider audio Buffer class, but for reading static images for sampling. ScinImageBuffers are most commonly used inside of ScinthDef functions as arguments to VSampler instances. Currently ScinImageBuffer support is limited to reading static images, but more may be added in the future.
Attempts to open the image file at the provided path and read the metadata. If that is successful the server will decode the image file, optionally resize it to the provided width and height, and upload it to the graphics hardware so it is ready for use.
The width and height arguments are both by default -1, which is an instruction to the server to respect the original dimensions of the image. If only one of the dimension arguments is supplied by -1, the server will scale the image to the non-negative dimension and then preserve the aspect ratio of the image by scaling the negative dimension to the appropriate size. Of course, if both dimensions are non-negative then the server will scale the image to the provided dimensions, disregarding the aspect ratio of the input image.
For example, for a source image that is 200 pixels wide and 100 pixels tall:
width requested | height requested | buffer width | buffer height | notes |
400 | 100 | 400 | 100 | Server will disregard aspect ratio of source image if both requested dimensions are nonnegative. |
-1 | 50 | 100 | 50 | In order to maintain 2:1 aspect ratio server has computed a width of 50 px. |
400 | -1 | 400 | 200 | In order to maintain 2:1 aspect ratio server has computed a height of 400 px. |
-1 | -1 | 200 | 100 | Server has allocated width and height of source image. |
server |
The ScinServer on which to read the image and allocate the buffer. If nil, will use |
path |
A string containing the path to the image file to read. |
width |
An optional integer describing a desired width to scale the image to, or -1. |
height |
An optional integer describing a desired height to scale the image to, or -1. |
action |
An optional function to be evaluated once the image has been decoded, uploaded, and this ImageBuffer's instance variables have been updated. The function will be passed this ImageBuffer as an argument. |
bufnum |
An explicitly specified buffer number. While buffer numbers for ImageBuffer are set on the client, and not allocated on the server, any load or delete operations on an ImageBuffer will clobber any exising ImageBuffer with the same buffer number. So, like Buffer, the best practice is to leave this unspecified. |
Returns the width of the ImageBuffer in pixels.
The ScinServer that owns the associated buffer.
The integer buffer number that uniquely identifies this buffer on the server.
Returns the height of the ImageBuffer in pixels.