Android SKIA Image Decoding

2019-07-19 02:35发布

问题:

HI,

I am currently studying how Android decode and image file. When I checked the code, it seems like it is calling the SKIA library. But, how do I know what are the image file format supported by android/skia basing on the source code?

I am not an expert in programming, so I am still trying to understand C++ and Java language.

I am now lost at SkImageDecoder* decoder = SkImageDecoder::Factory(stream); inside the BitmapFactory.cpp (JNI file). SkImageDecoder::Factory(stream) seems to be a template.

Anyone can explain me what is happening inside SKImageDecoder::Factory()? Any feedback will be greatly appreciated.

Thanks,
artsylar

回答1:

In skia/include/images/SkImageDecoder.h file, there is the image list decoding supported by Skia:

enum Format {
    kUnknown_Format,
    kBMP_Format,
    kGIF_Format,
    kICO_Format,
    kJPEG_Format,
    kPNG_Format,
    kWBMP_Format,
    kWEBP_Format,

    kLastKnownFormat = kWEBP_Format
};

In SkImageDecoder::Factory(stream) function, it will new a decoder instance according to analyze the Stream's header.



回答2:

By looking at the source codes of Android, I think the following image formats are supported. ICO (Windows ICON image format), BMP, JPEG, WBMP, GIF, and PNG.

Please correct me if I am wrong. Thank you.



回答3:

PNG, JPEG, and GIF are the supported formats. The primary formats used on Android are PNG and JPEG.



标签: android skia