blob: 69a6fd62aa90064238cd32ed1b22e203e58842df [file] [log] [blame]
Leon Scroggins III2f984942019-11-22 17:02:23 -05001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050018 * @defgroup ImageDecoder
19 *
20 * Functions for converting encoded images into RGBA pixels.
21 *
22 * Similar to the Java counterpart android.graphics.ImageDecoder, it can be used
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -050023 * to decode images in the following formats:
24 * - JPEG
25 * - PNG
26 * - GIF
27 * - WebP
28 * - BMP
29 * - ICO
30 * - WBMP
31 * - HEIF
32 * - Digital negatives (via the DNG SDK)
33 * <p>It has similar options for scaling, cropping, and choosing the output format.
34 * Unlike the Java API, which can create an android.graphics.Bitmap or
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050035 * android.graphics.drawable.Drawable object, AImageDecoder decodes directly
36 * into memory provided by the client. For more information, see the
37 * <a href="https://developer.android.com/ndk/guides/image-decoder">Image decoder</a>
38 * developer guide.
Leon Scroggins III2f984942019-11-22 17:02:23 -050039 * @{
40 */
41
42/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050043 * @file imagedecoder.h
44 * @brief API for decoding images.
Leon Scroggins III2f984942019-11-22 17:02:23 -050045 */
46
47#ifndef ANDROID_IMAGE_DECODER_H
48#define ANDROID_IMAGE_DECODER_H
49
50#include "bitmap.h"
Leon Scroggins IIIa9f397b2020-01-27 12:42:56 -050051#include <android/rect.h>
Leon Scroggins III2f984942019-11-22 17:02:23 -050052#include <stdint.h>
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58struct AAsset;
Leon Scroggins III2f984942019-11-22 17:02:23 -050059
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050060/**
Leon Scroggins III3b3700e2020-12-29 11:52:12 -050061 * {@link AImageDecoder} functions result code.
62 *
63 * Introduced in API 30.
64 *
65 * Many functions will return this to indicate success
66 * ({@link ANDROID_IMAGE_DECODER_SUCCESS}) or the reason for the failure. On
67 * failure, any out-parameters should be considered uninitialized, except where
68 * specified.
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050069 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050070enum {
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050071 /**
72 * Decoding was successful and complete.
73 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050074 ANDROID_IMAGE_DECODER_SUCCESS = 0,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050075 /**
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -050076 * The input is incomplete.
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050077 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050078 ANDROID_IMAGE_DECODER_INCOMPLETE = -1,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050079 /**
80 * The input contained an error after decoding some lines.
81 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050082 ANDROID_IMAGE_DECODER_ERROR = -2,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050083 /**
84 * Could not convert. For example, attempting to decode an image with
85 * alpha to an opaque format.
86 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050087 ANDROID_IMAGE_DECODER_INVALID_CONVERSION = -3,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050088 /**
89 * The scale is invalid. It may have overflowed, or it may be incompatible
90 * with the current alpha setting.
91 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050092 ANDROID_IMAGE_DECODER_INVALID_SCALE = -4,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050093 /**
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -050094 * Some other parameter is invalid.
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050095 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050096 ANDROID_IMAGE_DECODER_BAD_PARAMETER = -5,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050097 /**
98 * Input was invalid before decoding any pixels.
99 */
Leon Scroggins III2f984942019-11-22 17:02:23 -0500100 ANDROID_IMAGE_DECODER_INVALID_INPUT = -6,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500101 /**
102 * A seek was required and it failed.
103 */
Leon Scroggins III2f984942019-11-22 17:02:23 -0500104 ANDROID_IMAGE_DECODER_SEEK_ERROR = -7,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500105 /**
106 * Some other error. For example, an internal allocation failed.
107 */
Leon Scroggins III2f984942019-11-22 17:02:23 -0500108 ANDROID_IMAGE_DECODER_INTERNAL_ERROR = -8,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500109 /**
110 * AImageDecoder did not recognize the format.
111 */
Leon Scroggins III55287002020-10-13 11:30:11 -0400112 ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT = -9,
113 /**
114 * The animation has reached the end.
115 */
116 ANDROID_IMAGE_DECODER_FINISHED = -10,
117 /**
118 * This method cannot be called while the AImageDecoder is in its current
119 * state. For example, various setters (like {@link AImageDecoder_setTargetSize})
120 * can only be called while the AImageDecoder is set to decode the first
121 * frame of an animation. This ensures that any blending and/or restoring
122 * prior frames works correctly.
123 */
124 ANDROID_IMAGE_DECODER_INVALID_STATE = -11,
Leon Scroggins III2f984942019-11-22 17:02:23 -0500125};
126
127struct AImageDecoder;
128
129/**
130 * Opaque handle for decoding images.
131 *
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500132 * Introduced in API 30
133 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500134 * Create using one of the following:
135 * - {@link AImageDecoder_createFromAAsset}
136 * - {@link AImageDecoder_createFromFd}
137 * - {@link AImageDecoder_createFromBuffer}
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500138 *
139 * After creation, {@link AImageDecoder_getHeaderInfo} can be used to retrieve
140 * information about the encoded image. Other functions, like
141 * {@link AImageDecoder_setTargetSize}, can be used to specify how to decode, and
142 * {@link AImageDecoder_decode} will decode into client provided memory.
143 *
144 * {@link AImageDecoder} objects are NOT thread-safe, and should not be shared across
145 * threads.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500146 */
147typedef struct AImageDecoder AImageDecoder;
148
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500149#if __ANDROID_API__ >= 30
150
Leon Scroggins III2f984942019-11-22 17:02:23 -0500151/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500152 * Create a new {@link AImageDecoder} from an {@link AAsset}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500153 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700154 * Available since API level 30.
155 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500156 * @param asset {@link AAsset} containing encoded image data. Client is still
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500157 * responsible for calling {@link AAsset_close} on it, which may be
158 * done after deleting the returned {@link AImageDecoder}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500159 * @param outDecoder On success (i.e. return value is
160 * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to
161 * a newly created {@link AImageDecoder}. Caller is
162 * responsible for calling {@link AImageDecoder_delete} on it.
163 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500164 * indicating the reason for the failure.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500165 *
166 * Errors:
167 * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The asset was truncated before
168 * reading the image header.
169 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: One of the parameters is
170 * null.
171 * - {@link ANDROID_IMAGE_DECODER_INVALID_INPUT}: There is an error in the
172 * header.
173 * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The asset failed to seek.
174 * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a
175 * failure to allocate memory.
176 * - {@link ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT}: The format is not
177 * supported.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500178 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400179int AImageDecoder_createFromAAsset(struct AAsset* _Nonnull asset,
180 AImageDecoder* _Nonnull * _Nonnull outDecoder)
Leon Scroggins IIIa9f397b2020-01-27 12:42:56 -0500181 __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500182
183/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500184 * Create a new {@link AImageDecoder} from a file descriptor.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500185 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700186 * Available since API level 30.
187 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500188 * @param fd Seekable, readable, open file descriptor for encoded data.
189 * Client is still responsible for closing it, which may be done
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500190 * after deleting the returned {@link AImageDecoder}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500191 * @param outDecoder On success (i.e. return value is
192 * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to
193 * a newly created {@link AImageDecoder}. Caller is
194 * responsible for calling {@link AImageDecoder_delete} on it.
195 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500196 * indicating the reason for the failure.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500197 *
198 * Errors:
199 * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The file was truncated before
200 * reading the image header.
201 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The {@link AImageDecoder} is
202 * null, or |fd| does not represent a valid, seekable file descriptor.
203 * - {@link ANDROID_IMAGE_DECODER_INVALID_INPUT}: There is an error in the
204 * header.
205 * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The descriptor failed to seek.
206 * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a
207 * failure to allocate memory.
208 * - {@link ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT}: The format is not
209 * supported.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500210 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400211int AImageDecoder_createFromFd(int fd, AImageDecoder* _Nonnull * _Nonnull outDecoder)
212 __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500213
214/**
215 * Create a new AImageDecoder from a buffer.
216 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700217 * Available since API level 30.
218 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500219 * @param buffer Pointer to encoded data. Must be valid for the entire time
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500220 * the {@link AImageDecoder} is used.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500221 * @param length Byte length of buffer.
222 * @param outDecoder On success (i.e. return value is
223 * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to
224 * a newly created {@link AImageDecoder}. Caller is
225 * responsible for calling {@link AImageDecoder_delete} on it.
226 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500227 * indicating the reason for the failure.
228 *
229 * Errors:
230 * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The encoded image was truncated before
231 * reading the image header.
232 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: One of the parameters is
233 * invalid.
234 * - {@link ANDROID_IMAGE_DECODER_INVALID_INPUT}: There is an error in the
235 * header.
236 * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a
237 * failure to allocate memory.
238 * - {@link ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT}: The format is not
239 * supported.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500240 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400241int AImageDecoder_createFromBuffer(const void* _Nonnull buffer, size_t length,
242 AImageDecoder* _Nonnull * _Nonnull outDecoder)
243 __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500244
245/**
246 * Delete the AImageDecoder.
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700247 *
248 * Available since API level 30.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500249 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400250void AImageDecoder_delete(AImageDecoder* _Nonnull decoder) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500251
252/**
253 * Choose the desired output format.
254 *
Leon Scroggins III55287002020-10-13 11:30:11 -0400255 * If the encoded image represents an animation, this must be called while on
256 * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or
257 * after calling {@link AImageDecoder_rewind}).
258 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700259 * Available since API level 30.
260 *
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500261 * @param format {@link AndroidBitmapFormat} to use for the output.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500262 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
263 * indicating the reason for the failure. On failure, the
264 * {@link AImageDecoder} uses the format it was already planning
265 * to use (either its default or a previously successful setting
266 * from this function).
267 *
268 * Errors:
269 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The
270 * {@link AImageDecoder} is null or |format| does not correspond to an
271 * {@link AndroidBitmapFormat}.
272 * - {@link ANDROID_IMAGE_DECODER_INVALID_CONVERSION}: The
273 * {@link AndroidBitmapFormat} is incompatible with the image.
Leon Scroggins III55287002020-10-13 11:30:11 -0400274 * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on
275 * the first frame.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500276 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400277int AImageDecoder_setAndroidBitmapFormat(AImageDecoder* _Nonnull decoder,
Leon Scroggins III2f984942019-11-22 17:02:23 -0500278 int32_t format) __INTRODUCED_IN(30);
279
Leon Scroggins III1be112f2020-01-15 04:26:44 -0500280/**
281 * Specify whether the output's pixels should be unpremultiplied.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500282 *
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500283 * By default, {@link AImageDecoder_decodeImage} will premultiply the pixels, if they have alpha.
284 * Pass true to this method to leave them unpremultiplied. This has no effect on an
Leon Scroggins III1be112f2020-01-15 04:26:44 -0500285 * opaque image.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500286 *
Leon Scroggins III55287002020-10-13 11:30:11 -0400287 * If the encoded image represents an animation, this must be called while on
288 * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or
289 * after calling {@link AImageDecoder_rewind}).
290 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700291 * Available since API level 30.
292 *
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500293 * @param unpremultipliedRequired Pass true to leave the pixels unpremultiplied.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500294 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
295 * indicating the reason for the failure.
296 *
297 * Errors:
298 * - {@link ANDROID_IMAGE_DECODER_INVALID_CONVERSION}: Unpremultiplied is not
299 * possible due to an existing scale set by
300 * {@link AImageDecoder_setTargetSize}.
301 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The
302 * {@link AImageDecoder} is null.
Leon Scroggins III55287002020-10-13 11:30:11 -0400303 * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on
304 * the first frame.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500305 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400306int AImageDecoder_setUnpremultipliedRequired(AImageDecoder* _Nonnull decoder,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500307 bool unpremultipliedRequired) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500308
309/**
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500310 * Choose the dataspace for the output.
311 *
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500312 * Ignored by {@link ANDROID_BITMAP_FORMAT_A_8}, which does not support
313 * an {@link ADataSpace}.
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500314 *
Leon Scroggins III55287002020-10-13 11:30:11 -0400315 * If the encoded image represents an animation, this must be called while on
316 * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or
317 * after calling {@link AImageDecoder_rewind}).
318 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700319 * Available since API level 30.
320 *
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500321 * @param dataspace The {@link ADataSpace} to decode into. An ADataSpace
322 * specifies how to interpret the colors. By default,
323 * AImageDecoder will decode into the ADataSpace specified by
324 * {@link AImageDecoderHeaderInfo_getDataSpace}. If this
325 * parameter is set to a different ADataSpace, AImageDecoder
326 * will transform the output into the specified ADataSpace.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500327 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
328 * indicating the reason for the failure.
329 *
330 * Errors:
331 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The
332 * {@link AImageDecoder} is null or |dataspace| does not correspond to an
333 * {@link ADataSpace} value.
Leon Scroggins III55287002020-10-13 11:30:11 -0400334 * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on
335 * the first frame.
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500336 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400337int AImageDecoder_setDataSpace(AImageDecoder* _Nonnull decoder, int32_t dataspace)
338 __INTRODUCED_IN(30);
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500339
340/**
Leon Scroggins III2f984942019-11-22 17:02:23 -0500341 * Specify the output size for a decoded image.
342 *
343 * Future calls to {@link AImageDecoder_decodeImage} will sample or scale the
344 * encoded image to reach the desired size. If a crop rect is set (via
345 * {@link AImageDecoder_setCrop}), it must be contained within the dimensions
346 * specified by width and height, and the output image will be the size of the
347 * crop rect.
348 *
Leon Scroggins III55287002020-10-13 11:30:11 -0400349 * If the encoded image represents an animation, this must be called while on
350 * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or
351 * after calling {@link AImageDecoder_rewind}).
352 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700353 * Available since API level 30.
354 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500355 * @param width Width of the output (prior to cropping).
356 * This will affect future calls to
357 * {@link AImageDecoder_getMinimumStride}, which will now return
358 * a value based on this width.
359 * @param height Height of the output (prior to cropping).
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500360 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
361 * indicating the reason for the failure.
362 *
363 * Errors:
364 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The
365 * {@link AImageDecoder} is null.
366 * - {@link ANDROID_IMAGE_DECODER_INVALID_SCALE}: |width| or |height| is <= 0,
Leon Scroggins III55287002020-10-13 11:30:11 -0400367 * the size is too big, any existing crop is not contained by the new image
368 * dimensions, or the scale is incompatible with a previous call to
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500369 * {@link AImageDecoder_setUnpremultipliedRequired}(true).
Leon Scroggins III55287002020-10-13 11:30:11 -0400370 * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on
371 * the first frame.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500372 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400373int AImageDecoder_setTargetSize(AImageDecoder* _Nonnull decoder, int32_t width,
374 int32_t height) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500375
Leon Scroggins IIIf27256b2020-01-19 21:13:04 -0500376/**
377 * Compute the dimensions to use for a given sampleSize.
378 *
379 * Although AImageDecoder can scale to an arbitrary target size (see
380 * {@link AImageDecoder_setTargetSize}), some sizes may be more efficient than
381 * others. This computes the most efficient target size to use to reach a
382 * particular sampleSize.
383 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700384 * Available since API level 30.
385 *
Leon Scroggins IIIf27256b2020-01-19 21:13:04 -0500386 * @param sampleSize A subsampling rate of the original image. Must be greater
387 * than or equal to 1. A sampleSize of 2 means to skip every
388 * other pixel/line, resulting in a width and height that are
389 * 1/2 of the original dimensions, with 1/4 the number of
390 * pixels.
391 * @param width Out parameter for the width sampled by sampleSize, and rounded
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500392 * in the direction that the decoder can do most efficiently.
Leon Scroggins IIIf27256b2020-01-19 21:13:04 -0500393 * @param height Out parameter for the height sampled by sampleSize, and rounded
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500394 * in the direction that the decoder can do most efficiently.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500395 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
396 * indicating the reason for the failure.
397 *
398 * Errors:
399 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The
400 * {@link AImageDecoder}, |width| or |height| is null or |sampleSize| is < 1.
Leon Scroggins IIIf27256b2020-01-19 21:13:04 -0500401 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400402int AImageDecoder_computeSampledSize(const AImageDecoder* _Nonnull decoder, int sampleSize,
403 int32_t* _Nonnull width, int32_t* _Nonnull height)
404 __INTRODUCED_IN(30);
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500405
Leon Scroggins III2f984942019-11-22 17:02:23 -0500406/**
407 * Specify how to crop the output after scaling (if any).
408 *
409 * Future calls to {@link AImageDecoder_decodeImage} will crop their output to
410 * the specified {@link ARect}. Clients will only need to allocate enough memory
411 * for the cropped ARect.
412 *
Leon Scroggins III55287002020-10-13 11:30:11 -0400413 * If the encoded image represents an animation, this must be called while on
414 * the first frame (e.g. before calling {@link AImageDecoder_advanceFrame} or
415 * after calling {@link AImageDecoder_rewind}).
416 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700417 * Available since API level 30.
418 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500419 * @param crop Rectangle describing a crop of the decode. It must be contained inside of
420 * the (possibly scaled, by {@link AImageDecoder_setTargetSize})
421 * image dimensions. This will affect future calls to
422 * {@link AImageDecoder_getMinimumStride}, which will now return a
423 * value based on the width of the crop. An empty ARect -
424 * specifically { 0, 0, 0, 0 } - may be used to remove the cropping
425 * behavior. Any other empty or unsorted ARects will result in
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500426 * returning {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500427 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
428 * indicating the reason for the failure.
429 *
430 * Errors:
431 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The
Leon Scroggins III55287002020-10-13 11:30:11 -0400432 * {@link AImageDecoder} is null, or the crop is not contained by the
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500433 * (possibly scaled) image dimensions.
Leon Scroggins III55287002020-10-13 11:30:11 -0400434 * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE}: The animation is not on
435 * the first frame.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500436 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400437int AImageDecoder_setCrop(AImageDecoder* _Nonnull decoder, ARect crop) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500438
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500439#endif // __ANDROID_API__ >= 30
440
Leon Scroggins III2f984942019-11-22 17:02:23 -0500441struct AImageDecoderHeaderInfo;
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500442/**
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500443 * Opaque handle for representing information about the encoded image.
444 *
445 * Introduced in API 30
446 *
447 * Retrieved using {@link AImageDecoder_getHeaderInfo} and passed to methods
448 * like {@link AImageDecoderHeaderInfo_getWidth} and
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500449 * {@link AImageDecoderHeaderInfo_getHeight}.
450 */
Leon Scroggins III2f984942019-11-22 17:02:23 -0500451typedef struct AImageDecoderHeaderInfo AImageDecoderHeaderInfo;
452
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500453#if __ANDROID_API__ >= 30
454
Leon Scroggins III2f984942019-11-22 17:02:23 -0500455/**
456 * Return an opaque handle for reading header info.
457 *
458 * This is owned by the {@link AImageDecoder} and will be destroyed when the
459 * AImageDecoder is destroyed via {@link AImageDecoder_delete}.
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700460 *
461 * Available since API level 30.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500462 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400463const AImageDecoderHeaderInfo* _Nonnull AImageDecoder_getHeaderInfo(
464 const AImageDecoder* _Nonnull decoder) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500465
466/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500467 * Report the native width of the encoded image. This is also the logical
468 * pixel width of the output, unless {@link AImageDecoder_setTargetSize} is
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500469 * used to choose a different size or {@link AImageDecoder_setCrop} is used to
470 * set a crop rect.
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700471 *
472 * Available since API level 30.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500473 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400474int32_t AImageDecoderHeaderInfo_getWidth(const AImageDecoderHeaderInfo* _Nonnull)
475 __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500476
477/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500478 * Report the native height of the encoded image. This is also the logical
479 * pixel height of the output, unless {@link AImageDecoder_setTargetSize} is
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500480 * used to choose a different size or {@link AImageDecoder_setCrop} is used to
481 * set a crop rect.
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700482 *
483 * Available since API level 30.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500484 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400485int32_t AImageDecoderHeaderInfo_getHeight(const AImageDecoderHeaderInfo* _Nonnull)
486 __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500487
488/**
489 * Report the mimeType of the encoded image.
490 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700491 * Available since API level 30.
492 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500493 * @return a string literal describing the mime type.
494 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400495const char* _Nonnull AImageDecoderHeaderInfo_getMimeType(
496 const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500497
498/**
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500499 * Report the {@link AndroidBitmapFormat} the AImageDecoder will decode to
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500500 * by default. {@link AImageDecoder} will try to choose one that is sensible
Leon Scroggins III2f984942019-11-22 17:02:23 -0500501 * for the image and the system. Note that this does not indicate the
502 * encoded format of the image.
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700503 *
504 * Available since API level 30.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500505 */
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500506int32_t AImageDecoderHeaderInfo_getAndroidBitmapFormat(
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400507 const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500508
509/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500510 * Report how the {@link AImageDecoder} will handle alpha by default. If the image
Leon Scroggins III2f984942019-11-22 17:02:23 -0500511 * contains no alpha (according to its header), this will return
512 * {@link ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE}. If the image may contain alpha,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500513 * this returns {@link ANDROID_BITMAP_FLAGS_ALPHA_PREMUL}, because
514 * {@link AImageDecoder_decodeImage} will premultiply pixels by default.
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700515 *
516 * Available since API level 30.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500517 */
518int AImageDecoderHeaderInfo_getAlphaFlags(
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400519 const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500520
521/**
Leon Scroggins III8cee65e2020-01-30 14:20:42 -0500522 * Report the dataspace the AImageDecoder will decode to by default.
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500523 *
Leon Scroggins III8cee65e2020-01-30 14:20:42 -0500524 * By default, {@link AImageDecoder_decodeImage} will not do any color
525 * conversion.
526 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700527 * Available since API level 30.
528 *
Leon Scroggins III8cee65e2020-01-30 14:20:42 -0500529 * @return The {@link ADataSpace} representing the way the colors
530 * are encoded (or {@link ADATASPACE_UNKNOWN} if there is not a
531 * corresponding ADataSpace). This specifies how to interpret the colors
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500532 * in the decoded image, unless {@link AImageDecoder_setDataSpace} is
533 * called to decode to a different ADataSpace.
534 *
535 * Note that ADataSpace only exposes a few values. This may return
Leon Scroggins III8cee65e2020-01-30 14:20:42 -0500536 * {@link ADATASPACE_UNKNOWN}, even for Named ColorSpaces, if they have
537 * no corresponding {@link ADataSpace}.
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500538 */
539int32_t AImageDecoderHeaderInfo_getDataSpace(
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400540 const AImageDecoderHeaderInfo* _Nonnull) __INTRODUCED_IN(30);
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500541
542/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500543 * Return the minimum stride that can be used in
544 * {@link AImageDecoder_decodeImage).
545 *
546 * This stride provides no padding, meaning it will be exactly equal to the
547 * width times the number of bytes per pixel for the {@link AndroidBitmapFormat}
548 * being used.
549 *
550 * If the output is scaled (via {@link AImageDecoder_setTargetSize}) and/or
551 * cropped (via {@link AImageDecoder_setCrop}), this takes those into account.
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700552 *
553 * Available since API level 30.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500554 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400555size_t AImageDecoder_getMinimumStride(AImageDecoder* _Nonnull decoder) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500556
557/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500558 * Decode the image into pixels, using the settings of the {@link AImageDecoder}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500559 *
Elliott Hughes7be0e2d2020-06-02 13:05:04 -0700560 * Available since API level 30.
561 *
Leon Scroggins III1b389712020-10-09 13:12:39 -0400562 * Starting in API level 31, it can be used to decode all of the frames of an
Leon Scroggins III55287002020-10-13 11:30:11 -0400563 * animated image (i.e. GIF, WebP, HEIF) using new APIs. Internally,
564 * AImageDecoder keeps track of its "current frame" - that is, the frame that
565 * will be decoded by a call to AImageDecoder_decodeImage. At creation time, the
566 * current frame is always the first frame, and multiple calls to this method
567 * will each decode the first frame. {@link AImageDecoder_advanceFrame} advances
568 * the current frame to the following frame, so that future calls to this method
569 * will decode that frame. Some frames may update only part of the image. They
570 * may only update a sub-rectangle (see {@link
571 * AImageDecoderFrameInfo_getFrameRect}), or they may have alpha (see
572 * {@link AImageDecoderFrameInfo_hasAlphaWithinBounds}). In these cases, this
573 * method assumes that the prior frame is still residing in the |pixels| buffer,
574 * decodes only the new portion, and blends it with the buffer. Frames that change
575 * the entire |pixels| buffer are "independent", and do not require the prior
576 * frame to remain in the buffer. The first frame is always independent. A
577 * sophisticated client can use information from the {@link AImageDecoderFrameInfo}
578 * to determine whether other frames are independent, or what frames they rely on.
579 *
580 * If the current frame is marked {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS},
581 * AImageDecoder_decodeImage will cache the |pixels| buffer prior to decoding
582 * (note: this only happens for the first in a string of consecutive
583 * ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS frames). After advancing to the
584 * following frame, AImageDecoder_decodeImage will restore the cached buffer
585 * prior to decoding that frame.
586 *
587 * Ignoring timing information, display, etc, a client wishing to decode all
588 * frames of an animated image may conceptually use code like the following:
589 *
590 * while (true) {
591 * int result = AImageDecoder_decodeImage(decoder, pixels, stride, size);
592 * if (result != ANDROID_IMAGE_DECODER_SUCCESS) break;
593 *
594 * // Display or save the image in |pixels|, keeping the buffer intact for
595 * // AImageDecoder to decode the next frame correctly.
596 * Application_viewImage(pixels);
597 *
598 * result = AImageDecoder_advanceFrame(decoder);
599 * if (result != ANDROID_IMAGE_DECODER_SUCCESS) break;
600 * }
Leon Scroggins III1b389712020-10-09 13:12:39 -0400601 *
Leon Scroggins III2f984942019-11-22 17:02:23 -0500602 * @param decoder Opaque object representing the decoder.
603 * @param pixels On success, will be filled with the result
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500604 * of the decode. Must be large enough to hold |size| bytes.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500605 * @param stride Width in bytes of a single row. Must be at least
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500606 * {@link AImageDecoder_getMinimumStride} and a multiple of the
607 * bytes per pixel of the {@link AndroidBitmapFormat}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500608 * @param size Size of the pixel buffer in bytes. Must be at least
609 * stride * (height - 1) +
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500610 * {@link AImageDecoder_getMinimumStride}.
Leon Scroggins IIIbb5ffd22020-02-06 11:45:16 -0500611 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
612 * indicating the reason for the failure.
613 *
614 * Errors:
615 * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The image was truncated. A
616 * partial image was decoded, and undecoded lines have been initialized to all
617 * zeroes.
618 * - {@link ANDROID_IMAGE_DECODER_ERROR}: The image contained an error. A
619 * partial image was decoded, and undecoded lines have been initialized to all
620 * zeroes.
621 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The {@link AImageDecoder} or
622 * |pixels| is null, the stride is not large enough or not pixel aligned, or
623 * |size| is not large enough.
624 * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The asset or file descriptor
625 * failed to seek.
626 * - {@link ANDROID_IMAGE_DECODER_INTERNAL_ERROR}: Some other error, like a
627 * failure to allocate memory.
Leon Scroggins III55287002020-10-13 11:30:11 -0400628 * - {@link ANDROID_IMAGE_DECODER_FINISHED}: The input contains no
629 * more frames. No decoding occurred. The client must call
630 * {@link AImageDecoder_rewind} before calling
631 * {@link AImageDecoder_decodeImage} again.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500632 */
Leon Scroggins III4a8ecfe2020-10-07 10:53:24 -0400633int AImageDecoder_decodeImage(AImageDecoder* _Nonnull decoder,
634 void* _Nonnull pixels, size_t stride,
Leon Scroggins III2f984942019-11-22 17:02:23 -0500635 size_t size) __INTRODUCED_IN(30);
636
637#endif // __ANDROID_API__ >= 30
638
Leon Scroggins III1b389712020-10-09 13:12:39 -0400639#if __ANDROID_API__ >= 31
640
641/**
642 * Return true iff the image is animated - i.e. has multiple frames.
643 *
644 * Introduced in API 31.
645 *
Leon Scroggins III55287002020-10-13 11:30:11 -0400646 * A single frame GIF is considered to *not* be animated. This may require
647 * seeking past the first frame to verify whether there is a following frame.
Leon Scroggins III1b389712020-10-09 13:12:39 -0400648 *
649 * Errors:
650 * - returns false if |decoder| is null.
651 */
652bool AImageDecoder_isAnimated(AImageDecoder* _Nonnull decoder)
653 __INTRODUCED_IN(31);
654
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500655#endif // __ANDROID_API__ >= 31
656
Leon Scroggins III728a9ac2020-10-12 10:34:05 -0400657enum {
658 /*
659 * Reported by {@link AImageDecoder_getRepeatCount} if the
660 * animation should repeat forever.
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500661 *
662 * Introduced in API 31
Leon Scroggins III728a9ac2020-10-12 10:34:05 -0400663 */
664 ANDROID_IMAGE_DECODER_INFINITE = INT32_MAX,
665};
666
Leon Scroggins III3b3700e2020-12-29 11:52:12 -0500667#if __ANDROID_API__ >= 31
668
Leon Scroggins III728a9ac2020-10-12 10:34:05 -0400669/**
670 * Report how many times the animation should repeat.
671 *
672 * Introduced in API 31.
673 *
674 * This does not include the first play through. e.g. a repeat
675 * count of 4 means that each frame is played 5 times.
676 *
677 * {@link ANDROID_IMAGE_DECODER_INFINITE} means to repeat forever.
678 *
679 * This may require seeking.
680 *
681 * For non-animated formats, this returns 0. It may return non-zero for
682 * an image with only one frame (i.e. {@link AImageDecoder_isAnimated} returns
683 * false) if the encoded image contains a repeat count.
684 *
685 * @return Number of times to repeat on success or a value
686 * indicating the reason for the failure.
687 *
688 * Errors:
689 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder
690 * is null.
691 */
692int32_t AImageDecoder_getRepeatCount(AImageDecoder* _Nonnull decoder);
693 __INTRODUCED_IN(31);
694
Leon Scroggins III55287002020-10-13 11:30:11 -0400695/**
696 * Advance to the next frame in the animation.
697 *
698 * Introduced in API 31.
699 *
700 * The AImageDecoder keeps track internally which frame it is ready to decode
701 * (the "current frame"). Initially it is set to decode the first frame, and
702 * each call to {@link AImageDecoder_decodeImage} will continue to decode
703 * the same frame until this method (or {@link AImageDecoder_rewind})
704 * is called.
705 *
706 * Note that this can be used to skip a frame without decoding it. But
707 * some frames depend on (i.e. blend with) prior frames, and
708 * AImageDecoder_decodeImage assumes that the prior frame is in the
709 * |pixels| buffer. In addition, AImageDecoder_decodeImage handles caching and
710 * restoring frames (see {@link ANDROID_IMAGE_DECODER_DISPOSE_OP_PREVIOUS}), so
711 * skipping frames in an image with such frames may not produce the correct
712 * results.
713 *
714 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
715 * indicating the reason for the failure.
716 *
717 * Errors:
718 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder
719 * represents an image that is not animated (see
720 * {@link AImageDecoder_isAnimated}) or the AImageDecoder is null.
721 * - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The input appears
722 * to be truncated. The client must call {@link AImageDecoder_rewind}
723 * before calling {@link AImageDecoder_decodeImage} again.
724 * - {@link ANDROID_IMAGE_DECODER_ERROR}: The input contains an error.
725 * The client must call {@link AImageDecoder_rewind} before
726 * calling {@link AImageDecoder_decodeImage} again.
727 * - {@link ANDROID_IMAGE_DECODER_FINISHED}: The input contains no
728 * more frames. The client must call {@link AImageDecoder_rewind}
729 * before calling {@link AImageDecoder_decodeImage} again.
730 */
731int AImageDecoder_advanceFrame(AImageDecoder* _Nonnull decoder)
732 __INTRODUCED_IN(31);
733
734/**
735 * Return to the beginning of the animation.
736 *
737 * Introduced in API 31.
738 *
739 * After this call, the AImageDecoder will be ready to decode the
740 * first frame of the animation. This can be called after reaching
741 * the end of the animation or an error or in the middle of the
742 * animation.
743 *
744 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
745 * indicating the reason for the failure.
746 *
747 * Errors:
748 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder
749 * represents an image that is not animated (see
750 * {@link AImageDecoder_isAnimated}) or the AImageDecoder is
751 * null.
752 * - {@link ANDROID_IMAGE_DECODER_SEEK_ERROR}: The asset or file
753 * descriptor failed to seek.
754 */
755int AImageDecoder_rewind(AImageDecoder* _Nonnull decoder)
756 __INTRODUCED_IN(31);
757
Leon Scroggins III1b389712020-10-09 13:12:39 -0400758#endif // __ANDROID_API__ >= 31
759
Leon Scroggins III2f984942019-11-22 17:02:23 -0500760#ifdef __cplusplus
761}
762#endif
763
764#endif // ANDROID_IMAGE_DECODER_H
765
766/** @} */