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 #ifndef DecodeUtils_DEFINED 9 #define DecodeUtils_DEFINED 10 11 #include "include/core/SkImage.h" 12 #include "include/core/SkRefCnt.h" 13 #include "tools/Resources.h" 14 15 class SkBitmap; 16 class SkData; 17 18 namespace ToolUtils { 19 bool DecodeDataToBitmap(sk_sp<SkData> data, SkBitmap* dst); 20 GetResourceAsBitmap(const char * resource,SkBitmap * dst)21inline bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) { 22 return DecodeDataToBitmap(GetResourceAsData(resource), dst); 23 } 24 GetResourceAsImage(const char * resource)25inline sk_sp<SkImage> GetResourceAsImage(const char* resource) { 26 return SkImages::DeferredFromEncodedData(GetResourceAsData(resource)); 27 } 28 29 } // namespace ToolUtils 30 31 #endif 32