Hello,
I am stuck trying to feed a method that is an ImGui widget (image inspector).
The method to feed the image must receive a texture,
but as a pointer: (memory position of the first pixel and the size)
const unsigned char*
The thing is that I am trying with many workarounds to convert/cast the ofTexture, ofImage or even ofPixels to something like the “raw data”…
I am looking into the OF examples, like gl\textureBufferInstancedExample and others, also ofBuffer and ofBufferObject and ofTexture methods but no success.
If I don’t misunderstand, C++ apps/classes commonly passes a pointer to the image to be drawn, analyzed or whatever.
–
Here’s some code:
//ofApp.h
ofxImGui::Gui gui;
ofTexture textureSource;
GLuint textureSourceID;
float width = 200;
float height = 200;
//--
//ofApp.cpp
// setup
textureSourceID = gui.loadTexture(textureSource, "image.jpg");
// draw image
ImGui::Image((ImTextureID)(uintptr_t)textureSourceID, ImVec2(width, height));
// -> ??
// how to get pointer, to cast or to convert into:
const unsigned char* data = ...
ImageInspect::inspect(w, h, data, mouseUVCoord, displayedTextureSize);
//--
//imgInspect.h
// custom image widget
inline void inspect(const int width,
const int height,
const unsigned char* const data,
ImVec2 mouseUVCoord,
ImVec2 displayedTextureSize)
{
//...
}
–
That’s the widget that I am trying to use:
What I want to do is to get the color of the image pixels.
Any help around?