Explorar el Código

imgui_freetype: fixed divide by zero while handling FT_PIXEL_MODE_BGRA glyphs. (#7267, #3369)

ocornut hace 1 año
padre
commit
50a0f18e6a
Se han modificado 2 ficheros con 2 adiciones y 1 borrados
  1. 1 0
      docs/CHANGELOG.txt
  2. 1 1
      misc/freetype/imgui_freetype.cpp

+ 1 - 0
docs/CHANGELOG.txt

@@ -93,6 +93,7 @@ Other changes:
 - Debug Tools: Metrics/Debugger: Browsing a Storage perform hover lookup on identifier.
 - Viewports: Backported 'void* ImGuiViewport::PlatformHandle' from docking branch for
   use by backends.
+- imgui_freetype: Fixed divide by zero while handling FT_PIXEL_MODE_BGRA glyphs. (#7267, #3369)
 - Backends: OpenGL2, OpenGL3: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it
   has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (#7748) [@mlauss2]
 - Backends: SDL3: Update for API removal of keysym field in SDL_KeyboardEvent. (#7728)

+ 1 - 1
misc/freetype/imgui_freetype.cpp

@@ -357,7 +357,7 @@ namespace
         case FT_PIXEL_MODE_BGRA:
             {
                 // FIXME: Converting pre-multiplied alpha to straight. Doesn't smell good.
-                #define DE_MULTIPLY(color, alpha) (ImU32)(255.0f * (float)color / (float)alpha + 0.5f)
+                #define DE_MULTIPLY(color, alpha) ImMin((ImU32)(255.0f * (float)color / (float)(alpha + FLT_MIN) + 0.5f), 255u)
                 if (multiply_table == nullptr)
                 {
                     for (uint32_t y = 0; y < h; y++, src += src_pitch, dst += dst_pitch)