Atualização Hwgui 13-09-2026 Imagens SVG.

Projeto HwGui - Biblioteca visual para Harbour/xHarbour

Moderador: Moderadores

Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 8292
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 7 vezes
Curtiram: 2 vezes

Atualização Hwgui 13-09-2026 Imagens SVG.

Mensagem por Itamar M. Lins Jr. »

Olá!
Suporte a arquivos SVG.
O que há de mais moderno na opção de imagens.
As imagens são arquivos XML, extremamente pequenos e de alta resolução. Qualquer tamanho. 16, 256, etc...
Na Microsoft Windows 10/11 usa, no Linux é o padrão.

Código: Selecionar todos

2026-09-13 18:13 UTC-0300 Junior Itamar <itamarlins@gmail.com>
  * Language changed samples\test_svg.prg pt-br for en
    command for test SVG image files:
    hbmk2 test_svg.prg ..\svg.hbc

2026-09-13 18:02 UTC-0300 Junior Itamar <itamarlins@gmail.com>
  * Add optional SVG image loading via librsvg (Cairo + GLib + GObject).
    Enable with -D__USE_LIBRSVG and link against rsvg-2, cairo,
    gobject-2.0 and glib-2.0.
    New function:
      hwg_LoadSvg( cPath, nWidth, nHeight ) -> HBITMAP
    The DIB is filled with white before rendering so that transparent
    areas of the SVG appear as white instead of black (hwg_Drawbitmap
    ignores the alpha channel).
    When __USE_LIBRSVG is not defined, HWG_LOADSVG() is compiled as a
    stub that returns NULL, so callers do not need to guard the call
    with #ifdef.
  * hwgui.hbp add commented line #-cflag=-D__USE_LIBRSVG
  * Add HBitmap:AddHandle( hBmp ) to wrap an HBITMAP created outside
    the class (e.g. by hwg_LoadSvg). The handle is registered in the
    shared bitmap list, so HBitmap:RELEASE() deletes it when the object
    is released.
  * source\winapi\draw.c add function HWG_LOADSVG()
  * source\winapi\drawwidg.prg add method AddHandle()
  + Add svg.hbc for use of optional SVG recurse. hbmk2 hwgui.hbp svg.hbc
  + Add files hwgui.svg and info.svg
  + Add sample test_svg.prg
  ! Attention with file hwgui.hbp
    # Uncomment these line to build HwGUI with LIBRSVG SVG files
    #-cflag=-D__USE_LIBRSVG
    command: hbmk2 hwgui.hbp svg.hbc
    Note: Use msys2 on Windows OS Clang.
        * pacman -S mingw-w64-clang-x86_64-librsvg
        * pacman -S mingw-w64-clang-x86_64-gdk-pixbuf2
    This resource uses several libraries: 4 main libs + their
    transitive dependencies. To find all the libraries needed for
    distributing your app:
    C:\msys64\clang64\bin\llvm-objdump.exe -p test_svg.exe | C:\msys64\usr\bin\grep.exe -i "DLL Name"
    cd C:\msys64\clang64\bin
    C:\msys64\clang64\bin\llvm-objdump.exe -p librsvg-2-2.dll | C:\msys64\usr\bin\grep.exe -i "DLL Name"
    C:\msys64\clang64\bin\llvm-objdump.exe -p libcairo-2.dll | C:\msys64\usr\bin\grep.exe -i "DLL Name"
    C:\msys64\clang64\bin\llvm-objdump.exe -p libgobject-2.0-0.dll | C:\msys64\usr\bin\grep.exe -i "DLL Name"
    C:\msys64\clang64\bin\llvm-objdump.exe -p libglib-2.0-0.dll | C:\msys64\usr\bin\grep.exe -i "DLL Name"
Agora estudar a possibilidade de linkar tudo estático, para não depender de tantas DLLs.
O arquivo SVG! Isso é uma IMAGEM ou pelo menos como ele deve ser redenrizada.

Código: Selecionar todos

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 286 154" width="100%" height="100%">
   <!-- General White Background -->
   <rect width="286" height="154" fill="#FFFFFF" />

   <!-- Dark Brown Shape on the Left -->
   <path d="M 0,0 L 82,0 L 37,74 L 71,154 L 0,154 Z" fill="#6A3B03" />

   <!-- Orange/Triangular Bottom Shape -->
   <path d="M 37,74 L 286,74 L 71,154 Z" fill="#FF843D" />

   <!-- Main Text Block -->
   <g font-family="Arial, Helvetica, sans-serif" fill="#000000">
      <text x="76" y="34" font-size="25" font-weight="normal">HwGUI</text>
      <text x="76" y="62" font-size="21" font-weight="normal">Harbour Win32 Gui</text>
      <text x="167" y="143" font-size="12" font-weight="normal">By Alexander Kresin</text>
   </g>
