Flutter Engine
The Flutter Engine
third_party
skia
example
external_client
src
decode_png_main.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2023 Google LLC
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#include "
include/codec/SkCodec.h
"
9
#include "
include/codec/SkPngDecoder.h
"
10
#include "
include/core/SkImageInfo.h
"
11
#include "
include/core/SkStream.h
"
12
13
#include <cstdio>
14
15
int
main
(
int
argc,
char
**
argv
) {
16
if
(argc != 2) {
17
printf
(
"Usage: %s <name.png>"
,
argv
[0]);
18
return
1;
19
}
20
21
std::unique_ptr<SkFILEStream> input =
SkFILEStream::Make
(
argv
[1]);
22
if
(!input || !input->isValid()) {
23
printf
(
"Cannot open file %s\n"
,
argv
[1]);
24
return
1;
25
}
26
27
SkCodec::Result
result
;
28
auto
codec =
SkPngDecoder::Decode
(std::move(input), &
result
);
29
if
(!codec) {
30
printf
(
"Cannot decode file %s as a PNG\n"
,
argv
[1]);
31
printf
(
"Result code: %d\n"
,
result
);
32
return
1;
33
}
34
35
SkImageInfo
info
= codec->getInfo();
36
printf
(
"Image is %d by %d pixels.\n"
,
info
.width(),
info
.height());
37
38
return
0;
39
}
info
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition:
DM.cpp:213
SkCodec.h
SkImageInfo.h
SkPngDecoder.h
SkStream.h
SkCodec::Result
Result
Definition:
SkCodec.h:76
SkFILEStream::Make
static std::unique_ptr< SkFILEStream > Make(const char path[])
Definition:
SkStream.h:314
main
int main(int argc, char **argv)
Definition:
decode_png_main.cpp:15
result
GAsyncResult * result
Definition:
fl_text_input_plugin.cc:106
argv
char ** argv
Definition:
library.h:9
SkPngDecoder::Decode
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
Definition:
SkPngCodec.cpp:1238
SkSL::String::printf
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition:
SkSLString.cpp:83
SkImageInfo
Definition:
SkImageInfo.h:208
Generated on Sun Jun 23 2024 21:55:56 for Flutter Engine by
1.9.4