972 {
974 return Result::Skip(
"Uninteresting to test image generator to 565.");
975 }
976
978 if (!encoded) {
980 }
981
982#if defined(SK_BUILD_FOR_WIN)
983
984 SkAutoCoInitialize com;
985 if (!com.succeeded()) {
987 }
988#endif
989
990 std::unique_ptr<SkImageGenerator>
gen(
nullptr);
991 switch (fMode) {
995 return Result::Fatal(
"Could not create codec image generator.");
996 }
997 break;
999#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
1000 gen = SkImageGeneratorCG::MakeFromEncodedCG(encoded);
1001#elif defined(SK_BUILD_FOR_WIN)
1002 gen = SkImageGeneratorWIC::MakeFromEncodedWIC(encoded);
1003#elif defined(SK_ENABLE_NDK_IMAGES)
1004 gen = SkImageGeneratorNDK::MakeFromEncodedNDK(encoded);
1005#endif
1007 return Result::Fatal(
"Could not create platform image generator.");
1008 }
1009 break;
1010 }
1011 default:
1014 }
1015
1016
1017 if (fIsGpu) {
1020 return Result::Fatal(
"Could not create image from codec image generator.");
1021 }
1024 }
1025
1026
1027 SkImageInfo decodeInfo =
gen->getInfo().makeAlphaType(fDstAlphaType);
1028
1030 size_t rowBytes = decodeInfo.
width() * bpp;
1032 if (!
gen->getPixels(decodeInfo, pixels.get(), rowBytes)) {
1034#if defined(SK_BUILD_FOR_WIN)
1036
1038 }
1039#endif
1040 return Result(
1041 status,
1043 }
1044
1049}
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
@ kGetFromCanvas_DstColorType
static Result Skip(const char *fmt,...) SK_PRINTF_LIKE(1
static Result Fatal(const char *fmt,...) SK_PRINTF_LIKE(1
SkImageInfo imageInfo() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static std::unique_ptr< SkImageGenerator > MakeFromEncodedCodec(sk_sp< SkData >, std::optional< SkAlphaType >=std::nullopt)
static sk_sp< SkData > MakeFromFileName(const char path[])
const char * c_str() const
static void draw_to_canvas(SkCanvas *canvas, const SkImageInfo &info, void *pixels, size_t rowBytes, CodecSrc::DstColorType dstColorType, SkScalar left=0, SkScalar top=0)
static void set_bitmap_color_space(SkImageInfo *info)
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
sk_sp< const SkImage > image
int bytesPerPixel() const
SkColorType colorType() const