Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Loading multiple icons


Recommended Posts

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.

Link to post
Share on other sites

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);

 

  • Like 2
Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...