</svg>
Quando renderizado pelo app aparece assim:
Capturar_svg.PNG
Capturar_svg.PNG (21.29 KiB) Exibido 59 vezes
Sem serrilhas, alta definição.
Saudações,
Itamar M. Lins Jr.
alxsts
Colaborador
Colaborador
Mensagens: 3197
Registrado em: 12 Ago 2008 15:50
Localização: São Paulo-SP-Brasil
Curtiram: 9 vezes

Re: Atualização Hwgui 13-09-2026 Imagens SVG.

Mensagem por alxsts »

Olá!

A data da atualização ficou errada no título do post...
[]´s
Alexandre Santos (AlxSts)
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 8292
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 7 vezes
Curtiram: 2 vezes

Re: Atualização Hwgui 13-09-2026 Imagens SVG.

Mensagem por Itamar M. Lins Jr. »

Olá!
Pronto. É coisa prá dedeu! Sempre passa algo.
Agora aqui tentando linkar static...
Saudações,
Itamar M. Lins Jr.
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 8292
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 7 vezes
Curtiram: 2 vezes

Re: Atualização Hwgui 13-09-2026 Imagens SVG.

Mensagem por Itamar M. Lins Jr. »

Olá!
Pronto. Consegui compilar -fullstatic.
Agora o .exe cresce um pouco, mas é o preço da linkagem estática.
Capturar_dll.PNG
Capturar_dll.PNG (50.59 KiB) Exibido 51 vezes
O negócio que era cheio de segredinhos... Agora com IA... E lembrando de alguma coisa que estudei lá no idos de 1980.
E outra, uso qualquer IA. Tô nem ai, para as IAs :lol:
Saudações,
Itamar M. Lins Jr.
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 8292
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 7 vezes
Curtiram: 2 vezes

Re: Atualização Hwgui 13-09-2026 Imagens SVG.

Mensagem por Itamar M. Lins Jr. »

Olá!
Tá ai, o segredo revelado.
Até bug de bzip, foi corrigido.

Código: Selecionar todos

2026-09-13 20:35 UTC-0300 Junior Itamar <itamarlins@gmail.com>
  * Add support for fully static linking of librsvg (SVG) on
    MSYS2 CLANG64. Produces a single .exe with no third-party
    DLL dependencies - only Windows system DLLs remain.
    Tested with:
      MSYS2 CLANG64 (Clang 22)
      mingw-w64-clang-x86_64-librsvg 2.63.0-1
      Harbour 3.2.1dev (r2607071005)
    Note: librsvg 2.57 or earlier has a bug in the static library
    on MinGW that prevents linking (ld.lld: .idata$4 should not
    refer to special section 0). Version 2.63.0 is the first
    known working release.
  * svg.hbc: complete rewrite for static linking.
    Lists ~45 static libraries in dependency order plus the
    required Windows system libraries. All comments in English.
    Build command:
      hbmk2 your_app.prg path/to/hwgui.hbp path/to/svg.hbc -fullstatic
  * draw.c: add bz2_error_stub.c logic (bz_internal_error).
    The libbz2.a static archive references bz_internal_error()
    but does not define it - the default handler is only in the
    shared library. The stub is now part of libhwgui.a so that
    any statically linked application resolves the symbol
    automatically without needing to provide its own stub.
  * Static link produces test_svg.exe at 34 MB.
    After llvm-strip -s (or --strip-all):
       25.783.296 bytes  (~25.7 MB)
    Both -s and --strip-all have the same effect on PE/COFF:
    they remove the symbol table. No further reduction from
    strip alone.
  * Options for further reduction (not applied by default):
      - UPX:  upx --best --lzma test_svg.exe  -> ~9 MB
        Caveat: some antivirus tools report false positives
        on UPX-compressed executables.
  * Verified with:
      llvm-objdump -p test_svg.exe | grep "DLL Name"
    Result: 38 entries, all Windows system DLLs
    (KERNEL32, USER32, GDI32, gdiplus, ole32, SHELL32,
     api-ms-win-crt-*, etc.). No librsvg, cairo, glib,
     pango, gdk-pixbuf, harfbuzz, freetype, or any other
     third-party DLL is imported.
    The executable is fully self-contained on any
    Windows 10 or later system.
  Files changed:
      source/winapi/draw.c      add bz_internal_error() stub
      svg.hbc                   full rewrite for -fullstatic
Saudações,
Itamar M. Lins Jr.
Responder