Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
decode_everything.cpp File Reference
#include "include/codec/SkBmpDecoder.h"
#include "include/codec/SkCodec.h"
#include "include/codec/SkGifDecoder.h"
#include "include/codec/SkIcoDecoder.h"
#include "include/codec/SkJpegDecoder.h"
#include "include/codec/SkJpegxlDecoder.h"
#include "include/codec/SkPngDecoder.h"
#include "include/codec/SkWbmpDecoder.h"
#include "include/codec/SkWebpDecoder.h"
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkStream.h"
#include <cstdio>
#include <memory>

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 24 of file decode_everything.cpp.

24 {
25 if (argc != 2) {
26 printf("Usage: %s <name.png>", argv[0]);
27 return 1;
28 }
29
30 std::unique_ptr<SkFILEStream> input = SkFILEStream::Make(argv[1]);
31 if (!input || !input->isValid()) {
32 printf("Cannot open file %s\n", argv[1]);
33 return 1;
34 }
35
36 sk_sp<SkData> data = SkData::MakeFromStream(input.get(), input->getLength());
37
38 std::unique_ptr<SkCodec> codec = nullptr;
39 if (SkBmpDecoder::IsBmp(data->bytes(), data->size())) {
40 codec = SkBmpDecoder::Decode(data, nullptr);
41 } else if (SkGifDecoder::IsGif(data->bytes(), data->size())) {
42 codec = SkGifDecoder::Decode(data, nullptr);
43 } else if (SkIcoDecoder::IsIco(data->bytes(), data->size())) {
44 codec = SkIcoDecoder::Decode(data, nullptr);
45 } else if (SkJpegDecoder::IsJpeg(data->bytes(), data->size())) {
46 codec = SkJpegDecoder::Decode(data, nullptr);
47 } else if (SkJpegxlDecoder::IsJpegxl(data->bytes(), data->size())) {
48 codec = SkJpegxlDecoder::Decode(data, nullptr);
49 } else if (SkPngDecoder::IsPng(data->bytes(), data->size())) {
50 codec = SkPngDecoder::Decode(data, nullptr);
51 } else if (SkWbmpDecoder::IsWbmp(data->bytes(), data->size())) {
52 codec = SkWbmpDecoder::Decode(data, nullptr);
53 } else if (SkWebpDecoder::IsWebp(data->bytes(), data->size())) {
54 codec = SkWebpDecoder::Decode(data, nullptr);
55 } else {
56 printf("Unsupported file format\n");
57 return 1;
58 }
59
60 SkImageInfo info = codec->getInfo();
61 printf("Image is %d by %d pixels.\n", info.width(), info.height());
62
63 return 0;
64}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
Definition SkData.cpp:208
static std::unique_ptr< SkFILEStream > Make(const char path[])
Definition SkStream.h:314
SK_API bool IsBmp(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsGif(const void *, size_t)
SK_API bool IsIco(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsJpeg(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsJpegxl(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsPng(const void *, size_t)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
SK_API bool IsWbmp(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsWebp(const void *, size_t)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41