1 /* 2 * Copyright 2014 Google Inc. 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 #ifndef Resources_DEFINED 9 #define Resources_DEFINED 10 11 #include "include/core/SkImage.h" 12 #include "include/core/SkString.h" 13 14 class SkBitmap; 15 class SkData; 16 class SkStreamAsset; 17 class SkTypeface; 18 19 SkString GetResourcePath(const char* resource = ""); 20 21 void SetResourcePath(const char* ); 22 23 bool DecodeDataToBitmap(sk_sp<SkData> data, SkBitmap* dst); 24 25 sk_sp<SkData> GetResourceAsData(const char* resource); 26 GetResourceAsBitmap(const char * resource,SkBitmap * dst)27inline bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) { 28 return DecodeDataToBitmap(GetResourceAsData(resource), dst); 29 } 30 GetResourceAsImage(const char * resource)31inline sk_sp<SkImage> GetResourceAsImage(const char* resource) { 32 return SkImage::MakeFromEncoded(GetResourceAsData(resource)); 33 } 34 35 std::unique_ptr<SkStreamAsset> GetResourceAsStream(const char* resource); 36 37 sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource, int ttcIndex = 0); 38 39 #endif // Resources_DEFINED 40