pthom / imgui_bundle

Dear ImGui Bundle: an extensive set of Ready-to-use widgets and libraries, based on ImGui. Start your first app in 5 lines of code, or less. Whether you prefer Python or C++, this pack has your back!
https://pthom.github.io/imgui_bundle/
MIT License
590 stars 62 forks source link

imgui_tex_inspect displays incorrect color value of texture in windows #211

Closed ankerSlicerTeam closed 1 month ago

ankerSlicerTeam commented 1 month ago

a1dc6c29-bc14-43fd-9c65-6824dfc534de

pthom commented 1 month ago

This is likely an issue in ImGuiTexInspect

This demo only calls ImGuiTexInspect::ShowDemoWindow():

int main(int, char **)
{
    HelloImGui::SetAssetsFolder(DemosAssetsFolder());
    HelloImGui::SimpleRunnerParams runnerParams{.guiFunction = ImGuiTexInspect::ShowDemoWindow, .windowSize={1000, 1000}};
    ImmApp::AddOnsParams addOnsParams;
    addOnsParams.withTexInspect = true;
    ImmApp::Run(runnerParams, addOnsParams);
    return 0;
}

If you need to get pixel values, I advise you to use ImmVision which you can see in the demo

ankerSlicerTeam commented 1 month ago

Thank you for your answer. I have found the reason. imgui_tex_inspect sets a fixed value (512,512) when setting the texture size. However, when the image size is not (512,512), the texture is resized, and then the output rgba result is not displayed as shown after resize. By the way, ImmVision is a great tool and admire your excellent contribution

ankerSlicerTeam commented 1 month ago

Thank you for your answer. I have found the reason. imgui_tex_inspect sets a fixed value (512,512) when setting the texture size. However, when the image size is not (512,512), the texture is resized, and then the output rgba result is not displayed as shown after resize. By the way, ImmVision is a great tool and admire your excellent contribution

in imgui_tex_inspect_demo.h line 19:

Texture LoadTexture(const char * path)
{
    auto textureId = HelloImGui::ImTextureIdFromAsset(path);
    Texture r;
    r.size = ImVec2(512.f, 512.f); // This function is only by used the demo, which uses a 512x512 image
    r.texture = textureId;
    return r;
}
ankerSlicerTeam commented 1 month ago

However, the size of demo_tex_inspect.png displayed is 256*256

pthom commented 1 month ago

Ok thanks a lot for letting me know. I updated the code that sets the texture size. See these commits in the ImGuiTexInspect fork and in Dear ImGui Bundle.