svg2png: Clean up code

Modify the code to fit coding style
This commit is contained in:
JunsuChoi 2021-06-24 10:28:51 +09:00 committed by Hermet Park
parent a459a53bc7
commit b17f3cc9a4

View file

@ -29,25 +29,25 @@
using namespace std; using namespace std;
struct PngBuilder { struct PngBuilder
{
void build(const std::string &fileName , const uint32_t width, const uint32_t height, uint32_t *buffer) void build(const std::string &fileName , const uint32_t width, const uint32_t height, uint32_t *buffer)
{ {
std::vector<unsigned char> image; std::vector<unsigned char> image;
image.resize(width * height * 4); image.resize(width * height * 4);
for(unsigned y = 0; y < height; y++) { for (unsigned y = 0; y < height; y++) {
for(unsigned x = 0; x < width; x++) { for (unsigned x = 0; x < width; x++) {
uint32_t n = buffer[ y * width + x ]; uint32_t n = buffer[ y * width + x ];
image[4 * width * y + 4 * x + 0] = ( n >> 16 ) & 0xff; image[4 * width * y + 4 * x + 0] = (n >> 16) & 0xff;
image[4 * width * y + 4 * x + 1] = ( n >> 8 ) & 0xff; image[4 * width * y + 4 * x + 1] = (n >> 8) & 0xff;
image[4 * width * y + 4 * x + 2] = n & 0xff; image[4 * width * y + 4 * x + 2] = n & 0xff;
image[4 * width * y + 4 * x + 3] = ( n >> 24 ) & 0xff; image[4 * width * y + 4 * x + 3] = (n >> 24) & 0xff;
} }
} }
unsigned error = lodepng::encode(fileName, image, width, height); unsigned error = lodepng::encode(fileName, image, width, height);
//if there's an error, display it //if there's an error, display it
if(error) std::cout << "encoder error " << error << ": "<< lodepng_error_text(error) << std::endl; if (error) std::cout << "encoder error " << error << ": "<< lodepng_error_text(error) << std::endl;
} }
}; };
@ -63,7 +63,6 @@ struct App
//Initialize ThorVG Engine //Initialize ThorVG Engine
if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) { if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) {
//Create a Canvas //Create a Canvas
auto canvas = tvg::SwCanvas::gen(); auto canvas = tvg::SwCanvas::gen();