RonShortt Posted July 26, 2021 Share Posted July 26, 2021 I am loading a number of SVG icon files and wondered if there was a way to embed them in the C++ source code so that I don't need to include the files with the executable. LoadIcon only accepts a file name or Stream as the icon source. Quote Link to comment Share on other sites More sharing options...
Josh Posted July 26, 2021 Share Posted July 26, 2021 SVG files are XML vector files, so they can easily be stored in source code. The default SVG icons the interface uses are stored and loaded like this: auto buffer = CreateBuffer(); auto stream = CreateBufferStream(buffer); String s = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"> <svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\" enable-root=\"new 0 0 16 16\" xml:space=\"preserve\"> <polygon fill=\"#FFFFFF\" points=\"14.223,5.228 12.689,3.694 6.333,10.051 3.31,7.027 1.777,8.561 6.319,13.102 6.333,13.088 6.348,13.102 \"/> </svg>"; buffer->Resize(s.length() + 1); buffer->PokeString(0,s); auto icon_button_checkmark = LoadIcon(stream); 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
RonShortt Posted July 26, 2021 Author Share Posted July 26, 2021 That is exactly what I was looking for! Thank you very much! I am really enjoying programming with this package. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.