1*38e8c45fSAndroid Build Coastguard Worker /* 2*38e8c45fSAndroid Build Coastguard Worker * Copyright (C) 2019 The Android Open Source Project 3*38e8c45fSAndroid Build Coastguard Worker * 4*38e8c45fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*38e8c45fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*38e8c45fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*38e8c45fSAndroid Build Coastguard Worker * 8*38e8c45fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*38e8c45fSAndroid Build Coastguard Worker * 10*38e8c45fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*38e8c45fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*38e8c45fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*38e8c45fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*38e8c45fSAndroid Build Coastguard Worker * limitations under the License. 15*38e8c45fSAndroid Build Coastguard Worker */ 16*38e8c45fSAndroid Build Coastguard Worker 17*38e8c45fSAndroid Build Coastguard Worker /** 18*38e8c45fSAndroid Build Coastguard Worker * @defgroup ImageDecoder Android Image Decoder 19*38e8c45fSAndroid Build Coastguard Worker * 20*38e8c45fSAndroid Build Coastguard Worker * Functions for converting encoded images into RGBA pixels. 21*38e8c45fSAndroid Build Coastguard Worker * 22*38e8c45fSAndroid Build Coastguard Worker * Similar to the Java counterpart android.graphics.ImageDecoder, it can be used 23*38e8c45fSAndroid Build Coastguard Worker * to decode images in the following formats: 24*38e8c45fSAndroid Build Coastguard Worker * - JPEG 25*38e8c45fSAndroid Build Coastguard Worker * - PNG 26*38e8c45fSAndroid Build Coastguard Worker * - GIF 27*38e8c45fSAndroid Build Coastguard Worker * - WebP 28*38e8c45fSAndroid Build Coastguard Worker * - BMP 29*38e8c45fSAndroid Build Coastguard Worker * - ICO 30*38e8c45fSAndroid Build Coastguard Worker * - WBMP 31*38e8c45fSAndroid Build Coastguard Worker * - HEIF 32*38e8c45fSAndroid Build Coastguard Worker * - Digital negatives (via the DNG SDK) 33*38e8c45fSAndroid Build Coastguard Worker * <p>It has similar options for scaling, cropping, and choosing the output format. 34*38e8c45fSAndroid Build Coastguard Worker * Unlike the Java API, which can create an android.graphics.Bitmap or 35*38e8c45fSAndroid Build Coastguard Worker * android.graphics.drawable.Drawable object, AImageDecoder decodes directly 36*38e8c45fSAndroid Build Coastguard Worker * into memory provided by the client. For more information, see the 37*38e8c45fSAndroid Build Coastguard Worker * <a href="https://developer.android.com/ndk/guides/image-decoder">Image decoder</a> 38*38e8c45fSAndroid Build Coastguard Worker * developer guide. 39*38e8c45fSAndroid Build Coastguard Worker * @{ 40*38e8c45fSAndroid Build Coastguard Worker */ 41*38e8c45fSAndroid Build Coastguard Worker 42*38e8c45fSAndroid Build Coastguard Worker /** 43*38e8c45fSAndroid Build Coastguard Worker * @file imagedecoder.h 44*38e8c45fSAndroid Build Coastguard Worker * @brief API for decoding images. 45*38e8c45fSAndroid Build Coastguard Worker */ 46*38e8c45fSAndroid Build Coastguard Worker 47*38e8c45fSAndroid Build Coastguard Worker #ifndef ANDROID_IMAGE_DECODER_H 48*38e8c45fSAndroid Build Coastguard Worker #define ANDROID_IMAGE_DECODER_H 49*38e8c45fSAndroid Build Coastguard Worker 50*38e8c45fSAndroid Build Coastguard Worker #include "bitmap.h" 51*38e8c45fSAndroid Build Coastguard Worker #include <android/rect.h> 52*38e8c45fSAndroid Build Coastguard Worker #include <stdint.h> 53*38e8c45fSAndroid Build Coastguard Worker 54*38e8c45fSAndroid Build Coastguard Worker #if !defined(__INTRODUCED_IN) 55*38e8c45fSAndroid Build Coastguard Worker #define __INTRODUCED_IN(__api_level) /* nothing */ 56*38e8c45fSAndroid Build Coastguard Worker #endif 57*38e8c45fSAndroid Build Coastguard Worker 58*38e8c45fSAndroid Build Coastguard Worker #ifdef __cplusplus 59*38e8c45fSAndroid Build Coastguard Worker extern "C" { 60*38e8c45fSAndroid Build Coastguard Worker #endif 61*38e8c45fSAndroid Build Coastguard Worker 62*38e8c45fSAndroid Build Coastguard Worker struct AAsset; 63*38e8c45fSAndroid Build Coastguard Worker 64*38e8c45fSAndroid Build Coastguard Worker /** 65*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} functions result code. 66*38e8c45fSAndroid Build Coastguard Worker * 67*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 30. 68*38e8c45fSAndroid Build Coastguard Worker * 69*38e8c45fSAndroid Build Coastguard Worker * Many functions will return this to indicate success 70*38e8c45fSAndroid Build Coastguard Worker * ({@link ANDROID_IMAGE_DECODER_SUCCESS}) or the reason for the failure. On 71*38e8c45fSAndroid Build Coastguard Worker * failure, any out-parameters should be considered uninitialized, except where 72*38e8c45fSAndroid Build Coastguard Worker * specified. Use {@link AImageDecoder_resultToString} for a readable 73*38e8c45fSAndroid Build Coastguard Worker * version of the result code. 74*38e8c45fSAndroid Build Coastguard Worker */ 75*38e8c45fSAndroid Build Coastguard Worker enum { 76*38e8c45fSAndroid Build Coastguard Worker /** 77*38e8c45fSAndroid Build Coastguard Worker * Decoding was successful and complete. 78*38e8c45fSAndroid Build Coastguard Worker */ 79*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_SUCCESS = 0, 80*38e8c45fSAndroid Build Coastguard Worker /** 81*38e8c45fSAndroid Build Coastguard Worker * The input is incomplete. 82*38e8c45fSAndroid Build Coastguard Worker */ 83*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_INCOMPLETE = -1, 84*38e8c45fSAndroid Build Coastguard Worker /** 85*38e8c45fSAndroid Build Coastguard Worker * The input contained an error after decoding some lines. 86*38e8c45fSAndroid Build Coastguard Worker */ 87*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_ERROR = -2, 88*38e8c45fSAndroid Build Coastguard Worker /** 89*38e8c45fSAndroid Build Coastguard Worker * Could not convert. For example, attempting to decode an image with 90*38e8c45fSAndroid Build Coastguard Worker * alpha to an opaque format. 91*38e8c45fSAndroid Build Coastguard Worker */ 92*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_INVALID_CONVERSION = -3, 93*38e8c45fSAndroid Build Coastguard Worker /** 94*38e8c45fSAndroid Build Coastguard Worker * The scale is invalid. It may have overflowed, or it may be incompatible 95*38e8c45fSAndroid Build Coastguard Worker * with the current alpha setting. 96*38e8c45fSAndroid Build Coastguard Worker */ 97*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_INVALID_SCALE = -4, 98*38e8c45fSAndroid Build Coastguard Worker /** 99*38e8c45fSAndroid Build Coastguard Worker * Some other parameter is invalid. 100*38e8c45fSAndroid Build Coastguard Worker */ 101*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_BAD_PARAMETER = -5, 102*38e8c45fSAndroid Build Coastguard Worker /** 103*38e8c45fSAndroid Build Coastguard Worker * Input was invalid before decoding any pixels. 104*38e8c45fSAndroid Build Coastguard Worker */ 105*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_INVALID_INPUT = -6, 106*38e8c45fSAndroid Build Coastguard Worker /** 107*38e8c45fSAndroid Build Coastguard Worker * A seek was required and it failed. 108*38e8c45fSAndroid Build Coastguard Worker */ 109*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_SEEK_ERROR = -7, 110*38e8c45fSAndroid Build Coastguard Worker /** 111*38e8c45fSAndroid Build Coastguard Worker * Some other error. For example, an internal allocation failed. 112*38e8c45fSAndroid Build Coastguard Worker */ 113*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_INTERNAL_ERROR = -8, 114*38e8c45fSAndroid Build Coastguard Worker /** 115*38e8c45fSAndroid Build Coastguard Worker * AImageDecoder did not recognize the format. 116*38e8c45fSAndroid Build Coastguard Worker */ 117*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT = -9, 118*38e8c45fSAndroid Build Coastguard Worker /** 119*38e8c45fSAndroid Build Coastguard Worker * The animation has reached the end. 120*38e8c45fSAndroid Build Coastguard Worker */ 121*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_FINISHED = -10, 122*38e8c45fSAndroid Build Coastguard Worker /** 123*38e8c45fSAndroid Build Coastguard Worker * This method cannot be called while the AImageDecoder is in its current 124*38e8c45fSAndroid Build Coastguard Worker * state. For example, various setters (like {@link AImageDecoder_setTargetSize}) 125*38e8c45fSAndroid Build Coastguard Worker * can only be called while the AImageDecoder is set to decode the first 126*38e8c45fSAndroid Build Coastguard Worker * frame of an animation. This ensures that any blending and/or restoring 127*38e8c45fSAndroid Build Coastguard Worker * prior frames works correctly. 128*38e8c45fSAndroid Build Coastguard Worker */ 129*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_INVALID_STATE = -11, 130*38e8c45fSAndroid Build Coastguard Worker }; 131*38e8c45fSAndroid Build Coastguard Worker 132*38e8c45fSAndroid Build Coastguard Worker /** 133*38e8c45fSAndroid Build Coastguard Worker * Return a constant string value representing the error code. 134*38e8c45fSAndroid Build Coastguard Worker * 135*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 136*38e8c45fSAndroid Build Coastguard Worker * 137*38e8c45fSAndroid Build Coastguard Worker * Pass the return value from an {@link AImageDecoder} method (e.g. 138*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_decodeImage}) for a text string representing the error 139*38e8c45fSAndroid Build Coastguard Worker * code. 140*38e8c45fSAndroid Build Coastguard Worker * 141*38e8c45fSAndroid Build Coastguard Worker * Errors: 142*38e8c45fSAndroid Build Coastguard Worker * - Returns null for a value out of range. 143*38e8c45fSAndroid Build Coastguard Worker */ 144*38e8c45fSAndroid Build Coastguard Worker const char* _Nullable AImageDecoder_resultToString(int)__INTRODUCED_IN(31); 145*38e8c45fSAndroid Build Coastguard Worker 146*38e8c45fSAndroid Build Coastguard Worker struct AImageDecoder; 147*38e8c45fSAndroid Build Coastguard Worker 148*38e8c45fSAndroid Build Coastguard Worker /** 149*38e8c45fSAndroid Build Coastguard Worker * Opaque handle for decoding images. 150*38e8c45fSAndroid Build Coastguard Worker * 151*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 30 152*38e8c45fSAndroid Build Coastguard Worker * 153*38e8c45fSAndroid Build Coastguard Worker * Create using one of the following: 154*38e8c45fSAndroid Build Coastguard Worker * - {@link AImageDecoder_createFromAAsset} 155*38e8c45fSAndroid Build Coastguard Worker * - {@link AImageDecoder_createFromFd} 156*38e8c45fSAndroid Build Coastguard Worker * - {@link AImageDecoder_createFromBuffer} 157*38e8c45fSAndroid Build Coastguard Worker * 158*38e8c45fSAndroid Build Coastguard Worker * After creation, {@link AImageDecoder_getHeaderInfo} can be used to retrieve 159*38e8c45fSAndroid Build Coastguard Worker * information about the encoded image. Other functions, like 160*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_setTargetSize}, can be used to specify how to decode, and 161*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_decodeImage} will decode into client provided memory. 162*38e8c45fSAndroid Build Coastguard Worker * 163*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} objects are NOT thread-safe, and should not be shared across 164*38e8c45fSAndroid Build Coastguard Worker * threads. 165*38e8c45fSAndroid Build Coastguard Worker */ 166*38e8c45fSAndroid Build Coastguard Worker typedef struct AImageDecoder AImageDecoder; 167*38e8c45fSAndroid Build Coastguard Worker 168*38e8c45fSAndroid Build Coastguard Worker /** 169*38e8c45fSAndroid Build Coastguard Worker * Create a new {@link AImageDecoder} from an {@link AAsset}. 170*38e8c45fSAndroid Build Coastguard Worker * 171*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 172*38e8c45fSAndroid Build Coastguard Worker * 173*38e8c45fSAndroid Build Coastguard Worker * @param asset {@link AAsset} containing encoded image data. Client is still 174*38e8c45fSAndroid Build Coastguard Worker * responsible for calling {@link AAsset_close} on it, which may be 175*38e8c45fSAndroid Build Coastguard Worker * done after deleting the returned {@link AImageDecoder}. 176*38e8c45fSAndroid Build Coastguard Worker * @param outDecoder On success (i.e. return value is 177*38e8c45fSAndroid Build Coastguard Worker * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to 178*38e8c45fSAndroid Build Coastguard Worker * a newly created {@link AImageDecoder}. Caller is 179*38e8c45fSAndroid Build Coastguard Worker * responsible for calling {@link AImageDecoder_delete} on it. 180*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 181*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 182*38e8c45fSAndroid Build Coastguard Worker * 183*38e8c45fSAndroid Build Coastguard Worker * Errors: 184*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The asset was truncated before 185*38e8c45fSAndroid Build Coastguard Worker * reading the image header. 186*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: One of the parameters is 187*38e8c45fSAndroid Build Coastguard Worker * null. 188*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_INPUT}: There is an error in the 189*38e8c45fSAndroid Build Coastguard Worker * header. 190*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The asset failed to seek. 191*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a 192*38e8c45fSAndroid Build Coastguard Worker * failure to allocate memory. 193*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT}: The format is not 194*38e8c45fSAndroid Build Coastguard Worker * supported. 195*38e8c45fSAndroid Build Coastguard Worker */ 196*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_createFromAAsset(struct AAsset* _Nonnull asset, 197*38e8c45fSAndroid Build Coastguard Worker AImageDecoder* _Nullable * _Nonnull outDecoder) 198*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(30); 199*38e8c45fSAndroid Build Coastguard Worker 200*38e8c45fSAndroid Build Coastguard Worker /** 201*38e8c45fSAndroid Build Coastguard Worker * Create a new {@link AImageDecoder} from a file descriptor. 202*38e8c45fSAndroid Build Coastguard Worker * 203*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 204*38e8c45fSAndroid Build Coastguard Worker * 205*38e8c45fSAndroid Build Coastguard Worker * @param fd Seekable, readable, open file descriptor for encoded data. 206*38e8c45fSAndroid Build Coastguard Worker * Client is still responsible for closing it, which may be done 207*38e8c45fSAndroid Build Coastguard Worker * after deleting the returned {@link AImageDecoder}. 208*38e8c45fSAndroid Build Coastguard Worker * @param outDecoder On success (i.e. return value is 209*38e8c45fSAndroid Build Coastguard Worker * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to 210*38e8c45fSAndroid Build Coastguard Worker * a newly created {@link AImageDecoder}. Caller is 211*38e8c45fSAndroid Build Coastguard Worker * responsible for calling {@link AImageDecoder_delete} on it. 212*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 213*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 214*38e8c45fSAndroid Build Coastguard Worker * 215*38e8c45fSAndroid Build Coastguard Worker * Errors: 216*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The file was truncated before 217*38e8c45fSAndroid Build Coastguard Worker * reading the image header. 218*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The {@link AImageDecoder} is 219*38e8c45fSAndroid Build Coastguard Worker * null, or |fd| does not represent a valid, seekable file descriptor. 220*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_INPUT}: There is an error in the 221*38e8c45fSAndroid Build Coastguard Worker * header. 222*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The descriptor failed to seek. 223*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a 224*38e8c45fSAndroid Build Coastguard Worker * failure to allocate memory. 225*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT}: The format is not 226*38e8c45fSAndroid Build Coastguard Worker * supported. 227*38e8c45fSAndroid Build Coastguard Worker */ 228*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_createFromFd(int fd, AImageDecoder* _Nullable * _Nonnull outDecoder) 229*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(30); 230*38e8c45fSAndroid Build Coastguard Worker 231*38e8c45fSAndroid Build Coastguard Worker /** 232*38e8c45fSAndroid Build Coastguard Worker * Create a new AImageDecoder from a buffer. 233*38e8c45fSAndroid Build Coastguard Worker * 234*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 235*38e8c45fSAndroid Build Coastguard Worker * 236*38e8c45fSAndroid Build Coastguard Worker * @param buffer Pointer to encoded data. Must be valid for the entire time 237*38e8c45fSAndroid Build Coastguard Worker * the {@link AImageDecoder} is used. 238*38e8c45fSAndroid Build Coastguard Worker * @param length Byte length of buffer. 239*38e8c45fSAndroid Build Coastguard Worker * @param outDecoder On success (i.e. return value is 240*38e8c45fSAndroid Build Coastguard Worker * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to 241*38e8c45fSAndroid Build Coastguard Worker * a newly created {@link AImageDecoder}. Caller is 242*38e8c45fSAndroid Build Coastguard Worker * responsible for calling {@link AImageDecoder_delete} on it. 243*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 244*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 245*38e8c45fSAndroid Build Coastguard Worker * 246*38e8c45fSAndroid Build Coastguard Worker * Errors: 247*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The encoded image was truncated before 248*38e8c45fSAndroid Build Coastguard Worker * reading the image header. 249*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: One of the parameters is 250*38e8c45fSAndroid Build Coastguard Worker * invalid. 251*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_INPUT}: There is an error in the 252*38e8c45fSAndroid Build Coastguard Worker * header. 253*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a 254*38e8c45fSAndroid Build Coastguard Worker * failure to allocate memory. 255*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT}: The format is not 256*38e8c45fSAndroid Build Coastguard Worker * supported. 257*38e8c45fSAndroid Build Coastguard Worker */ 258*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_createFromBuffer(const void* _Nonnull buffer, size_t length, 259*38e8c45fSAndroid Build Coastguard Worker AImageDecoder* _Nullable * _Nonnull outDecoder) 260*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(30); 261*38e8c45fSAndroid Build Coastguard Worker 262*38e8c45fSAndroid Build Coastguard Worker /** 263*38e8c45fSAndroid Build Coastguard Worker * Delete the AImageDecoder. 264*38e8c45fSAndroid Build Coastguard Worker * @param decoder {@link AImageDecoder} object created with one of AImageDecoder_createFrom... 265*38e8c45fSAndroid Build Coastguard Worker * functions. 266*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 267*38e8c45fSAndroid Build Coastguard Worker */ 268*38e8c45fSAndroid Build Coastguard Worker void AImageDecoder_delete(AImageDecoder* _Nullable decoder) __INTRODUCED_IN(30); 269*38e8c45fSAndroid Build Coastguard Worker 270*38e8c45fSAndroid Build Coastguard Worker /** 271*38e8c45fSAndroid Build Coastguard Worker * Choose the desired output format. 272*38e8c45fSAndroid Build Coastguard Worker * 273*38e8c45fSAndroid Build Coastguard Worker * If the encoded image represents an animation, this must be called while on 274*38e8c45fSAndroid Build Coastguard Worker * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or 275*38e8c45fSAndroid Build Coastguard Worker * after calling {@link AImageDecoder_rewind}). 276*38e8c45fSAndroid Build Coastguard Worker * 277*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 278*38e8c45fSAndroid Build Coastguard Worker * 279*38e8c45fSAndroid Build Coastguard Worker * @param format {@link AndroidBitmapFormat} to use for the output. 280*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 281*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 282*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. On failure, the 283*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} uses the format it was already planning 284*38e8c45fSAndroid Build Coastguard Worker * to use (either its default or a previously successful setting 285*38e8c45fSAndroid Build Coastguard Worker * from this function). 286*38e8c45fSAndroid Build Coastguard Worker * 287*38e8c45fSAndroid Build Coastguard Worker * Errors: 288*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The 289*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} is null or |format| does not correspond to an 290*38e8c45fSAndroid Build Coastguard Worker * {@link AndroidBitmapFormat}. 291*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_CONVERSION}: The 292*38e8c45fSAndroid Build Coastguard Worker * {@link AndroidBitmapFormat} is incompatible with the image. 293*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on 294*38e8c45fSAndroid Build Coastguard Worker * the first frame. 295*38e8c45fSAndroid Build Coastguard Worker */ 296*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_setAndroidBitmapFormat(AImageDecoder* _Nonnull decoder, 297*38e8c45fSAndroid Build Coastguard Worker int32_t format) __INTRODUCED_IN(30); 298*38e8c45fSAndroid Build Coastguard Worker 299*38e8c45fSAndroid Build Coastguard Worker /** 300*38e8c45fSAndroid Build Coastguard Worker * Specify whether the output's pixels should be unpremultiplied. 301*38e8c45fSAndroid Build Coastguard Worker * 302*38e8c45fSAndroid Build Coastguard Worker * By default, {@link AImageDecoder_decodeImage} will premultiply the pixels, if they have alpha. 303*38e8c45fSAndroid Build Coastguard Worker * Pass true to this method to leave them unpremultiplied. This has no effect on an 304*38e8c45fSAndroid Build Coastguard Worker * opaque image. 305*38e8c45fSAndroid Build Coastguard Worker * 306*38e8c45fSAndroid Build Coastguard Worker * If the encoded image represents an animation, this must be called while on 307*38e8c45fSAndroid Build Coastguard Worker * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or 308*38e8c45fSAndroid Build Coastguard Worker * after calling {@link AImageDecoder_rewind}). 309*38e8c45fSAndroid Build Coastguard Worker * 310*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 311*38e8c45fSAndroid Build Coastguard Worker * 312*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 313*38e8c45fSAndroid Build Coastguard Worker * @param unpremultipliedRequired Pass true to leave the pixels unpremultiplied. 314*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 315*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 316*38e8c45fSAndroid Build Coastguard Worker * 317*38e8c45fSAndroid Build Coastguard Worker * Errors: 318*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_CONVERSION}: Unpremultiplied is not 319*38e8c45fSAndroid Build Coastguard Worker * possible due to an existing scale set by 320*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_setTargetSize}. 321*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The 322*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} is null. 323*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on 324*38e8c45fSAndroid Build Coastguard Worker * the first frame. 325*38e8c45fSAndroid Build Coastguard Worker */ 326*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_setUnpremultipliedRequired(AImageDecoder* _Nonnull decoder, 327*38e8c45fSAndroid Build Coastguard Worker bool unpremultipliedRequired) __INTRODUCED_IN(30); 328*38e8c45fSAndroid Build Coastguard Worker 329*38e8c45fSAndroid Build Coastguard Worker /** 330*38e8c45fSAndroid Build Coastguard Worker * Choose the dataspace for the output. 331*38e8c45fSAndroid Build Coastguard Worker * 332*38e8c45fSAndroid Build Coastguard Worker * Ignored by {@link ANDROID_BITMAP_FORMAT_A_8}, which does not support 333*38e8c45fSAndroid Build Coastguard Worker * an {@link ADataSpace}. 334*38e8c45fSAndroid Build Coastguard Worker * 335*38e8c45fSAndroid Build Coastguard Worker * If the encoded image represents an animation, this must be called while on 336*38e8c45fSAndroid Build Coastguard Worker * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or 337*38e8c45fSAndroid Build Coastguard Worker * after calling {@link AImageDecoder_rewind}). 338*38e8c45fSAndroid Build Coastguard Worker * 339*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 340*38e8c45fSAndroid Build Coastguard Worker * 341*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 342*38e8c45fSAndroid Build Coastguard Worker * @param dataspace The {@link ADataSpace} to decode into. An ADataSpace 343*38e8c45fSAndroid Build Coastguard Worker * specifies how to interpret the colors. By default, 344*38e8c45fSAndroid Build Coastguard Worker * AImageDecoder will decode into the ADataSpace specified by 345*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoderHeaderInfo_getDataSpace}. If this 346*38e8c45fSAndroid Build Coastguard Worker * parameter is set to a different ADataSpace, AImageDecoder 347*38e8c45fSAndroid Build Coastguard Worker * will transform the output into the specified ADataSpace. 348*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 349*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 350*38e8c45fSAndroid Build Coastguard Worker * 351*38e8c45fSAndroid Build Coastguard Worker * Errors: 352*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The 353*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} is null or |dataspace| does not correspond to an 354*38e8c45fSAndroid Build Coastguard Worker * {@link ADataSpace} value. 355*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on 356*38e8c45fSAndroid Build Coastguard Worker * the first frame. 357*38e8c45fSAndroid Build Coastguard Worker */ 358*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_setDataSpace(AImageDecoder* _Nonnull decoder, int32_t dataspace) 359*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(30); 360*38e8c45fSAndroid Build Coastguard Worker 361*38e8c45fSAndroid Build Coastguard Worker /** 362*38e8c45fSAndroid Build Coastguard Worker * Specify the output size for a decoded image. 363*38e8c45fSAndroid Build Coastguard Worker * 364*38e8c45fSAndroid Build Coastguard Worker * Future calls to {@link AImageDecoder_decodeImage} will sample or scale the 365*38e8c45fSAndroid Build Coastguard Worker * encoded image to reach the desired size. If a crop rect is set (via 366*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_setCrop}), it must be contained within the dimensions 367*38e8c45fSAndroid Build Coastguard Worker * specified by width and height, and the output image will be the size of the 368*38e8c45fSAndroid Build Coastguard Worker * crop rect. 369*38e8c45fSAndroid Build Coastguard Worker * 370*38e8c45fSAndroid Build Coastguard Worker * If the encoded image represents an animation, this must be called while on 371*38e8c45fSAndroid Build Coastguard Worker * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or 372*38e8c45fSAndroid Build Coastguard Worker * after calling {@link AImageDecoder_rewind}). 373*38e8c45fSAndroid Build Coastguard Worker * 374*38e8c45fSAndroid Build Coastguard Worker * It is strongly recommended to use setTargetSize only for downscaling, as it 375*38e8c45fSAndroid Build Coastguard Worker * is often more efficient to scale-up when rendering than up-front due to 376*38e8c45fSAndroid Build Coastguard Worker * reduced overall memory. 377*38e8c45fSAndroid Build Coastguard Worker * 378*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 379*38e8c45fSAndroid Build Coastguard Worker * 380*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 381*38e8c45fSAndroid Build Coastguard Worker * @param width Width of the output (prior to cropping). 382*38e8c45fSAndroid Build Coastguard Worker * This will affect future calls to 383*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_getMinimumStride}, which will now return 384*38e8c45fSAndroid Build Coastguard Worker * a value based on this width. 385*38e8c45fSAndroid Build Coastguard Worker * @param height Height of the output (prior to cropping). 386*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 387*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 388*38e8c45fSAndroid Build Coastguard Worker * 389*38e8c45fSAndroid Build Coastguard Worker * Errors: 390*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The 391*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} is null. 392*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_SCALE}: |width| or |height| is <= 0, 393*38e8c45fSAndroid Build Coastguard Worker * the size is too big, any existing crop is not contained by the new image 394*38e8c45fSAndroid Build Coastguard Worker * dimensions, or the scale is incompatible with a previous call to 395*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_setUnpremultipliedRequired}(true). 396*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on 397*38e8c45fSAndroid Build Coastguard Worker * the first frame. 398*38e8c45fSAndroid Build Coastguard Worker */ 399*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_setTargetSize(AImageDecoder* _Nonnull decoder, int32_t width, 400*38e8c45fSAndroid Build Coastguard Worker int32_t height) __INTRODUCED_IN(30); 401*38e8c45fSAndroid Build Coastguard Worker 402*38e8c45fSAndroid Build Coastguard Worker /** 403*38e8c45fSAndroid Build Coastguard Worker * Compute the dimensions to use for a given sampleSize. 404*38e8c45fSAndroid Build Coastguard Worker * 405*38e8c45fSAndroid Build Coastguard Worker * Although AImageDecoder can scale to an arbitrary target size (see 406*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_setTargetSize}), some sizes may be more efficient than 407*38e8c45fSAndroid Build Coastguard Worker * others. This computes the most efficient target size to use to reach a 408*38e8c45fSAndroid Build Coastguard Worker * particular sampleSize. 409*38e8c45fSAndroid Build Coastguard Worker * 410*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 411*38e8c45fSAndroid Build Coastguard Worker * 412*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 413*38e8c45fSAndroid Build Coastguard Worker * @param sampleSize A subsampling rate of the original image. Must be greater 414*38e8c45fSAndroid Build Coastguard Worker * than or equal to 1. A sampleSize of 2 means to skip every 415*38e8c45fSAndroid Build Coastguard Worker * other pixel/line, resulting in a width and height that are 416*38e8c45fSAndroid Build Coastguard Worker * 1/2 of the original dimensions, with 1/4 the number of 417*38e8c45fSAndroid Build Coastguard Worker * pixels. 418*38e8c45fSAndroid Build Coastguard Worker * @param width Out parameter for the width sampled by sampleSize, and rounded 419*38e8c45fSAndroid Build Coastguard Worker * in the direction that the decoder can do most efficiently. 420*38e8c45fSAndroid Build Coastguard Worker * @param height Out parameter for the height sampled by sampleSize, and rounded 421*38e8c45fSAndroid Build Coastguard Worker * in the direction that the decoder can do most efficiently. 422*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 423*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 424*38e8c45fSAndroid Build Coastguard Worker * 425*38e8c45fSAndroid Build Coastguard Worker * Errors: 426*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The 427*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder}, |width| or |height| is null or |sampleSize| is < 1. 428*38e8c45fSAndroid Build Coastguard Worker */ 429*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_computeSampledSize(const AImageDecoder* _Nonnull decoder, int sampleSize, 430*38e8c45fSAndroid Build Coastguard Worker int32_t* _Nonnull width, int32_t* _Nonnull height) 431*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(30); 432*38e8c45fSAndroid Build Coastguard Worker 433*38e8c45fSAndroid Build Coastguard Worker /** 434*38e8c45fSAndroid Build Coastguard Worker * Specify how to crop the output after scaling (if any). 435*38e8c45fSAndroid Build Coastguard Worker * 436*38e8c45fSAndroid Build Coastguard Worker * Future calls to {@link AImageDecoder_decodeImage} will crop their output to 437*38e8c45fSAndroid Build Coastguard Worker * the specified {@link ARect}. Clients will only need to allocate enough memory 438*38e8c45fSAndroid Build Coastguard Worker * for the cropped ARect. 439*38e8c45fSAndroid Build Coastguard Worker * 440*38e8c45fSAndroid Build Coastguard Worker * If the encoded image represents an animation, this must be called while on 441*38e8c45fSAndroid Build Coastguard Worker * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or 442*38e8c45fSAndroid Build Coastguard Worker * after calling {@link AImageDecoder_rewind}). 443*38e8c45fSAndroid Build Coastguard Worker * 444*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 445*38e8c45fSAndroid Build Coastguard Worker * 446*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 447*38e8c45fSAndroid Build Coastguard Worker * @param crop Rectangle describing a crop of the decode. It must be contained inside of 448*38e8c45fSAndroid Build Coastguard Worker * the (possibly scaled, by {@link AImageDecoder_setTargetSize}) 449*38e8c45fSAndroid Build Coastguard Worker * image dimensions. This will affect future calls to 450*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_getMinimumStride}, which will now return a 451*38e8c45fSAndroid Build Coastguard Worker * value based on the width of the crop. An empty ARect - 452*38e8c45fSAndroid Build Coastguard Worker * specifically { 0, 0, 0, 0 } - may be used to remove the cropping 453*38e8c45fSAndroid Build Coastguard Worker * behavior. Any other empty or unsorted ARects will result in 454*38e8c45fSAndroid Build Coastguard Worker * returning {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}. 455*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 456*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 457*38e8c45fSAndroid Build Coastguard Worker * 458*38e8c45fSAndroid Build Coastguard Worker * Errors: 459*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The 460*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder} is null, or the crop is not contained by the 461*38e8c45fSAndroid Build Coastguard Worker * (possibly scaled) image dimensions. 462*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on 463*38e8c45fSAndroid Build Coastguard Worker * the first frame. 464*38e8c45fSAndroid Build Coastguard Worker */ 465*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_setCrop(AImageDecoder* _Nonnull decoder, ARect crop) __INTRODUCED_IN(30); 466*38e8c45fSAndroid Build Coastguard Worker 467*38e8c45fSAndroid Build Coastguard Worker struct AImageDecoderHeaderInfo; 468*38e8c45fSAndroid Build Coastguard Worker /** 469*38e8c45fSAndroid Build Coastguard Worker * Opaque handle for representing information about the encoded image. 470*38e8c45fSAndroid Build Coastguard Worker * 471*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 30 472*38e8c45fSAndroid Build Coastguard Worker * 473*38e8c45fSAndroid Build Coastguard Worker * Retrieved using {@link AImageDecoder_getHeaderInfo} and passed to methods 474*38e8c45fSAndroid Build Coastguard Worker * like {@link AImageDecoderHeaderInfo_getWidth} and 475*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoderHeaderInfo_getHeight}. 476*38e8c45fSAndroid Build Coastguard Worker */ 477*38e8c45fSAndroid Build Coastguard Worker typedef struct AImageDecoderHeaderInfo AImageDecoderHeaderInfo; 478*38e8c45fSAndroid Build Coastguard Worker 479*38e8c45fSAndroid Build Coastguard Worker /** 480*38e8c45fSAndroid Build Coastguard Worker * Return an opaque handle for reading header info. 481*38e8c45fSAndroid Build Coastguard Worker * 482*38e8c45fSAndroid Build Coastguard Worker * This is owned by the {@link AImageDecoder} and will be destroyed when the 483*38e8c45fSAndroid Build Coastguard Worker * AImageDecoder is destroyed via {@link AImageDecoder_delete}. 484*38e8c45fSAndroid Build Coastguard Worker * 485*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 486*38e8c45fSAndroid Build Coastguard Worker * 487*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 488*38e8c45fSAndroid Build Coastguard Worker */ 489*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderHeaderInfo* _Nonnull AImageDecoder_getHeaderInfo( 490*38e8c45fSAndroid Build Coastguard Worker const AImageDecoder* _Nonnull decoder) __INTRODUCED_IN(30); 491*38e8c45fSAndroid Build Coastguard Worker 492*38e8c45fSAndroid Build Coastguard Worker /** 493*38e8c45fSAndroid Build Coastguard Worker * Report the native width of the encoded image. This is also the logical 494*38e8c45fSAndroid Build Coastguard Worker * pixel width of the output, unless {@link AImageDecoder_setTargetSize} is 495*38e8c45fSAndroid Build Coastguard Worker * used to choose a different size or {@link AImageDecoder_setCrop} is used to 496*38e8c45fSAndroid Build Coastguard Worker * set a crop rect. 497*38e8c45fSAndroid Build Coastguard Worker * 498*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 499*38e8c45fSAndroid Build Coastguard Worker */ 500*38e8c45fSAndroid Build Coastguard Worker int32_t AImageDecoderHeaderInfo_getWidth(const AImageDecoderHeaderInfo* _Nonnull) 501*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(30); 502*38e8c45fSAndroid Build Coastguard Worker 503*38e8c45fSAndroid Build Coastguard Worker /** 504*38e8c45fSAndroid Build Coastguard Worker * Report the native height of the encoded image. This is also the logical 505*38e8c45fSAndroid Build Coastguard Worker * pixel height of the output, unless {@link AImageDecoder_setTargetSize} is 506*38e8c45fSAndroid Build Coastguard Worker * used to choose a different size or {@link AImageDecoder_setCrop} is used to 507*38e8c45fSAndroid Build Coastguard Worker * set a crop rect. 508*38e8c45fSAndroid Build Coastguard Worker * 509*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 510*38e8c45fSAndroid Build Coastguard Worker */ 511*38e8c45fSAndroid Build Coastguard Worker int32_t AImageDecoderHeaderInfo_getHeight(const AImageDecoderHeaderInfo* _Nonnull) 512*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(30); 513*38e8c45fSAndroid Build Coastguard Worker 514*38e8c45fSAndroid Build Coastguard Worker /** 515*38e8c45fSAndroid Build Coastguard Worker * Report the mimeType of the encoded image. 516*38e8c45fSAndroid Build Coastguard Worker * 517*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 518*38e8c45fSAndroid Build Coastguard Worker * 519*38e8c45fSAndroid Build Coastguard Worker * @return a string literal describing the mime type. 520*38e8c45fSAndroid Build Coastguard Worker */ 521*38e8c45fSAndroid Build Coastguard Worker const char* _Nonnull AImageDecoderHeaderInfo_getMimeType( 522*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30); 523*38e8c45fSAndroid Build Coastguard Worker 524*38e8c45fSAndroid Build Coastguard Worker /** 525*38e8c45fSAndroid Build Coastguard Worker * Report the {@link AndroidBitmapFormat} the AImageDecoder will decode to 526*38e8c45fSAndroid Build Coastguard Worker * by default. {@link AImageDecoder} will try to choose one that is sensible 527*38e8c45fSAndroid Build Coastguard Worker * for the image and the system. Note that this does not indicate the 528*38e8c45fSAndroid Build Coastguard Worker * encoded format of the image. 529*38e8c45fSAndroid Build Coastguard Worker * 530*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 531*38e8c45fSAndroid Build Coastguard Worker */ 532*38e8c45fSAndroid Build Coastguard Worker int32_t AImageDecoderHeaderInfo_getAndroidBitmapFormat( 533*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30); 534*38e8c45fSAndroid Build Coastguard Worker 535*38e8c45fSAndroid Build Coastguard Worker /** 536*38e8c45fSAndroid Build Coastguard Worker * Report how the {@link AImageDecoder} will handle alpha by default. If the image 537*38e8c45fSAndroid Build Coastguard Worker * contains no alpha (according to its header), this will return 538*38e8c45fSAndroid Build Coastguard Worker * {@link ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE}. If the image may contain alpha, 539*38e8c45fSAndroid Build Coastguard Worker * this returns {@link ANDROID_BITMAP_FLAGS_ALPHA_PREMUL}, because 540*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_decodeImage} will premultiply pixels by default. 541*38e8c45fSAndroid Build Coastguard Worker * 542*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 543*38e8c45fSAndroid Build Coastguard Worker * 544*38e8c45fSAndroid Build Coastguard Worker * Starting in API level 31, an AImageDecoder may contain multiple frames of an 545*38e8c45fSAndroid Build Coastguard Worker * animation, but this method still only reports whether the first frame has 546*38e8c45fSAndroid Build Coastguard Worker * alpha. 547*38e8c45fSAndroid Build Coastguard Worker */ 548*38e8c45fSAndroid Build Coastguard Worker int AImageDecoderHeaderInfo_getAlphaFlags( 549*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30); 550*38e8c45fSAndroid Build Coastguard Worker 551*38e8c45fSAndroid Build Coastguard Worker /** 552*38e8c45fSAndroid Build Coastguard Worker * Report the dataspace the AImageDecoder will decode to by default. 553*38e8c45fSAndroid Build Coastguard Worker * 554*38e8c45fSAndroid Build Coastguard Worker * By default, {@link AImageDecoder_decodeImage} will not do any color 555*38e8c45fSAndroid Build Coastguard Worker * conversion. 556*38e8c45fSAndroid Build Coastguard Worker * 557*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 558*38e8c45fSAndroid Build Coastguard Worker * 559*38e8c45fSAndroid Build Coastguard Worker * @return The {@link ADataSpace} representing the way the colors 560*38e8c45fSAndroid Build Coastguard Worker * are encoded (or {@link ADATASPACE_UNKNOWN} if there is not a 561*38e8c45fSAndroid Build Coastguard Worker * corresponding ADataSpace). This specifies how to interpret the colors 562*38e8c45fSAndroid Build Coastguard Worker * in the decoded image, unless {@link AImageDecoder_setDataSpace} is 563*38e8c45fSAndroid Build Coastguard Worker * called to decode to a different ADataSpace. 564*38e8c45fSAndroid Build Coastguard Worker * 565*38e8c45fSAndroid Build Coastguard Worker * Note that ADataSpace only exposes a few values. This may return 566*38e8c45fSAndroid Build Coastguard Worker * {@link ADATASPACE_UNKNOWN}, even for Named ColorSpaces, if they have 567*38e8c45fSAndroid Build Coastguard Worker * no corresponding {@link ADataSpace}. 568*38e8c45fSAndroid Build Coastguard Worker */ 569*38e8c45fSAndroid Build Coastguard Worker int32_t AImageDecoderHeaderInfo_getDataSpace( 570*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30); 571*38e8c45fSAndroid Build Coastguard Worker 572*38e8c45fSAndroid Build Coastguard Worker /** 573*38e8c45fSAndroid Build Coastguard Worker * Return the minimum stride that can be used in 574*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_decodeImage}. 575*38e8c45fSAndroid Build Coastguard Worker * 576*38e8c45fSAndroid Build Coastguard Worker * This stride provides no padding, meaning it will be exactly equal to the 577*38e8c45fSAndroid Build Coastguard Worker * width times the number of bytes per pixel for the {@link AndroidBitmapFormat} 578*38e8c45fSAndroid Build Coastguard Worker * being used. 579*38e8c45fSAndroid Build Coastguard Worker * 580*38e8c45fSAndroid Build Coastguard Worker * If the output is scaled (via {@link AImageDecoder_setTargetSize}) and/or 581*38e8c45fSAndroid Build Coastguard Worker * cropped (via {@link AImageDecoder_setCrop}), this takes those into account. 582*38e8c45fSAndroid Build Coastguard Worker * 583*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 584*38e8c45fSAndroid Build Coastguard Worker * 585*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 586*38e8c45fSAndroid Build Coastguard Worker */ 587*38e8c45fSAndroid Build Coastguard Worker size_t AImageDecoder_getMinimumStride(AImageDecoder* _Nonnull decoder) __INTRODUCED_IN(30); 588*38e8c45fSAndroid Build Coastguard Worker 589*38e8c45fSAndroid Build Coastguard Worker /** 590*38e8c45fSAndroid Build Coastguard Worker * Decode the image into pixels, using the settings of the {@link AImageDecoder}. 591*38e8c45fSAndroid Build Coastguard Worker * 592*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 593*38e8c45fSAndroid Build Coastguard Worker * 594*38e8c45fSAndroid Build Coastguard Worker * Starting in API level 31, it can be used to decode all of the frames of an 595*38e8c45fSAndroid Build Coastguard Worker * animated image (i.e. GIF, WebP) using new APIs. Internally, 596*38e8c45fSAndroid Build Coastguard Worker * AImageDecoder keeps track of its "current frame" - that is, the frame that 597*38e8c45fSAndroid Build Coastguard Worker * will be decoded by a call to AImageDecoder_decodeImage. At creation time, the 598*38e8c45fSAndroid Build Coastguard Worker * current frame is always the first frame, and multiple calls to this method 599*38e8c45fSAndroid Build Coastguard Worker * will each decode the first frame. {@link AImageDecoder_advanceFrame} advances 600*38e8c45fSAndroid Build Coastguard Worker * the current frame to the following frame, so that future calls to this method 601*38e8c45fSAndroid Build Coastguard Worker * will decode that frame. Some frames may update only part of the image. They 602*38e8c45fSAndroid Build Coastguard Worker * may only update a sub-rectangle (see {@link 603*38e8c45fSAndroid Build Coastguard Worker * AImageDecoderFrameInfo_getFrameRect}), or they may have alpha (see 604*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoderFrameInfo_hasAlphaWithinBounds}). In these cases, this 605*38e8c45fSAndroid Build Coastguard Worker * method assumes that the prior frame is still residing in the |pixels| buffer, 606*38e8c45fSAndroid Build Coastguard Worker * decodes only the new portion, and blends it with the buffer. Frames that change 607*38e8c45fSAndroid Build Coastguard Worker * the entire |pixels| buffer are "independent", and do not require the prior 608*38e8c45fSAndroid Build Coastguard Worker * frame to remain in the buffer. The first frame is always independent. A 609*38e8c45fSAndroid Build Coastguard Worker * sophisticated client can use information from the {@link AImageDecoderFrameInfo} 610*38e8c45fSAndroid Build Coastguard Worker * to determine whether other frames are independent, or what frames they rely on. 611*38e8c45fSAndroid Build Coastguard Worker * 612*38e8c45fSAndroid Build Coastguard Worker * If the current frame is marked {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS}, 613*38e8c45fSAndroid Build Coastguard Worker * AImageDecoder_decodeImage will store the |pixels| buffer prior to decoding 614*38e8c45fSAndroid Build Coastguard Worker * (note: this only happens for the first in a string of consecutive 615*38e8c45fSAndroid Build Coastguard Worker * ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS frames). After advancing to the 616*38e8c45fSAndroid Build Coastguard Worker * following frame, AImageDecoder_decodeImage will restore that buffer prior to 617*38e8c45fSAndroid Build Coastguard Worker * decoding that frame. This is the default behavior, but it can be disabled 618*38e8c45fSAndroid Build Coastguard Worker * by passing false to {@link AImageDecoder_setInternallyHandleDisposePrevious}. 619*38e8c45fSAndroid Build Coastguard Worker * 620*38e8c45fSAndroid Build Coastguard Worker * Ignoring timing information, display, etc, a client wishing to decode all 621*38e8c45fSAndroid Build Coastguard Worker * frames of an animated image may conceptually use code like the following: 622*38e8c45fSAndroid Build Coastguard Worker * 623*38e8c45fSAndroid Build Coastguard Worker * while (true) { 624*38e8c45fSAndroid Build Coastguard Worker * int result = AImageDecoder_decodeImage(decoder, pixels, stride, size); 625*38e8c45fSAndroid Build Coastguard Worker * if (result != ANDROID_IMAGE_DECODER_SUCCESS) break; 626*38e8c45fSAndroid Build Coastguard Worker * 627*38e8c45fSAndroid Build Coastguard Worker * // Display or save the image in |pixels|, keeping the buffer intact for 628*38e8c45fSAndroid Build Coastguard Worker * // AImageDecoder to decode the next frame correctly. 629*38e8c45fSAndroid Build Coastguard Worker * Application_viewImage(pixels); 630*38e8c45fSAndroid Build Coastguard Worker * 631*38e8c45fSAndroid Build Coastguard Worker * result = AImageDecoder_advanceFrame(decoder); 632*38e8c45fSAndroid Build Coastguard Worker * if (result != ANDROID_IMAGE_DECODER_SUCCESS) break; 633*38e8c45fSAndroid Build Coastguard Worker * } 634*38e8c45fSAndroid Build Coastguard Worker * 635*38e8c45fSAndroid Build Coastguard Worker * @param decoder Opaque object representing the decoder. 636*38e8c45fSAndroid Build Coastguard Worker * @param pixels On success, will be filled with the result 637*38e8c45fSAndroid Build Coastguard Worker * of the decode. Must be large enough to hold |size| bytes. 638*38e8c45fSAndroid Build Coastguard Worker * @param stride Width in bytes of a single row. Must be at least 639*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_getMinimumStride} and a multiple of the 640*38e8c45fSAndroid Build Coastguard Worker * bytes per pixel of the {@link AndroidBitmapFormat}. 641*38e8c45fSAndroid Build Coastguard Worker * @param size Size of the pixel buffer in bytes. Must be at least 642*38e8c45fSAndroid Build Coastguard Worker * stride * (height - 1) + 643*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_getMinimumStride}. 644*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 645*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 646*38e8c45fSAndroid Build Coastguard Worker * 647*38e8c45fSAndroid Build Coastguard Worker * Errors: 648*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The image was truncated. A 649*38e8c45fSAndroid Build Coastguard Worker * partial image was decoded, and undecoded lines have been initialized to all 650*38e8c45fSAndroid Build Coastguard Worker * zeroes. 651*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_ERROR}: The image contained an error. A 652*38e8c45fSAndroid Build Coastguard Worker * partial image was decoded, and undecoded lines have been initialized to all 653*38e8c45fSAndroid Build Coastguard Worker * zeroes. 654*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The {@link AImageDecoder} or 655*38e8c45fSAndroid Build Coastguard Worker * |pixels| is null, the stride is not large enough or not pixel aligned, or 656*38e8c45fSAndroid Build Coastguard Worker * |size| is not large enough. 657*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The asset or file descriptor 658*38e8c45fSAndroid Build Coastguard Worker * failed to seek. 659*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a 660*38e8c45fSAndroid Build Coastguard Worker * failure to allocate memory. 661*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_FINISHED}: The input contains no 662*38e8c45fSAndroid Build Coastguard Worker * more frames. No decoding occurred. The client must call 663*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_rewind} before calling 664*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_decodeImage} again. 665*38e8c45fSAndroid Build Coastguard Worker */ 666*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_decodeImage(AImageDecoder* _Nonnull decoder, 667*38e8c45fSAndroid Build Coastguard Worker void* _Nonnull pixels, size_t stride, 668*38e8c45fSAndroid Build Coastguard Worker size_t size) __INTRODUCED_IN(30); 669*38e8c45fSAndroid Build Coastguard Worker 670*38e8c45fSAndroid Build Coastguard Worker /** 671*38e8c45fSAndroid Build Coastguard Worker * Return true iff the image is animated - i.e. has multiple frames. 672*38e8c45fSAndroid Build Coastguard Worker * 673*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 674*38e8c45fSAndroid Build Coastguard Worker * 675*38e8c45fSAndroid Build Coastguard Worker * A single frame GIF is considered to *not* be animated. This may require 676*38e8c45fSAndroid Build Coastguard Worker * seeking past the first frame to verify whether there is a following frame. 677*38e8c45fSAndroid Build Coastguard Worker * 678*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 679*38e8c45fSAndroid Build Coastguard Worker * 680*38e8c45fSAndroid Build Coastguard Worker * Errors: 681*38e8c45fSAndroid Build Coastguard Worker * - returns false if |decoder| is null. 682*38e8c45fSAndroid Build Coastguard Worker */ 683*38e8c45fSAndroid Build Coastguard Worker bool AImageDecoder_isAnimated(AImageDecoder* _Nonnull decoder) 684*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 685*38e8c45fSAndroid Build Coastguard Worker 686*38e8c45fSAndroid Build Coastguard Worker enum { 687*38e8c45fSAndroid Build Coastguard Worker /** 688*38e8c45fSAndroid Build Coastguard Worker * Reported by {@link AImageDecoder_getRepeatCount} if the 689*38e8c45fSAndroid Build Coastguard Worker * animation should repeat forever. 690*38e8c45fSAndroid Build Coastguard Worker * 691*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31 692*38e8c45fSAndroid Build Coastguard Worker */ 693*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_INFINITE = INT32_MAX, 694*38e8c45fSAndroid Build Coastguard Worker }; 695*38e8c45fSAndroid Build Coastguard Worker 696*38e8c45fSAndroid Build Coastguard Worker /** 697*38e8c45fSAndroid Build Coastguard Worker * Report how many times the animation should repeat. 698*38e8c45fSAndroid Build Coastguard Worker * 699*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 700*38e8c45fSAndroid Build Coastguard Worker * 701*38e8c45fSAndroid Build Coastguard Worker * This does not include the first play through. e.g. a repeat 702*38e8c45fSAndroid Build Coastguard Worker * count of 4 means that each frame is played 5 times. 703*38e8c45fSAndroid Build Coastguard Worker * 704*38e8c45fSAndroid Build Coastguard Worker * {@link ANDROID_IMAGE_DECODER_INFINITE} means to repeat forever. 705*38e8c45fSAndroid Build Coastguard Worker * 706*38e8c45fSAndroid Build Coastguard Worker * This may require seeking. 707*38e8c45fSAndroid Build Coastguard Worker * 708*38e8c45fSAndroid Build Coastguard Worker * For non-animated formats, this returns 0. It may return non-zero for 709*38e8c45fSAndroid Build Coastguard Worker * an image with only one frame (i.e. {@link AImageDecoder_isAnimated} returns 710*38e8c45fSAndroid Build Coastguard Worker * false) if the encoded image contains a repeat count. 711*38e8c45fSAndroid Build Coastguard Worker * 712*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 713*38e8c45fSAndroid Build Coastguard Worker * @return Number of times to repeat on success or a value 714*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 715*38e8c45fSAndroid Build Coastguard Worker * 716*38e8c45fSAndroid Build Coastguard Worker * Errors: 717*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder 718*38e8c45fSAndroid Build Coastguard Worker * is null. 719*38e8c45fSAndroid Build Coastguard Worker */ 720*38e8c45fSAndroid Build Coastguard Worker int32_t AImageDecoder_getRepeatCount(AImageDecoder* _Nonnull decoder) 721*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 722*38e8c45fSAndroid Build Coastguard Worker 723*38e8c45fSAndroid Build Coastguard Worker /** 724*38e8c45fSAndroid Build Coastguard Worker * Advance to the next frame in the animation. 725*38e8c45fSAndroid Build Coastguard Worker * 726*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 727*38e8c45fSAndroid Build Coastguard Worker * 728*38e8c45fSAndroid Build Coastguard Worker * The AImageDecoder keeps track internally which frame it is ready to decode 729*38e8c45fSAndroid Build Coastguard Worker * (the "current frame"). Initially it is set to decode the first frame, and 730*38e8c45fSAndroid Build Coastguard Worker * each call to {@link AImageDecoder_decodeImage} will continue to decode 731*38e8c45fSAndroid Build Coastguard Worker * the same frame until this method (or {@link AImageDecoder_rewind}) 732*38e8c45fSAndroid Build Coastguard Worker * is called. 733*38e8c45fSAndroid Build Coastguard Worker * 734*38e8c45fSAndroid Build Coastguard Worker * Note that this can be used to skip a frame without decoding it. But 735*38e8c45fSAndroid Build Coastguard Worker * some frames depend on (i.e. blend with) prior frames, and 736*38e8c45fSAndroid Build Coastguard Worker * AImageDecoder_decodeImage assumes that the prior frame is in the 737*38e8c45fSAndroid Build Coastguard Worker * |pixels| buffer. In addition, AImageDecoder_decodeImage handles caching and 738*38e8c45fSAndroid Build Coastguard Worker * restoring frames (see {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS}), so 739*38e8c45fSAndroid Build Coastguard Worker * skipping frames in an image with such frames may not produce the correct 740*38e8c45fSAndroid Build Coastguard Worker * results. 741*38e8c45fSAndroid Build Coastguard Worker * 742*38e8c45fSAndroid Build Coastguard Worker * Only supported by {@link ANDROID_BITMAP_FORMAT_RGBA_8888} and 743*38e8c45fSAndroid Build Coastguard Worker * {@link ANDROID_BITMAP_FORMAT_RGBA_F16}. 744*38e8c45fSAndroid Build Coastguard Worker * 745*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 746*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 747*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 748*38e8c45fSAndroid Build Coastguard Worker * 749*38e8c45fSAndroid Build Coastguard Worker * Errors: 750*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder 751*38e8c45fSAndroid Build Coastguard Worker * represents an image that is not animated (see 752*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_isAnimated}) or the AImageDecoder is null. 753*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE): The requested 754*38e8c45fSAndroid Build Coastguard Worker * {@link AndroidBitmapFormat} does not support animation. 755*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The input appears 756*38e8c45fSAndroid Build Coastguard Worker * to be truncated. The client must call {@link AImageDecoder_rewind} 757*38e8c45fSAndroid Build Coastguard Worker * before calling {@link AImageDecoder_decodeImage} again. 758*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_ERROR}: The input contains an error. 759*38e8c45fSAndroid Build Coastguard Worker * The client must call {@link AImageDecoder_rewind} before 760*38e8c45fSAndroid Build Coastguard Worker * calling {@link AImageDecoder_decodeImage} again. 761*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_FINISHED}: The input contains no 762*38e8c45fSAndroid Build Coastguard Worker * more frames. The client must call {@link AImageDecoder_rewind} 763*38e8c45fSAndroid Build Coastguard Worker * before calling {@link AImageDecoder_decodeImage} again. 764*38e8c45fSAndroid Build Coastguard Worker */ 765*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_advanceFrame(AImageDecoder* _Nonnull decoder) 766*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 767*38e8c45fSAndroid Build Coastguard Worker 768*38e8c45fSAndroid Build Coastguard Worker /** 769*38e8c45fSAndroid Build Coastguard Worker * Return to the beginning of the animation. 770*38e8c45fSAndroid Build Coastguard Worker * 771*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 772*38e8c45fSAndroid Build Coastguard Worker * 773*38e8c45fSAndroid Build Coastguard Worker * After this call, the AImageDecoder will be ready to decode the 774*38e8c45fSAndroid Build Coastguard Worker * first frame of the animation. This can be called after reaching 775*38e8c45fSAndroid Build Coastguard Worker * the end of the animation or an error or in the middle of the 776*38e8c45fSAndroid Build Coastguard Worker * animation. 777*38e8c45fSAndroid Build Coastguard Worker * 778*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 779*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 780*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 781*38e8c45fSAndroid Build Coastguard Worker * 782*38e8c45fSAndroid Build Coastguard Worker * Errors: 783*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder 784*38e8c45fSAndroid Build Coastguard Worker * represents an image that is not animated (see 785*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_isAnimated}) or the AImageDecoder is 786*38e8c45fSAndroid Build Coastguard Worker * null. 787*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The asset or file 788*38e8c45fSAndroid Build Coastguard Worker * descriptor failed to seek. 789*38e8c45fSAndroid Build Coastguard Worker */ 790*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_rewind(AImageDecoder* _Nonnull decoder) 791*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 792*38e8c45fSAndroid Build Coastguard Worker 793*38e8c45fSAndroid Build Coastguard Worker struct AImageDecoderFrameInfo; 794*38e8c45fSAndroid Build Coastguard Worker 795*38e8c45fSAndroid Build Coastguard Worker /** 796*38e8c45fSAndroid Build Coastguard Worker * Opaque handle to animation information about a single frame. 797*38e8c45fSAndroid Build Coastguard Worker * 798*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31 799*38e8c45fSAndroid Build Coastguard Worker * 800*38e8c45fSAndroid Build Coastguard Worker * The duration (retrieved with {@link AImageDecoderFrameInfo_getDuration}) is 801*38e8c45fSAndroid Build Coastguard Worker * necessary for clients to display the animation at the proper speed. The other 802*38e8c45fSAndroid Build Coastguard Worker * information is helpful for a client that wants to determine what frames are 803*38e8c45fSAndroid Build Coastguard Worker * independent (or what frames they depend on), but is unnecessary for 804*38e8c45fSAndroid Build Coastguard Worker * a simple client that wants to sequentially display all frames. 805*38e8c45fSAndroid Build Coastguard Worker */ 806*38e8c45fSAndroid Build Coastguard Worker typedef struct AImageDecoderFrameInfo AImageDecoderFrameInfo; 807*38e8c45fSAndroid Build Coastguard Worker 808*38e8c45fSAndroid Build Coastguard Worker /** 809*38e8c45fSAndroid Build Coastguard Worker * Create an uninitialized AImageDecoderFrameInfo. 810*38e8c45fSAndroid Build Coastguard Worker * 811*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 812*38e8c45fSAndroid Build Coastguard Worker * 813*38e8c45fSAndroid Build Coastguard Worker * This can be passed to {@link AImageDecoder_getFrameInfo} to fill 814*38e8c45fSAndroid Build Coastguard Worker * in information about the current frame. It may be reused. 815*38e8c45fSAndroid Build Coastguard Worker * 816*38e8c45fSAndroid Build Coastguard Worker * Must be deleted with {@link AImageDecoderFrameInfo_delete}. 817*38e8c45fSAndroid Build Coastguard Worker */ 818*38e8c45fSAndroid Build Coastguard Worker AImageDecoderFrameInfo* _Nullable AImageDecoderFrameInfo_create() 819*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 820*38e8c45fSAndroid Build Coastguard Worker 821*38e8c45fSAndroid Build Coastguard Worker /** 822*38e8c45fSAndroid Build Coastguard Worker * Delete an AImageDecoderFrameInfo. 823*38e8c45fSAndroid Build Coastguard Worker * 824*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 825*38e8c45fSAndroid Build Coastguard Worker */ 826*38e8c45fSAndroid Build Coastguard Worker void AImageDecoderFrameInfo_delete( 827*38e8c45fSAndroid Build Coastguard Worker AImageDecoderFrameInfo* _Nullable info) __INTRODUCED_IN(31); 828*38e8c45fSAndroid Build Coastguard Worker 829*38e8c45fSAndroid Build Coastguard Worker /** 830*38e8c45fSAndroid Build Coastguard Worker * Fill |info| with information about the current frame. 831*38e8c45fSAndroid Build Coastguard Worker * 832*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 833*38e8c45fSAndroid Build Coastguard Worker * 834*38e8c45fSAndroid Build Coastguard Worker * Initially, this will return information about the first frame. 835*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_advanceFrame} and 836*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_rewind} can be used to change which frame 837*38e8c45fSAndroid Build Coastguard Worker * is the current frame. 838*38e8c45fSAndroid Build Coastguard Worker * 839*38e8c45fSAndroid Build Coastguard Worker * If the image only has one frame, this will fill the {@link 840*38e8c45fSAndroid Build Coastguard Worker * AImageDecoderFrameInfo} with the encoded info and reasonable 841*38e8c45fSAndroid Build Coastguard Worker * defaults. 842*38e8c45fSAndroid Build Coastguard Worker * 843*38e8c45fSAndroid Build Coastguard Worker * If {@link AImageDecoder_advanceFrame} succeeded, this will succeed as well. 844*38e8c45fSAndroid Build Coastguard Worker * 845*38e8c45fSAndroid Build Coastguard Worker * @param decoder Opaque object representing the decoder. 846*38e8c45fSAndroid Build Coastguard Worker * @param info Opaque object to hold frame information. On success, will be 847*38e8c45fSAndroid Build Coastguard Worker * filled with information regarding the current frame. 848*38e8c45fSAndroid Build Coastguard Worker * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value 849*38e8c45fSAndroid Build Coastguard Worker * indicating the reason for the failure. 850*38e8c45fSAndroid Build Coastguard Worker * 851*38e8c45fSAndroid Build Coastguard Worker * Errors: 852*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: One of the parameters is null. 853*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_FINISHED}: The input contains no 854*38e8c45fSAndroid Build Coastguard Worker * more frames. The client must call {@link AImageDecoder_rewind} to reset the 855*38e8c45fSAndroid Build Coastguard Worker * current frame to a valid frame (0). 856*38e8c45fSAndroid Build Coastguard Worker */ 857*38e8c45fSAndroid Build Coastguard Worker int AImageDecoder_getFrameInfo(AImageDecoder* _Nonnull decoder, 858*38e8c45fSAndroid Build Coastguard Worker AImageDecoderFrameInfo* _Nonnull info) __INTRODUCED_IN(31); 859*38e8c45fSAndroid Build Coastguard Worker 860*38e8c45fSAndroid Build Coastguard Worker /** 861*38e8c45fSAndroid Build Coastguard Worker * Report the number of nanoseconds to show the current frame. 862*38e8c45fSAndroid Build Coastguard Worker * 863*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 864*38e8c45fSAndroid Build Coastguard Worker * 865*38e8c45fSAndroid Build Coastguard Worker * Errors: 866*38e8c45fSAndroid Build Coastguard Worker * - returns {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if |info| is null. 867*38e8c45fSAndroid Build Coastguard Worker */ 868*38e8c45fSAndroid Build Coastguard Worker int64_t AImageDecoderFrameInfo_getDuration( 869*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderFrameInfo* _Nonnull info) __INTRODUCED_IN(31); 870*38e8c45fSAndroid Build Coastguard Worker 871*38e8c45fSAndroid Build Coastguard Worker /** 872*38e8c45fSAndroid Build Coastguard Worker * The rectangle of the image (within 0, 0, 873*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoderHeaderInfo_getWidth}, {@link AImageDecoderHeaderInfo_getHeight}) 874*38e8c45fSAndroid Build Coastguard Worker * updated by this frame. 875*38e8c45fSAndroid Build Coastguard Worker * 876*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 877*38e8c45fSAndroid Build Coastguard Worker * 878*38e8c45fSAndroid Build Coastguard Worker * Note that this is unaffected by calls to 879*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_setTargetSize} or 880*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_setCrop}. 881*38e8c45fSAndroid Build Coastguard Worker * 882*38e8c45fSAndroid Build Coastguard Worker * A frame may update only part of the image. This will always be 883*38e8c45fSAndroid Build Coastguard Worker * contained by the image’s dimensions. 884*38e8c45fSAndroid Build Coastguard Worker * 885*38e8c45fSAndroid Build Coastguard Worker * This, along with other information in AImageDecoderFrameInfo, 886*38e8c45fSAndroid Build Coastguard Worker * can be useful for determining whether a frame is independent, but 887*38e8c45fSAndroid Build Coastguard Worker * the decoder handles blending frames, so a simple 888*38e8c45fSAndroid Build Coastguard Worker * sequential client does not need this. 889*38e8c45fSAndroid Build Coastguard Worker * 890*38e8c45fSAndroid Build Coastguard Worker * Errors: 891*38e8c45fSAndroid Build Coastguard Worker * - returns an empty ARect if |info| is null. 892*38e8c45fSAndroid Build Coastguard Worker */ 893*38e8c45fSAndroid Build Coastguard Worker ARect AImageDecoderFrameInfo_getFrameRect( 894*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderFrameInfo* _Nonnull info) __INTRODUCED_IN(31); 895*38e8c45fSAndroid Build Coastguard Worker 896*38e8c45fSAndroid Build Coastguard Worker /** 897*38e8c45fSAndroid Build Coastguard Worker * Whether the new portion of this frame may contain alpha. 898*38e8c45fSAndroid Build Coastguard Worker * 899*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 900*38e8c45fSAndroid Build Coastguard Worker * 901*38e8c45fSAndroid Build Coastguard Worker * Unless this frame is independent (see {@link AImageDecoder_decodeImage}), 902*38e8c45fSAndroid Build Coastguard Worker * a single call to {@link AImageDecoder_decodeImage} will decode an updated 903*38e8c45fSAndroid Build Coastguard Worker * rectangle of pixels and then blend it with the existing pixels in the 904*38e8c45fSAndroid Build Coastguard Worker * |pixels| buffer according to {@link AImageDecoderFrameInfo_getBlendOp}. This 905*38e8c45fSAndroid Build Coastguard Worker * method returns whether the updated rectangle has alpha, prior to blending. 906*38e8c45fSAndroid Build Coastguard Worker * The return value is conservative; for example, if a color-index-based frame 907*38e8c45fSAndroid Build Coastguard Worker * has a color with alpha but does not use it, this will still return true. 908*38e8c45fSAndroid Build Coastguard Worker * 909*38e8c45fSAndroid Build Coastguard Worker * This, along with other information in AImageDecoderFrameInfo, 910*38e8c45fSAndroid Build Coastguard Worker * can be useful for determining whether a frame is independent, but 911*38e8c45fSAndroid Build Coastguard Worker * the decoder handles blending frames, so a simple 912*38e8c45fSAndroid Build Coastguard Worker * sequential client does not need this. 913*38e8c45fSAndroid Build Coastguard Worker * 914*38e8c45fSAndroid Build Coastguard Worker * Note that this may differ from whether the composed frame (that is, the 915*38e8c45fSAndroid Build Coastguard Worker * resulting image after blending) has alpha. If this frame does not fill the 916*38e8c45fSAndroid Build Coastguard Worker * entire image dimensions (see {@link AImageDecoderFrameInfo_getFrameRect}) 917*38e8c45fSAndroid Build Coastguard Worker * or it blends with an opaque frame, for example, the composed frame’s alpha 918*38e8c45fSAndroid Build Coastguard Worker * may not match. 919*38e8c45fSAndroid Build Coastguard Worker * 920*38e8c45fSAndroid Build Coastguard Worker * Errors: 921*38e8c45fSAndroid Build Coastguard Worker * - returns false if |info| is null. 922*38e8c45fSAndroid Build Coastguard Worker */ 923*38e8c45fSAndroid Build Coastguard Worker bool AImageDecoderFrameInfo_hasAlphaWithinBounds( 924*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderFrameInfo* _Nonnull info) __INTRODUCED_IN(31); 925*38e8c45fSAndroid Build Coastguard Worker 926*38e8c45fSAndroid Build Coastguard Worker /** 927*38e8c45fSAndroid Build Coastguard Worker * How a frame is “disposed” before showing the next one. 928*38e8c45fSAndroid Build Coastguard Worker * 929*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 930*38e8c45fSAndroid Build Coastguard Worker * 931*38e8c45fSAndroid Build Coastguard Worker * This, along with other information in AImageDecoderFrameInfo, 932*38e8c45fSAndroid Build Coastguard Worker * can be useful for determining whether a frame is independent, but 933*38e8c45fSAndroid Build Coastguard Worker * the decoder handles disposing of frames, so a simple 934*38e8c45fSAndroid Build Coastguard Worker * sequential client does not need this. 935*38e8c45fSAndroid Build Coastguard Worker */ 936*38e8c45fSAndroid Build Coastguard Worker enum { 937*38e8c45fSAndroid Build Coastguard Worker /// No disposal. The following frame will be drawn directly 938*38e8c45fSAndroid Build Coastguard Worker /// on top of this one. 939*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_DISPOSE_OP_NONE = 1, 940*38e8c45fSAndroid Build Coastguard Worker /// The frame’s rectangle is cleared to transparent (by AImageDecoder) 941*38e8c45fSAndroid Build Coastguard Worker /// before decoding the next frame. 942*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_DISPOSE_OP_BACKGROUND = 2, 943*38e8c45fSAndroid Build Coastguard Worker /// The frame’s rectangle is reverted to the prior frame before decoding 944*38e8c45fSAndroid Build Coastguard Worker /// the next frame. This is handled by AImageDecoder, unless 945*38e8c45fSAndroid Build Coastguard Worker /// {@link AImageDecoder_setInternallyHandleDisposePrevious} is set to false. 946*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS = 3, 947*38e8c45fSAndroid Build Coastguard Worker }; 948*38e8c45fSAndroid Build Coastguard Worker 949*38e8c45fSAndroid Build Coastguard Worker /** 950*38e8c45fSAndroid Build Coastguard Worker * Return how this frame is “disposed” before showing the next one. 951*38e8c45fSAndroid Build Coastguard Worker * 952*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 953*38e8c45fSAndroid Build Coastguard Worker * 954*38e8c45fSAndroid Build Coastguard Worker * This, along with other information in AImageDecoderFrameInfo, 955*38e8c45fSAndroid Build Coastguard Worker * can be useful for determining whether a frame is independent, but 956*38e8c45fSAndroid Build Coastguard Worker * the decoder handles disposing of frames, so a simple 957*38e8c45fSAndroid Build Coastguard Worker * sequential client does not need this. 958*38e8c45fSAndroid Build Coastguard Worker * 959*38e8c45fSAndroid Build Coastguard Worker * @return one of: 960*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_NONE} 961*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_BACKGROUND} 962*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS} 963*38e8c45fSAndroid Build Coastguard Worker * Errors: 964*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if |info| is null. 965*38e8c45fSAndroid Build Coastguard Worker */ 966*38e8c45fSAndroid Build Coastguard Worker int32_t AImageDecoderFrameInfo_getDisposeOp( 967*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderFrameInfo* _Nonnull info) __INTRODUCED_IN(31); 968*38e8c45fSAndroid Build Coastguard Worker 969*38e8c45fSAndroid Build Coastguard Worker /** 970*38e8c45fSAndroid Build Coastguard Worker * How a frame is blended with the previous frame. 971*38e8c45fSAndroid Build Coastguard Worker * 972*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 973*38e8c45fSAndroid Build Coastguard Worker * 974*38e8c45fSAndroid Build Coastguard Worker * This, along with other information in AImageDecoderFrameInfo, 975*38e8c45fSAndroid Build Coastguard Worker * can be useful for determining whether a frame is independent, but 976*38e8c45fSAndroid Build Coastguard Worker * the decoder handles blending frames, so a simple 977*38e8c45fSAndroid Build Coastguard Worker * sequential client does not need this. 978*38e8c45fSAndroid Build Coastguard Worker */ 979*38e8c45fSAndroid Build Coastguard Worker enum { 980*38e8c45fSAndroid Build Coastguard Worker /// This frame replaces existing content. This corresponds 981*38e8c45fSAndroid Build Coastguard Worker /// to webp’s “do not blend”. 982*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_BLEND_OP_SRC = 1, 983*38e8c45fSAndroid Build Coastguard Worker /// This frame blends with the previous frame. 984*38e8c45fSAndroid Build Coastguard Worker ANDROID_IMAGE_DECODER_BLEND_OP_SRC_OVER = 2, 985*38e8c45fSAndroid Build Coastguard Worker }; 986*38e8c45fSAndroid Build Coastguard Worker 987*38e8c45fSAndroid Build Coastguard Worker /** 988*38e8c45fSAndroid Build Coastguard Worker * Return how this frame is blended with the previous frame. 989*38e8c45fSAndroid Build Coastguard Worker * 990*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 991*38e8c45fSAndroid Build Coastguard Worker * 992*38e8c45fSAndroid Build Coastguard Worker * This, along with other information in AImageDecoderFrameInfo, 993*38e8c45fSAndroid Build Coastguard Worker * can be useful for determining whether a frame is independent, but 994*38e8c45fSAndroid Build Coastguard Worker * the decoder handles blending frames, so a simple 995*38e8c45fSAndroid Build Coastguard Worker * sequential client does not need this. 996*38e8c45fSAndroid Build Coastguard Worker * 997*38e8c45fSAndroid Build Coastguard Worker * @return one of: 998*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BLEND_OP_SRC} 999*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BLEND_OP_SRC_OVER} 1000*38e8c45fSAndroid Build Coastguard Worker * Errors: 1001*38e8c45fSAndroid Build Coastguard Worker * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if |info| is null. 1002*38e8c45fSAndroid Build Coastguard Worker */ 1003*38e8c45fSAndroid Build Coastguard Worker int32_t AImageDecoderFrameInfo_getBlendOp( 1004*38e8c45fSAndroid Build Coastguard Worker const AImageDecoderFrameInfo* _Nonnull info) 1005*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 1006*38e8c45fSAndroid Build Coastguard Worker 1007*38e8c45fSAndroid Build Coastguard Worker /** 1008*38e8c45fSAndroid Build Coastguard Worker * Whether to have AImageDecoder store the frame prior to a 1009*38e8c45fSAndroid Build Coastguard Worker * frame marked {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS}. 1010*38e8c45fSAndroid Build Coastguard Worker * 1011*38e8c45fSAndroid Build Coastguard Worker * Introduced in API 31. 1012*38e8c45fSAndroid Build Coastguard Worker * 1013*38e8c45fSAndroid Build Coastguard Worker * The default is true. Many images will not have such a frame (it 1014*38e8c45fSAndroid Build Coastguard Worker * is not supported by WebP, and only some GIFs use it). But 1015*38e8c45fSAndroid Build Coastguard Worker * if frame i is ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS, then i+1 1016*38e8c45fSAndroid Build Coastguard Worker * may depend on i-1. When this setting is true, AImageDecoder will 1017*38e8c45fSAndroid Build Coastguard Worker * defensively copy frame i-1 (i.e. the contents of |pixels| in 1018*38e8c45fSAndroid Build Coastguard Worker * {@link AImageDecoder_decodeImage}) into an internal buffer so that 1019*38e8c45fSAndroid Build Coastguard Worker * it can be used to decode i+1. 1020*38e8c45fSAndroid Build Coastguard Worker * 1021*38e8c45fSAndroid Build Coastguard Worker * AImageDecoder will only store a single frame, at the size specified 1022*38e8c45fSAndroid Build Coastguard Worker * by {@link AImageDecoder_setTargetSize} (or the original dimensions 1023*38e8c45fSAndroid Build Coastguard Worker * if that method has not been called), and will discard it when it is 1024*38e8c45fSAndroid Build Coastguard Worker * no longer necessary. 1025*38e8c45fSAndroid Build Coastguard Worker * 1026*38e8c45fSAndroid Build Coastguard Worker * A client that desires to manually store such frames may set this to 1027*38e8c45fSAndroid Build Coastguard Worker * false, so that AImageDecoder does not need to store this extra 1028*38e8c45fSAndroid Build Coastguard Worker * frame. Instead, when decoding the same 1029*38e8c45fSAndroid Build Coastguard Worker * ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS frame i, AImageDecoder 1030*38e8c45fSAndroid Build Coastguard Worker * will decode directly into |pixels|, assuming the client stored i-1. 1031*38e8c45fSAndroid Build Coastguard Worker * When asked to decode frame i+1, AImageDecoder will now assume that 1032*38e8c45fSAndroid Build Coastguard Worker * the client provided i-1 in |pixels|. 1033*38e8c45fSAndroid Build Coastguard Worker * 1034*38e8c45fSAndroid Build Coastguard Worker * @param decoder an {@link AImageDecoder} object. 1035*38e8c45fSAndroid Build Coastguard Worker * @param handleInternally Whether AImageDecoder will internally 1036*38e8c45fSAndroid Build Coastguard Worker * handle ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS 1037*38e8c45fSAndroid Build Coastguard Worker * frames. 1038*38e8c45fSAndroid Build Coastguard Worker */ 1039*38e8c45fSAndroid Build Coastguard Worker void AImageDecoder_setInternallyHandleDisposePrevious( 1040*38e8c45fSAndroid Build Coastguard Worker AImageDecoder* _Nonnull decoder, bool handleInternally) 1041*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 1042*38e8c45fSAndroid Build Coastguard Worker 1043*38e8c45fSAndroid Build Coastguard Worker 1044*38e8c45fSAndroid Build Coastguard Worker #ifdef __cplusplus 1045*38e8c45fSAndroid Build Coastguard Worker } 1046*38e8c45fSAndroid Build Coastguard Worker #endif 1047*38e8c45fSAndroid Build Coastguard Worker 1048*38e8c45fSAndroid Build Coastguard Worker #endif // ANDROID_IMAGE_DECODER_H 1049*38e8c45fSAndroid Build Coastguard Worker 1050*38e8c45fSAndroid Build Coastguard Worker /** @} */ 1051