ImGui Tex Inspect: a texture inspector: zoom into a texture down to its pixels, read their values, and draw annotations over them.
The C++ API of ImGui Tex Inspect as it is bound to Python: the entries of the module imgui_bundle.imgui_tex_inspect, in the same order, with their C++ signatures and the headers’ comments. From the stubs: the functions excluded from the bindings, the typedefs and the macros are absent.
imgui_tex_inspect.h¶
INIT & SHUTDOWN¶
ImGuiTexInspect::Init¶
void Init();ImGuiTexInspect::Shutdown¶
void Shutdown();BASIC USAGE¶
InspectorAlphaMode (enum)¶
| Member | Value | |
|---|---|---|
InspectorAlphaMode_ImGui | 0 | Alpha is transparency so you see the ImGui panel background behind image |
InspectorAlphaMode_Black | 1 | Alpha is used to blend over a black background |
InspectorAlphaMode_White | 2 | Alpha is used to blend over a white background |
InspectorAlphaMode_CustomColor | 3 | Alpha is used to blend over a custom colour. |
InspectorFlags_ (enum)¶
| Member | Value | |
|---|---|---|
InspectorFlags_ShowWrap = 1 << 0 | 1 << 0 | Draw beyong the [0,1] uv range. What you see will depend on API |
InspectorFlags_NoForceFilterNearest = 1 << 1 | 1 << 1 | Normally we force nearest neighbour sampling when zoomed in. Set to disable this. |
InspectorFlags_NoGrid = 1 << 2 | 1 << 2 | By default a grid is shown at high zoom levels |
InspectorFlags_NoTooltip = 1 << 3 | 1 << 3 | Disable tooltip on hover |
InspectorFlags_FillHorizontal = 1 << 4 | 1 << 4 | Scale to fill available space horizontally |
InspectorFlags_FillVertical = 1 << 5 | 1 << 5 | Scale to fill available space vertically |
InspectorFlags_NoAutoReadTexture = 1 << 6 | 1 << 6 | By default texture data is read to CPU every frame for tooltip and annotations |
InspectorFlags_FlipX = 1 << 7 | 1 << 7 | Horizontally flip the way the texture is displayed |
InspectorFlags_FlipY = 1 << 8 | 1 << 8 | Vertically flip the way the texture is displayed |
SizeIncludingBorder (struct)¶
| Member | |
|---|---|
ImVec2 Size; |
SizeIncludingBorder::SizeIncludingBorder¶
SizeIncludingBorder(ImVec2 size):Size(size);SizeExcludingBorder (struct)¶
| Member | |
|---|---|
ImVec2 size; |
SizeExcludingBorder::SizeExcludingBorder¶
SizeExcludingBorder(ImVec2 size):size(size);BeginInspectorPanel¶
Returns True if panel is drawn. Note that flags will only be considered on the first call
ImGuiTexInspect::BeginInspectorPanel¶
bool BeginInspectorPanel(const char *name, ImTextureID, ImVec2 textureSize, InspectorFlags flags = 0);bool BeginInspectorPanel(const char *name, ImTextureID, ImVec2 textureSize, InspectorFlags flags, SizeIncludingBorder size);bool BeginInspectorPanel(const char *name, ImTextureID, ImVec2 textureSize, InspectorFlags flags, SizeExcludingBorder size);ImGuiTexInspect::EndInspectorPanel¶
void EndInspectorPanel();EndInspectorPanel
Always call after BeginInspectorPanel and after you have drawn any required annotations
ImGuiTexInspect::ReleaseInspectorData¶
void ReleaseInspectorData(ImGuiID id);ReleaseInspectorData
ImGuiTexInspect keeps texture data cached in memory. If you know you won’t
be displaying a particular panel for a while you can call this to release
the memory. It won’t be allocated again until next time you call
BeginInspectorPanel. If id is None then the current (most recent) inspector
will be affected. Unless you have a lot of different Inspector instances
you can probably not worry about this. Call CurrentInspector_GetID to get
the ID of an inspector.
ImGuiTexInspect::CurrentInspector_SetAlphaMode¶
void CurrentInspector_SetAlphaMode(InspectorAlphaMode);CurrentInspector_SetAlphaMode - see enum comments for details
ImGuiTexInspect::CurrentInspector_SetFlags¶
void CurrentInspector_SetFlags(InspectorFlags toSet, InspectorFlags toClear = 0);ImGuiTexInspect::CurrentInspector_ClearFlags¶
inline void CurrentInspector_ClearFlags(InspectorFlags toClear);ImGuiTexInspect::CurrentInspector_SetGridColor¶
void CurrentInspector_SetGridColor(ImU32 color);ImGuiTexInspect::CurrentInspector_SetMaxAnnotations¶
void CurrentInspector_SetMaxAnnotations(int maxAnnotations);ImGuiTexInspect::CurrentInspector_InvalidateTextureCache¶
void CurrentInspector_InvalidateTextureCache();CurrentInspector_InvalidateTextureCache
If using the InspectorFlags_NoAutoReadTexture flag then call this to
indicate your texture has changed context.
CurrentInspector_SetCustomBackgroundColor¶
If using InspectorAlphaMode_CustomColor then this is the color that will be
blended as the background where alpha is less than one.
ImGuiTexInspect::CurrentInspector_SetCustomBackgroundColor¶
void CurrentInspector_SetCustomBackgroundColor(ImVec4 color);void CurrentInspector_SetCustomBackgroundColor(ImU32 color);ImGuiTexInspect::CurrentInspector_GetID¶
ImGuiID CurrentInspector_GetID();CurrentInspector_GetID
Get the ID of the current inspector. Currently only used for calling
ReleaseInspectorData.
ImGuiTexInspect::DrawColorMatrixEditor¶
void DrawColorMatrixEditor();ColorMatrix editor. See comments on ColorMatrix below.
Some convenience functions for drawing ImGui controls for the current Inspector
ImGuiTexInspect::DrawGridEditor¶
void DrawGridEditor();Grid editor. Enable/Disable grid. Set Grid Color.
ImGuiTexInspect::DrawColorChannelSelector¶
void DrawColorChannelSelector();For toggling R,G,B channels
ImGuiTexInspect::DrawAlphaModeSelector¶
void DrawAlphaModeSelector();A combo box for selecting the alpha mode
ImGuiTexInspect::SetZoomRate¶
void SetZoomRate(float factor);CONTEXT-WIDE SETTINGS
/* SetZoomRate
factor should be greater than 1. A value of 1.5 means one mouse wheel
scroll will increase zoom level by 50%. The factor used for zooming out is
1/factor. */
ANNOTATION TOOLS¶
ImGuiTexInspect::DrawAnnotationLine¶
void DrawAnnotationLine(ImDrawList *drawList, ImVec2 fromTexel, ImVec2 toTexel, Transform2D texelsToPixels, ImU32 color);DrawAnnotationLine
Convenience function to add a line to draw list using texel coordinates.
ValueText (struct)¶
ValueText
An annoation class that draws text inside each texel when zoom level is high enough for it to fit.
The text shows the value of the texel. E.g. “R:255, G: 128, B:0, A:255”
ValueText::Format (enum)¶
| Member | Value | |
|---|---|---|
HexString | 0 | E.g. #EF97B9FF |
BytesHex | 1 | E.g. R:#EF G:#97 B:#B9 A:#FF (split over 4 lines) |
BytesDec | 2 | E.g. R:239 G: 151 B:185 A:255 (split over 4 lines) |
Floats | 3 | E.g. 0.937 0.592 0.725 1.000 (split over 4 lines) |
ValueText::ValueText¶
ValueText(Format format = HexString);ValueText::DrawAnnotation¶
void DrawAnnotation(ImDrawList *drawList, ImVec2 texel, Transform2D texelsToPixels, ImVec4 value);Arrow (struct)¶
Arrow
An annotation class that draws an arrow inside each texel when zoom level is
high enough. The direction and length of the arrow are determined by texel
values.
The X and Y components of the arrow is determined by the VectorIndex_x, and
VectorIndex_y channels of the texel value. Examples:
VectorIndex_x = 0, VectorIndex_y = 1 means X component is red and Y component is green
VectorIndex_x = 1, VectorIndex_y = 2 means X component is green and Y component is blue
VectorIndex_x = 0, VectorIndex_y = 3 means X component is red and Y component is alpha\
ZeroPoint is the texel value which corresponds to a zero length vector. E.g.
ZeroPoint = (0.5, 0.5) means (0.5, 0.5) will be drawn as a zero length arrow\
All public properties can be directly manipulated. There are also presets that can be set
by calling UsePreset.
| Member | |
|---|---|
int VectorIndex_x; | |
int VectorIndex_y; | |
ImVec2 LineScale; | |
ImVec2 ZeroPoint = {0, 0}; |
Arrow::Preset (enum)¶
| Member | Value | |
|---|---|---|
NormalMap | 0 | For normal maps. I.e. Arrow is in (R,G) channels. 128, 128 is zero point |
NormalizedFloat | 1 | Arrow in (R,G) channels. 0,0 is zero point, (1,0) will draw an arrow exactly to |
Arrow::Arrow¶
Arrow(int xVectorIndex = 0, int yVectorIndex = 1, ImVec2 lineScale = ImVec2(1, 1));right edge of texture. (0,-1) will draw exactly to the bottom etc.
Arrow::UsePreset¶
Arrow &UsePreset(Preset);Arrow::DrawAnnotation¶
void DrawAnnotation(ImDrawList *drawList, ImVec2 texel, Transform2D texelsToPixels, ImVec4 value);INTERNAL¶
Transform2D (struct)¶
| Member | |
|---|---|
ImVec2 Scale; | |
ImVec2 Translate; |
Transform2D::Inverse¶
Transform2D Inverse() const;Return an inverse transform such that transform.Inverse() * transform * vector == vector
imgui_tex_inspect_demo.h¶
Texture (struct)¶
| Member | |
|---|---|
ImTextureID texture; | |
ImVec2 size; |
ImGuiTexInspect::ShowDemoWindow¶
void ShowDemoWindow();