Switch image handling in HTML from wxImage to wxBitmapBundle (PR #26474)

17 views
Skip to first unread message

Randalphwa

unread,
May 17, 2026, 6:59:40 PM (2 days ago) May 17
to wx-...@googlegroups.com, Subscribed

Primary reason is to allow SVG images in HTML pages, with the added bonus of multi-resolution png files being bundled together for better scaling on high DPI displays.

I also added a toolbar to the html/test sample just to make it easier to move forward/back including disabling/enabling the buttons depending on whether any history was available.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26474

Commit Summary

  • dff45c6 Switch to using wxBitmapBundle instead of wxImage
  • 06d3654 Add a toolbar for moving back/forward
  • b5739f8 Update wxHtmlWindow interface docs

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26474@github.com>

Randalphwa

unread,
May 17, 2026, 10:47:39 PM (2 days ago) May 17
to wx-...@googlegroups.com, Subscribed
Randalphwa left a comment (wxWidgets/wxWidgets#26474)

Turning this into a draft -- seeing a discrepancy between what lunasvg should be displaying versus what is actually displaying...


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26474/c4473816292@github.com>

VZ

unread,
May 18, 2026, 10:36:01 PM (4 hours ago) May 18
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Looks good, thanks!

I'd just like to avoid duplicating the code reading SVGs from stream, could you please do this? TIA!


In src/html/m_image.cpp:

>                  bool readImg = true;
-                if ( m_windowIface &&
-                     (input->GetLocation().Matches(wxT("*.gif")) ||
-                      input->GetLocation().Matches(wxT("*.GIF"))) )
+                wxString loc = input->GetLocation();
+
+                // SVG image path
+                if ( loc.Matches("*.svg") || loc.Matches("*.SVG") )
+                {
+#ifdef wxHAS_SVG
+                    // Read the entire stream into a buffer for SVG
+                    wxMemoryBuffer svgBuf;
+                    for ( ;; )
+                    {
+                        char tmp[4096];

We have just seen in #26461 that using 64KiB buffer is much faster than using 4KiB, so I think we should change the size here too. Or maybe just use Read(std::vector<char>& buffer) overload once the other PR is merged.


In src/html/m_image.cpp:

> +                // SVG image path
+                if ( loc.Matches("*.svg") || loc.Matches("*.SVG") )
+                {
+#ifdef wxHAS_SVG
+                    // Read the entire stream into a buffer for SVG
+                    wxMemoryBuffer svgBuf;
+                    for ( ;; )
+                    {
+                        char tmp[4096];
+                        s->Read(tmp, WXSIZEOF(tmp));
+                        const size_t n = s->LastRead();
+                        if ( n == 0 )
+                            break;
+                        svgBuf.AppendData(tmp, n);
+                    }
+                    wxBitmapBundle svgBundle = wxBitmapBundle::FromSVG(

Or maybe add FromSVG() overload taking a stream?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26474/review/4315258372@github.com>

Reply all
Reply to author
Forward
0 new messages