From 20d480ce9c6bfdd54d2b1e5e34306744968a4f37 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Wed, 15 Jan 2020 15:32:59 -0500 Subject: Add AImageDecoder HeaderInfo_get/_setDataSpace Bug: 135133301 Test: Iffe659e50078139188c3325545624640ae177cc2 Default to ADATASPACE_UNKNOWN for images that do not have a matching ADataSpace. This matches the behavior of android.graphics.ImageDecoder and BitmapFactory, which would use an "Unknown" ColorSpace for the same images. It also means that a client who knows the true underlying profile information to treat it as if it came from that profile. Further, it means that if we add more ADataSpace values in the future, the decode will be unchanged. A client can still choose to use a known ADataSpace using _setDataSpace. Change-Id: Id3ecf3bab17e4905fb2b75410ec756233d600c97 --- include/android/imagedecoder.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'include/android/imagedecoder.h') diff --git a/include/android/imagedecoder.h b/include/android/imagedecoder.h index 4b6446c33d..68401ea5a2 100644 --- a/include/android/imagedecoder.h +++ b/include/android/imagedecoder.h @@ -158,6 +158,25 @@ int AImageDecoder_setAndroidBitmapFormat(AImageDecoder*, */ int AImageDecoder_setUnpremultipliedRequired(AImageDecoder*, bool required) __INTRODUCED_IN(30); +/** + * Choose the dataspace for the output. + * + * Not supported for {@link ANDROID_BITMAP_FORMAT_A_8}, which does not support + * an ADataSpace. + * + * @param dataspace The {@link ADataSpace} to decode into. An ADataSpace + * specifies how to interpret the colors. By default, + * AImageDecoder will decode into the ADataSpace specified by + * {@link AImageDecoderHeaderInfo_getDataSpace}. If this + * parameter is set to a different ADataSpace, AImageDecoder + * will transform the output into the specified ADataSpace. + * @return - {@link ANDROID_IMAGE_DECODER_SUCCESS} on success + * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} for a null + * AImageDecoder or an integer that does not correspond to an + * ADataSpace value. + */ +int AImageDecoder_setDataSpace(AImageDecoder*, int32_t dataspace) __INTRODUCED_IN(30); + /** * Specify the output size for a decoded image. * @@ -260,6 +279,25 @@ AndroidBitmapFormat AImageDecoderHeaderInfo_getAndroidBitmapFormat( int AImageDecoderHeaderInfo_getAlphaFlags( const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30); +/** + * Report the dataspace the AImageDecoder will decode to by default. + * AImageDecoder will try to choose one that is sensible for the + * image and the system. Note that this may not exactly match the ICC + * profile (or other color information) stored in the encoded image. + * + * @return The {@link ADataSpace} most closely representing the way the colors + * are encoded (or {@link ADATASPACE_UNKNOWN} if there is not an + * approximate ADataSpace). This specifies how to interpret the colors + * in the decoded image, unless {@link AImageDecoder_setDataSpace} is + * called to decode to a different ADataSpace. + * + * Note that ADataSpace only exposes a few values. This may return + * ADATASPACE_UNKNOWN, even for Named ColorSpaces, if they have no + * corresponding ADataSpace. + */ +int32_t AImageDecoderHeaderInfo_getDataSpace( + const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30); + /** * Return the minimum stride that can be used, taking the specified * (or default) (possibly scaled) width, crop rect and -- cgit v1.2.3-59-g8ed1b