Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImGui::ImageButton render transparent image error #8165

Closed
chris0306 opened this issue Nov 19, 2024 · 3 comments
Closed

ImGui::ImageButton render transparent image error #8165

chris0306 opened this issue Nov 19, 2024 · 3 comments

Comments

@chris0306
Copy link

Version/Branch of Dear ImGui:

Version 1.XX, Branch: XXX (master/docking/etc.)

Back-ends:

imgui_impl_XXX.cpp + imgui_impl_XXX.cpp

Compiler, OS:

GLESv2

Full config/build information:

No response

Details:

ImGui::Image(texid, ImVec2(128, 128), uv0, uv1);

if (ImGui::ImageButton(texid, ImVec2(128, 128))) {
printf("btn clicked!12!!\n");
}

ImGui::Image is right, but imagebutton color is wrong, the edge of "p" image is transparent.
how to solve it , thanks!!!

Screenshots/Video:

ppp

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
@GamingMinds-DanielC
Copy link
Contributor

Could be many things, you left out so much information that there is nothing to go on. First you can check the texture format and the blend states with RenderDoc, to see if they are as they should be.

@ocornut
Copy link
Owner

ocornut commented Nov 19, 2024

ImageButton() draws a background frame using the ImGuiCol_ButtonXXXX colors.

@ocornut
Copy link
Owner

ocornut commented Nov 25, 2024

ImageButton() draws a background frame using the ImGuiCol_ButtonXXXX colors.

So if you have a transparent image and want to disable that background you may need to use:

PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
ImageButton(...);
PopStyleColor(3);

You may wrap this into your own helper function if needed.

I am adding comments to clarify this in the ImageButton() declaration and definition.
Ideally we might introduce flags to control those behavior. Similarly to the problem discussed in #8131 for Image().

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants