Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
decode_png_main.cpp File Reference
#include "include/codec/SkCodec.h"
#include "include/codec/SkPngDecoder.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkStream.h"
#include <cstdio>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 15 of file decode_png_main.cpp.

15 {
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
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}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static std::unique_ptr< SkFILEStream > Make(const char path[])
Definition SkStream.h:314
GAsyncResult * result
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1