Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
use_skresources.cpp File Reference
#include "include/codec/SkCodec.h"
#include "include/codec/SkJpegDecoder.h"
#include "include/codec/SkPngDecoder.h"
#include "include/core/SkImage.h"
#include "include/core/SkString.h"
#include "modules/skresources/include/SkResources.h"
#include <cstdio>
#include <filesystem>

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 19 of file use_skresources.cpp.

19 {
20 if (argc != 2) {
21 printf("Usage: %s [folder]", argv[0]);
22 return 1;
23 }
24
25 SkCodecs::Register(SkJpegDecoder::Decoder());
26 SkCodecs::Register(SkPngDecoder::Decoder());
28
29 // Try to load two arbitrary files in //resources/images
30
31 sk_sp<skresources::ImageAsset> asset = frp->loadImageAsset("images", "baby_tux.png", "");
32 if (!asset) {
33 printf("Could not load baby_tux.png in images subdirectory\n");
34 return 1;
35 }
36 sk_sp<SkImage> tux = asset->getFrameData(0).image;
37 if (!tux) {
38 printf("Could not decode baby_tux.png in images subdirectory\n");
39 return 1;
40 }
41 printf("Baby Tux is %d by %d pixels big\n", tux->width(), tux->height());
42
43 asset = frp->loadImageAsset("images", "CMYK.jpg", "");
44 if (!asset || !asset->getFrameData(0).image) {
45 printf("Could not load/decode CMYK.jpg in images subdirectory\n");
46 return 1;
47 }
48
49 sk_sp<SkImage> cmyk = asset->getFrameData(0).image;
50 if (!cmyk) {
51 printf("Could not decode CMYK.jpg in images subdirectory\n");
52 return 1;
53 }
54 printf("CMYK is %d by %d pixels big\n", cmyk->width(), cmyk->height());
55
56 return 0;
57}
static sk_sp< FileResourceProvider > Make(SkString base_dir, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode)
constexpr SkCodecs::Decoder Decoder()
constexpr SkCodecs::Decoder Decoder()
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1