Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
I
IMGRender
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
IMGRender
Commits
3ea9e458
Commit
3ea9e458
authored
Aug 01, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example: skia_svg_render
parent
2a06c91a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
skia_svg_render.cc
examples/skia_svg_render.cc
+8
-4
No files found.
examples/skia_svg_render.cc
View file @
3ea9e458
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment