From b076b0f48b9674682d7555722acf4fd4b8f4de07 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Thu, 24 Jun 2021 10:28:51 +0900 Subject: [PATCH] svg2png: Clean up code Modify the code to fit coding style --- src/bin/svg2png/svg2png.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/svg2png/svg2png.cpp b/src/bin/svg2png/svg2png.cpp index f678e1f6..3e0f56e0 100644 --- a/src/bin/svg2png/svg2png.cpp +++ b/src/bin/svg2png/svg2png.cpp @@ -29,25 +29,25 @@ using namespace std; -struct PngBuilder { - +struct PngBuilder +{ void build(const std::string &fileName , const uint32_t width, const uint32_t height, uint32_t *buffer) { std::vector image; image.resize(width * height * 4); - for(unsigned y = 0; y < height; y++) { - for(unsigned x = 0; x < width; x++) { + for (unsigned y = 0; y < height; y++) { + for (unsigned x = 0; x < 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 + 1] = ( n >> 8 ) & 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 + 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); //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 if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) { - //Create a Canvas auto canvas = tvg::SwCanvas::gen(); -- 2.34.1