Vuo
1.1.0
|
An image residing in GPU memory (GL Texture Object).
Classes | |
struct | _VuoImage |
An image residing in GPU memory (GL Texture Object). More... | |
Typedefs | |
typedef struct _VuoImage * | VuoImage |
An image residing in GPU memory (GL Texture Object). | |
typedef void(* | VuoImage_freeCallback )(VuoImage imageToFree) |
A callback to be implemented if non-Vuo code needs to retain ownership of the GL texture (instead of the default behavior where VuoImage takes ownership of the texture). | |
Functions | |
VuoImage | VuoImage_get (const char *imageURL) |
Retrieves the image at the specified imageURL , and creates a VuoImage from it. | |
void | VuoImage_free (void *texture) |
Decrements the retain count of the OpenGL Texture Object associated with the specified VuoImage , and frees the texture VuoImage struct. | |
VuoImage | VuoImage_make (unsigned int glTextureName, unsigned int glInternalFormat, unsigned long int pixelsWide, unsigned long int pixelsHigh) |
Returns a new VuoImage structure representing the specified glTextureName . | |
VuoImage | VuoImage_makeClientOwned (unsigned int glTextureName, unsigned int glInternalFormat, unsigned long int pixelsWide, unsigned long int pixelsHigh, VuoImage_freeCallback freeCallback, void *freeCallbackContext) |
Returns a new VuoImage structure representing the specified glTextureName . | |
VuoImage | VuoImage_makeClientOwnedGlTextureRectangle (unsigned int glTextureName, unsigned int glInternalFormat, unsigned long int pixelsWide, unsigned long int pixelsHigh, VuoImage_freeCallback freeCallback, void *freeCallbackContext) |
Returns a new VuoImage structure representing the specified glTextureName . | |
VuoImage | VuoImage_makeFromBuffer (const void *pixels, unsigned int format, unsigned int pixelsWide, unsigned int pixelsHigh, VuoImageColorDepth colorDepth) |
Uploads the specified pixel data to the GPU and returns a new VuoImage referencing it. | |
VuoImage | VuoImage_makeFromJson (json_object *js) |
Decodes the JSON object js to create a new value. | |
json_object * | VuoImage_getJson (const VuoImage value) |
Encodes value as a JSON object. | |
json_object * | VuoImage_getInterprocessJson (const VuoImage value) |
Returns a JSON object containing an interprocess handle for the specified texture. | |
char * | VuoImage_getSummary (const VuoImage value) |
A brief summary of the contents of this texture. | |
VuoImage | VuoImage_makeColorImage (VuoColor color, unsigned int pixelsWide, unsigned int pixelsHigh) |
Makes a solid-color image. | |
VuoImage | VuoImage_makeCopy (VuoImage image, bool flip) |
Returns a new texture copy of the passed image. | |
VuoImage | VuoImage_makeShallowCopy (VuoImage image) |
Returns a new VuoImage with the same GL texture as the input image . | |
VuoImage | VuoImage_makeGlTextureRectangleCopy (VuoImage image) |
Copies image to a new GL_TEXTURE_RECTANGLE_ARB texture. | |
VuoImage | VuoImage_makeFromContextFramebuffer (VuoGlContext context) |
Returns an image with the contents of the context 's framebuffer. | |
unsigned char * | VuoImage_copyBuffer (VuoImage image, unsigned int requestedFormat) |
Downloads the specified image's pixel data from the GPU to the CPU, and returns the CPU memory buffer. | |
void | VuoImage_setWrapMode (VuoImage image, VuoImageWrapMode wrapMode) |
Changes the image's wrap mode. | |
VuoImage | VuoImage_blur (VuoImage image, VuoReal radius, VuoBoolean expandBounds) |
Returns a blurred copy of image. | |
VuoImage | VuoImage_mapColors (VuoImage image, VuoList_VuoColor colors, VuoReal filterOpacity) |
Returns a color-mapped copy of image. | |
bool | VuoImage_areEqual (const VuoImage a, const VuoImage b) |
Returns true if both images have the same dimensions and the same RGBA pixel data. | |
bool | VuoImage_isEmpty (const VuoImage image) |
VuoRectangle | VuoImage_getRectangle (const VuoImage image) |
Returns a rectangle (in Vuo Coordinates) at the origin, with width 2 and height matching the image's aspect ratio. | |
VuoImageColorDepth | VuoImage_getColorDepth (const VuoImage image) |
Returns the color depth of the image. | |
VuoImage | VuoImage_makeFromString (const char *str) |
Automatically generated function. | |
char * | VuoImage_getString (const VuoImage value) |
Automatically generated function. | |
char * | VuoImage_getInterprocessString (const VuoImage value) |
Automatically generated function. | |
void | VuoImage_retain (VuoImage value) |
Automatically generated function. | |
void | VuoImage_release (VuoImage value) |
Automatically generated function. | |
struct _VuoImage |
Class Members | ||
---|---|---|
void * | freeCallbackContext |
User data for freeCallback . See VuoImage_makeClientOwned. |
unsigned int | glInternalFormat |
The OpenGL internal texture format (as provided to glTexImage2D ). |
unsigned int | glTextureName | The unique OpenGL texture identifier. |
unsigned long int | glTextureTarget |
Always GL_TEXTURE_2D , unless converting from an IOSurface . |
unsigned long int | pixelsHigh | The vertical size of the image, in pixels. |
unsigned long int | pixelsWide | The horizontal size of the image, in pixels. |
An image residing in GPU memory (GL Texture Object).
The struct is typedef'd to a pointer so that VuoImages are reference-counted, enabling us to automatically delete the GL Texture Object when the last reference is released.
typedef void(* VuoImage_freeCallback)(VuoImage imageToFree) |
A callback to be implemented if non-Vuo code needs to retain ownership of the GL texture (instead of the default behavior where VuoImage takes ownership of the texture).
Returns true if both images have the same dimensions and the same RGBA pixel data.
Other attributes (pixel format, target) are ignored.
Two NULL images are considered equal. A NULL image is never equal to a non-NULL image.
This operation is fairly expensive — it requires downloading both images from the GPU to the CPU. It's intended primarily for use in automated tests.
VuoImage VuoImage_blur | ( | VuoImage | image, |
VuoReal | radius, | ||
VuoBoolean | expandBounds | ||
) |
Returns a blurred copy of image.
(Or, if radius is zero, returns image.)
If expandBounds is true, the output image will be expanded to encompass the full bleed of the blur. Otherwise, the output image will have the same dimensions as the soure image.
unsigned char* VuoImage_copyBuffer | ( | VuoImage | image, |
unsigned int | requestedFormat | ||
) |
Downloads the specified image's pixel data from the GPU to the CPU, and returns the CPU memory buffer.
The return value is a pointer to a buffer of pixel data. 8 bits per channel. Row-major, starting at the bottom (flipped). Zero stride. Premultiplied alpha.
The caller should free()
the returned buffer when it is finished using it.
This function may be called from any thread.
image | The image to download. |
requestedFormat | An OpenGL format constant. Supported formats include:
|
void VuoImage_free | ( | void * | texture | ) |
Decrements the retain count of the OpenGL Texture Object associated with the specified VuoImage
, and frees the texture
VuoImage struct.
This function may be called from any thread.
VuoImage VuoImage_get | ( | const char * | imageURL | ) |
Retrieves the image at the specified imageURL
, and creates a VuoImage
from it.
This function may be called from any thread.
VuoImageColorDepth VuoImage_getColorDepth | ( | const VuoImage | image | ) |
Returns the color depth of the image.
|
read |
Returns a JSON object containing an interprocess handle for the specified texture.
value
may be either GL_TEXTURE_2D
or GL_TEXTURE_RECTANGLE_ARB
.
This function may be called from any thread.
char* VuoImage_getInterprocessString | ( | const VuoImage | value | ) |
Automatically generated function.
|
read |
Encodes value
as a JSON object.
This function may be called from any thread.
VuoRectangle VuoImage_getRectangle | ( | const VuoImage | image | ) |
Returns a rectangle (in Vuo Coordinates) at the origin, with width 2 and height matching the image's aspect ratio.
char* VuoImage_getString | ( | const VuoImage | value | ) |
Automatically generated function.
char * VuoImage_getSummary | ( | const VuoImage | value | ) |
A brief summary of the contents of this texture.
This function may be called from any thread.
bool VuoImage_isEmpty | ( | const VuoImage | image | ) |
VuoImage VuoImage_make | ( | unsigned int | glTextureName, |
unsigned int | glInternalFormat, | ||
unsigned long int | pixelsWide, | ||
unsigned long int | pixelsHigh | ||
) |
Returns a new VuoImage structure representing the specified glTextureName
.
The texture must:
GL_TEXTURE_2D
.The VuoImage takes ownership of glTextureName
, and will call glDeleteTextures()
on it when it's no longer needed.
VuoImage is intended to be immutable — do not modify the contents of the glTextureName
after passing it to this function.
This function may be called from any thread.
VuoImage VuoImage_makeClientOwned | ( | unsigned int | glTextureName, |
unsigned int | glInternalFormat, | ||
unsigned long int | pixelsWide, | ||
unsigned long int | pixelsHigh, | ||
VuoImage_freeCallback | freeCallback, | ||
void * | freeCallbackContext | ||
) |
Returns a new VuoImage structure representing the specified glTextureName
.
The texture must:
GL_TEXTURE_2D
When the VuoImage is no longer needed, freeCallback
is called. The freeCallback
may then activate a GL context and delete the texture, or send it back to a texture pool. freeCallback
must not be NULL.
freeCallbackContext
is optional data passed to freeCallback
via the VuoImage struct. Use NULL
if you don't need to provide additional data to the callback.
VuoImage is intended to be immutable — do not modify the contents of the glTextureName
between passing it to this function and when freeCallback
is called.
This function may be called from any thread.
VuoImage VuoImage_makeClientOwnedGlTextureRectangle | ( | unsigned int | glTextureName, |
unsigned int | glInternalFormat, | ||
unsigned long int | pixelsWide, | ||
unsigned long int | pixelsHigh, | ||
VuoImage_freeCallback | freeCallback, | ||
void * | freeCallbackContext | ||
) |
Returns a new VuoImage structure representing the specified glTextureName
.
The texture must:
GL_TEXTURE_RECTANGLE_ARB
When the VuoImage is no longer needed, freeCallback
is called. The freeCallback
may then activate a GL context and delete the texture, or send it back to a texture pool. freeCallback
must not be NULL.
freeCallbackContext
is optional data passed to freeCallback
via the VuoImage struct. Use NULL
if you don't need to provide additional data to the callback.
VuoImage is intended to be immutable — do not modify the contents of the glTextureName
between passing it to this function and when freeCallback
is called.
GL_TEXTURE_RECTANGLE_ARB
.This function may be called from any thread.
VuoImage VuoImage_makeColorImage | ( | VuoColor | color, |
unsigned int | pixelsWide, | ||
unsigned int | pixelsHigh | ||
) |
Makes a solid-color image.
Returns a new texture copy of the passed image.
image
may be either GL_TEXTURE_2D
or GL_TEXTURE_RECTANGLE_ARB
.
If flip
is true, the copied image is flipped upside-down relative to the source image.
VuoImage VuoImage_makeFromBuffer | ( | const void * | pixels, |
unsigned int | format, | ||
unsigned int | pixelsWide, | ||
unsigned int | pixelsHigh, | ||
VuoImageColorDepth | colorDepth | ||
) |
Uploads the specified pixel data to the GPU and returns a new VuoImage referencing it.
This function may be called from any thread.
pixels | Pointer to a buffer of pixel data. Row-major, starting at the bottom (flipped). Zero stride. Premultiplied alpha. The caller is responsible for freeing this buffer sometime after this function returns. |
format | An OpenGL format constant. Supported formats include:
|
pixelsWide | Width in pixels |
pixelsHigh | Height in pixels |
colorDepth | The number of bits per channel. When 8bpc, pixels should be unsigned char * ; when 16bpc, pixels should be float * . |
VuoImage VuoImage_makeFromContextFramebuffer | ( | VuoGlContext | context | ) |
Returns an image with the contents of the context
's framebuffer.
VuoImage VuoImage_makeFromJson | ( | json_object * | js | ) |
Decodes the JSON object js
to create a new value.
Automatically activates and deactivates a GL Context (if needed to dereference an IOSurface).
This function may be called from any thread.
js
contains valid data, returns a pointer to the VuoImage. If not, returns NULL.js | A JSON object containing one of the following schemas: |
IOSurfaceID
and the texture's width and height in pixels: VuoImage VuoImage_makeFromString | ( | const char * | str | ) |
Automatically generated function.
Copies image
to a new GL_TEXTURE_RECTANGLE_ARB
texture.
GL_TEXTURE_2D
internally. Returns a new VuoImage with the same GL texture as the input image
.
VuoImage VuoImage_mapColors | ( | VuoImage | image, |
VuoList_VuoColor | colors, | ||
VuoReal | filterOpacity | ||
) |
Returns a color-mapped copy of image.
(Or, if colors is empty, returns image.)
void VuoImage_release | ( | VuoImage | value | ) |
Automatically generated function.
void VuoImage_retain | ( | VuoImage | value | ) |
Automatically generated function.
void VuoImage_setWrapMode | ( | VuoImage | image, |
VuoImageWrapMode | wrapMode | ||
) |
Changes the image's wrap mode.