sammycage / lunasvg

lunasvg is a standalone SVG rendering library in C++
MIT License
818 stars 115 forks source link

Taking Pull requests? SVG2ICO example. #151

Closed g40 closed 6 months ago

g40 commented 6 months ago

Hello @sammycage .

I have some relatively simple C++ code here that converts an SVG into a multiple resolution .ICO complete with transparency. It is Windows only. Would you like a PR? (Single C++ .h file only)

//-----------------------------------------------------------------------------
// create an icon with 1+ entries from an SVG file
// 256x256 maximum supported size. 32bpp only
static
bool
MakeIcon(
    // .svg filename
    const std::string& ipname,
    // .ico filename
    const std::string& opname,
    // add size pairs to suit
    const std::vector<std::pair<int, int>> dimensions = { {128,128} },
    // transparent background
    std::uint32_t bgColor = 0x00000000)

Example output viewed in Axialis Icon Workshop

image

sammycage commented 6 months ago

Thanks a bunch for your fantastic work! Just a quick note about the pull request: currently, we can't accept requests with dependencies. Hope you understand.

g40 commented 6 months ago

Hello. I do indeed.

[edit]

This is an all-inline implementation. There are no 3rd party dependencies or build requirements aside from the standard Windows libraries and, of course, LunaSVG itself.

#pragma once

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <lunasvg.h>
#include <windows.h>
sammycage commented 6 months ago

"#include " is not available on all platforms.

g40 commented 6 months ago

Err, yes. " It is Windows only."

sammycage commented 6 months ago

Okay, create the pull request, and make sure you include a build script. Let me review it.

sammycage commented 6 months ago

@g40 FYI, when I say dependencies, I don't solely mean 3rd party libraries; I'm also referring to platforms. A lot of people are using this library because it's standalone.

g40 commented 6 months ago

PR is available now.