Commit 3ea9e458 authored by Linshizhi's avatar Linshizhi

update example: skia_svg_render

parent 2a06c91a
......@@ -14,20 +14,24 @@
#include "include/core/SkData.h"
#include "include/gpu/gl/GrGLTypes.h"
int main(void) {
int main(int argc, char *argv[]) {
const int width = 1920;
const int height = 1080;
const int pixelBytes = 4;
if (argc < 3) {
std::cout << "skia_svg_render input_svg_path output_png_path\n";
return 1;
}
SkImageInfo imgInfo = SkImageInfo::Make(
width, height, kBGRA_8888_SkColorType, kOpaque_SkAlphaType);
size_t size = 1920 * 1080 * 4;
uint8_t *buffer = new uint8_t[size];
auto canvas = SkCanvas::MakeRasterDirect(
imgInfo, buffer, imgInfo.width() * pixelBytes);
SkFILEStream svgStream("/home/aydenlin/Downloads/example.svg");
SkFILEStream svgStream(argv[1]);
if (!svgStream.isValid()) {
return 1;
......@@ -51,7 +55,7 @@ int main(void) {
sk_sp<SkData> data = image->encodeToData(SkEncodedImageFormat::kPNG, 100);
uint8_t *dataPtr = const_cast<uint8_t*>(data->bytes());
std::ofstream out("/home/aydenlin/Downloads/out.png", std::ios::binary);
std::ofstream out(argv[2], std::ios::binary);
for (int i = 0; i < data->size(); ++i) {
out.write(reinterpret_cast<char*>(&dataPtr[i]), 1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment