Vuo  2.0.0
VuoImage.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #ifndef DISPATCH_RETURNS_RETAINED_BLOCK
17  #define DISPATCH_RETURNS_RETAINED_BLOCK
20 #endif
21 #include <dispatch/dispatch.h>
22 
23 #include "VuoBoolean.h"
24 #include "VuoColor.h"
25 #include "VuoGlContext.h"
26 #include "VuoHeap.h"
27 #include "VuoImageColorDepth.h"
28 #include "VuoImageWrapMode.h"
29 #include "VuoPoint2d.h"
30 #include "VuoRectangle.h"
31 
46 typedef struct _VuoImage *VuoImage;
47 
54 typedef void (*VuoImage_freeCallback)(VuoImage imageToFree);
55 
60 struct _VuoImage
61 {
62  // GPU image
63  unsigned int glTextureName;
64  unsigned int glInternalFormat;
65  unsigned long int glTextureTarget;
66 
67  // Common
68  unsigned long int pixelsWide;
69  unsigned long int pixelsHigh;
70  float scaleFactor;
71 
73 
74  // CPU image
75  dispatch_once_t cpuQueueInitialized;
76  dispatch_queue_t cpuQueue;
77  struct json_object *cpuData;
78 };
79 
80 VuoImage VuoImage_make(unsigned int glTextureName, unsigned int glInternalFormat, unsigned long int pixelsWide, unsigned long int pixelsHigh);
81 VuoImage VuoImage_makeClientOwned(unsigned int glTextureName, unsigned int glInternalFormat, unsigned long int pixelsWide, unsigned long int pixelsHigh, VuoImage_freeCallback freeCallback, void *freeCallbackContext) __attribute__((nonnull(5)));
82 VuoImage VuoImage_makeClientOwnedGlTextureRectangle(unsigned int glTextureName, unsigned int glInternalFormat, unsigned long int pixelsWide, unsigned long int pixelsHigh, VuoImage_freeCallback freeCallback, void *freeCallbackContext) __attribute__((nonnull(5)));
83 VuoImage VuoImage_makeFromBuffer(const void *pixels, unsigned int format, unsigned int pixelsWide, unsigned int pixelsHigh, VuoImageColorDepth colorDepth, void (^freeCallback)(void *pixels)) __attribute__((nonnull(1)));
84 VuoImage VuoImage_makeFromBufferWithStride(const void *pixels, unsigned int format, unsigned int pixelsWide, unsigned int pixelsHigh, unsigned int bytesPerRow, VuoImageColorDepth colorDepth, void (^freeCallback)(void *pixels)) __attribute__((nonnull(1)));
85 VuoImage VuoImage_makeColorImage(VuoColor color, unsigned int pixelsWide, unsigned int pixelsHigh);
86 VuoImage VuoImage_makeCopy(VuoImage image, bool flip, unsigned int forcePixelsWide, unsigned int forcePixelsHigh, bool forceAlpha);
88 const unsigned char *VuoImage_getBuffer(VuoImage image, unsigned int requestedFormat);
89 
91 void VuoImage_setWrapMode(VuoImage image, VuoImageWrapMode wrapMode);
92 
93 VuoImage VuoImage_mapColors(VuoImage image, VuoList_VuoColor colors, VuoReal filterOpacity);
94 
96 #define VuoImage_SUPPORTS_COMPARISON
97 bool VuoImage_areEqual(const VuoImage a, const VuoImage b);
98 bool VuoImage_isLessThan(const VuoImage a, const VuoImage b);
99 
100 bool VuoImage_areEqualWithinTolerance(const VuoImage a, const VuoImage b, const unsigned char tolerance);
101 bool VuoImage_isEmpty(const VuoImage image);
102 bool VuoImage_isPopulated(const VuoImage image);
103 
106 
108 VuoImage VuoImage_makeFromJsonWithDimensions(struct json_object *js, unsigned int requestedPixelsWide, unsigned int requestedPixelsHigh) VuoWarnUnusedResult;
109 GLuint VuoImage_resolveInterprocessJsonUsingTextureProvider(struct json_object *js, GLuint (^provider)(unsigned int pixelsWide, unsigned int pixelsHigh), unsigned int *outputPixelsWide, unsigned int *outputPixelsHigh, void *outputIOSurface) VuoWarnUnusedResult;
110 bool VuoImage_resolveInterprocessJsonUsingClientTexture(struct json_object *js, GLuint textureName, unsigned int pixelsWide, unsigned int pixelsHigh, void *outputIOSurface) VuoWarnUnusedResult;
112 struct json_object * VuoImage_getJson(const VuoImage value);
113 
115 #define VuoImage_REQUIRES_INTERPROCESS_JSON
117 
118 char * VuoImage_getSummary(const VuoImage value);
119 
121 
124 VuoImage VuoImage_makeFromString(const char *str);
125 char * VuoImage_getString(const VuoImage value);
126 char * VuoImage_getInterprocessString(const VuoImage value);
127 void VuoImage_retain(VuoImage value);
128 void VuoImage_release(VuoImage value);
130 
135 #ifdef __cplusplus
136 }
137 #endif