blob: 6e5da52cb53c12827f8cbd1b8e9fd1a5cf8bd0f1 [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
23 * to decode images like PNG, JPEG, GIF, WEBP and HEIF. It has similar options
24 * for scaling, cropping, and choosing the output format. Unlike the Java API,
25 * which can create an android.graphics.Bitmap or
26 * android.graphics.drawable.Drawable object, AImageDecoder decodes directly
27 * into memory provided by the client. For more information, see the
28 * <a href="https://developer.android.com/ndk/guides/image-decoder">Image decoder</a>
29 * developer guide.
Leon Scroggins III2f984942019-11-22 17:02:23 -050030 * @{
31 */
32
33/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050034 * @file imagedecoder.h
35 * @brief API for decoding images.
Leon Scroggins III2f984942019-11-22 17:02:23 -050036 */
37
38#ifndef ANDROID_IMAGE_DECODER_H
39#define ANDROID_IMAGE_DECODER_H
40
41#include "bitmap.h"
Leon Scroggins IIIa9f397b2020-01-27 12:42:56 -050042#include <android/rect.h>
Leon Scroggins III2f984942019-11-22 17:02:23 -050043#include <stdint.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49struct AAsset;
Leon Scroggins III2f984942019-11-22 17:02:23 -050050
51#if __ANDROID_API__ >= 30
52
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050053/**
54 * {@link AImageDecoder} functions result code. Many functions will return one of these
55 * to indicate success ({@link ANDROID_IMAGE_DECODER_SUCCESS}) or the reason
56 * for the failure. On failure, any out-parameters should be considered
57 * uninitialized, except where specified.
58 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050059enum {
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050060 /**
61 * Decoding was successful and complete.
62 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050063 ANDROID_IMAGE_DECODER_SUCCESS = 0,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050064 /**
65 * The input was incomplete.
66 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050067 ANDROID_IMAGE_DECODER_INCOMPLETE = -1,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050068 /**
69 * The input contained an error after decoding some lines.
70 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050071 ANDROID_IMAGE_DECODER_ERROR = -2,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050072 /**
73 * Could not convert. For example, attempting to decode an image with
74 * alpha to an opaque format.
75 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050076 ANDROID_IMAGE_DECODER_INVALID_CONVERSION = -3,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050077 /**
78 * The scale is invalid. It may have overflowed, or it may be incompatible
79 * with the current alpha setting.
80 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050081 ANDROID_IMAGE_DECODER_INVALID_SCALE = -4,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050082 /**
83 * Some other parameter was bad.
84 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050085 ANDROID_IMAGE_DECODER_BAD_PARAMETER = -5,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050086 /**
87 * Input was invalid before decoding any pixels.
88 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050089 ANDROID_IMAGE_DECODER_INVALID_INPUT = -6,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050090 /**
91 * A seek was required and it failed.
92 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050093 ANDROID_IMAGE_DECODER_SEEK_ERROR = -7,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050094 /**
95 * Some other error. For example, an internal allocation failed.
96 */
Leon Scroggins III2f984942019-11-22 17:02:23 -050097 ANDROID_IMAGE_DECODER_INTERNAL_ERROR = -8,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -050098 /**
99 * AImageDecoder did not recognize the format.
100 */
Leon Scroggins III2f984942019-11-22 17:02:23 -0500101 ANDROID_IMAGE_DECODER_UNSUPPORTED_FORMAT = -9
102};
103
104struct AImageDecoder;
105
106/**
107 * Opaque handle for decoding images.
108 *
109 * Create using one of the following:
110 * - {@link AImageDecoder_createFromAAsset}
111 * - {@link AImageDecoder_createFromFd}
112 * - {@link AImageDecoder_createFromBuffer}
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500113 *
114 * After creation, {@link AImageDecoder_getHeaderInfo} can be used to retrieve
115 * information about the encoded image. Other functions, like
116 * {@link AImageDecoder_setTargetSize}, can be used to specify how to decode, and
117 * {@link AImageDecoder_decode} will decode into client provided memory.
118 *
119 * {@link AImageDecoder} objects are NOT thread-safe, and should not be shared across
120 * threads.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500121 */
122typedef struct AImageDecoder AImageDecoder;
123
124/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500125 * Create a new {@link AImageDecoder} from an {@link AAsset}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500126 *
127 * @param asset {@link AAsset} containing encoded image data. Client is still
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500128 * responsible for calling {@link AAsset_close} on it, which may be
129 * done after deleting the returned {@link AImageDecoder}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500130 * @param outDecoder On success (i.e. return value is
131 * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to
132 * a newly created {@link AImageDecoder}. Caller is
133 * responsible for calling {@link AImageDecoder_delete} on it.
134 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500135 * indicating the reason for the failure.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500136 */
Leon Scroggins IIIa9f397b2020-01-27 12:42:56 -0500137int AImageDecoder_createFromAAsset(struct AAsset* asset, AImageDecoder** outDecoder)
138 __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500139
140/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500141 * Create a new {@link AImageDecoder} from a file descriptor.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500142 *
143 * @param fd Seekable, readable, open file descriptor for encoded data.
144 * Client is still responsible for closing it, which may be done
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500145 * after deleting the returned {@link AImageDecoder}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500146 * @param outDecoder On success (i.e. return value is
147 * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to
148 * a newly created {@link AImageDecoder}. Caller is
149 * responsible for calling {@link AImageDecoder_delete} on it.
150 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500151 * indicating the reason for the failure.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500152 */
153int AImageDecoder_createFromFd(int fd, AImageDecoder** outDecoder) __INTRODUCED_IN(30);
154
155/**
156 * Create a new AImageDecoder from a buffer.
157 *
158 * @param buffer Pointer to encoded data. Must be valid for the entire time
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500159 * the {@link AImageDecoder} is used.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500160 * @param length Byte length of buffer.
161 * @param outDecoder On success (i.e. return value is
162 * {@link ANDROID_IMAGE_DECODER_SUCCESS}), this will be set to
163 * a newly created {@link AImageDecoder}. Caller is
164 * responsible for calling {@link AImageDecoder_delete} on it.
165 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
166 * indicating reason for the failure.
167 */
168int AImageDecoder_createFromBuffer(const void* buffer, size_t length,
169 AImageDecoder** outDecoder) __INTRODUCED_IN(30);
170
171/**
172 * Delete the AImageDecoder.
173 */
174void AImageDecoder_delete(AImageDecoder* decoder) __INTRODUCED_IN(30);
175
176/**
177 * Choose the desired output format.
178 *
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500179 * @param format {@link AndroidBitmapFormat} to use for the output.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500180 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} if the format is compatible
181 * with the image and {@link ANDROID_IMAGE_DECODER_INVALID_CONVERSION}
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500182 * otherwise. In the latter case, the {@link AImageDecoder} uses the
Leon Scroggins III2f984942019-11-22 17:02:23 -0500183 * format it was already planning to use (either its default
184 * or a previously successful setting from this function).
185 */
186int AImageDecoder_setAndroidBitmapFormat(AImageDecoder*,
187 int32_t format) __INTRODUCED_IN(30);
188
Leon Scroggins III1be112f2020-01-15 04:26:44 -0500189/**
190 * Specify whether the output's pixels should be unpremultiplied.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500191 *
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500192 * By default, {@link AImageDecoder_decodeImage} will premultiply the pixels, if they have alpha.
193 * Pass true to this method to leave them unpremultiplied. This has no effect on an
Leon Scroggins III1be112f2020-01-15 04:26:44 -0500194 * opaque image.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500195 *
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500196 * @param unpremultipliedRequired Pass true to leave the pixels unpremultiplied.
197 * @return an enum describing whether the call succeeded.
198 * - {@link ANDROID_IMAGE_DECODER_SUCCESS} on success
Leon Scroggins III2f984942019-11-22 17:02:23 -0500199 * - {@link ANDROID_IMAGE_DECODER_INVALID_CONVERSION} if the conversion
200 * is not possible
201 * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} for bad parameters
202 */
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500203int AImageDecoder_setUnpremultipliedRequired(AImageDecoder*,
204 bool unpremultipliedRequired) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500205
206/**
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500207 * Choose the dataspace for the output.
208 *
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500209 * Ignored by {@link ANDROID_BITMAP_FORMAT_A_8}, which does not support
210 * an {@link ADataSpace}.
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500211 *
212 * @param dataspace The {@link ADataSpace} to decode into. An ADataSpace
213 * specifies how to interpret the colors. By default,
214 * AImageDecoder will decode into the ADataSpace specified by
215 * {@link AImageDecoderHeaderInfo_getDataSpace}. If this
216 * parameter is set to a different ADataSpace, AImageDecoder
217 * will transform the output into the specified ADataSpace.
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500218 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or
219 * {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} for a null
220 * {@link AImageDecoder} or an integer that does not correspond to an
221 * {@link ADataSpace} value.
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500222 */
223int AImageDecoder_setDataSpace(AImageDecoder*, int32_t dataspace) __INTRODUCED_IN(30);
224
225/**
Leon Scroggins III2f984942019-11-22 17:02:23 -0500226 * Specify the output size for a decoded image.
227 *
228 * Future calls to {@link AImageDecoder_decodeImage} will sample or scale the
229 * encoded image to reach the desired size. If a crop rect is set (via
230 * {@link AImageDecoder_setCrop}), it must be contained within the dimensions
231 * specified by width and height, and the output image will be the size of the
232 * crop rect.
233 *
234 * @param width Width of the output (prior to cropping).
235 * This will affect future calls to
236 * {@link AImageDecoder_getMinimumStride}, which will now return
237 * a value based on this width.
238 * @param height Height of the output (prior to cropping).
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500239 * @return an enum describing whether the call succeeded.
240 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or
241 * {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if the {@link AImageDecoder}
242 * pointer is null, width or height is <= 0, or any existing crop is
243 * not contained by the new image dimensions.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500244 */
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500245int AImageDecoder_setTargetSize(AImageDecoder*, int32_t width, int32_t height) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500246
Leon Scroggins IIIf27256b2020-01-19 21:13:04 -0500247
248/**
249 * Compute the dimensions to use for a given sampleSize.
250 *
251 * Although AImageDecoder can scale to an arbitrary target size (see
252 * {@link AImageDecoder_setTargetSize}), some sizes may be more efficient than
253 * others. This computes the most efficient target size to use to reach a
254 * particular sampleSize.
255 *
256 * @param sampleSize A subsampling rate of the original image. Must be greater
257 * than or equal to 1. A sampleSize of 2 means to skip every
258 * other pixel/line, resulting in a width and height that are
259 * 1/2 of the original dimensions, with 1/4 the number of
260 * pixels.
261 * @param width Out parameter for the width sampled by sampleSize, and rounded
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500262 * in the direction that the decoder can do most efficiently.
Leon Scroggins IIIf27256b2020-01-19 21:13:04 -0500263 * @param height Out parameter for the height sampled by sampleSize, and rounded
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500264 * in the direction that the decoder can do most efficiently.
265 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or
266 * {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} for bad input.
Leon Scroggins IIIf27256b2020-01-19 21:13:04 -0500267 */
268int AImageDecoder_computeSampledSize(const AImageDecoder*, int sampleSize,
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500269 int32_t* width, int32_t* height) __INTRODUCED_IN(30);
Leon Scroggins III2f984942019-11-22 17:02:23 -0500270/**
271 * Specify how to crop the output after scaling (if any).
272 *
273 * Future calls to {@link AImageDecoder_decodeImage} will crop their output to
274 * the specified {@link ARect}. Clients will only need to allocate enough memory
275 * for the cropped ARect.
276 *
277 * @param crop Rectangle describing a crop of the decode. It must be contained inside of
278 * the (possibly scaled, by {@link AImageDecoder_setTargetSize})
279 * image dimensions. This will affect future calls to
280 * {@link AImageDecoder_getMinimumStride}, which will now return a
281 * value based on the width of the crop. An empty ARect -
282 * specifically { 0, 0, 0, 0 } - may be used to remove the cropping
283 * behavior. Any other empty or unsorted ARects will result in
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500284 * returning {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}.
285 * @return an enum describing whether the call succeeded.
286 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or
287 * {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if the {@link AImageDecoder}
288 * pointer is null or the crop is not contained by the image
289 * dimensions.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500290 */
291int AImageDecoder_setCrop(AImageDecoder*, ARect crop) __INTRODUCED_IN(30);
292
Leon Scroggins III2f984942019-11-22 17:02:23 -0500293struct AImageDecoderHeaderInfo;
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500294/**
295 * Opaque handle for representing information about the encoded image. It can
296 * be passed to methods like {@link AImageDecoderHeaderInfo_getWidth} and
297 * {@link AImageDecoderHeaderInfo_getHeight}.
298 */
Leon Scroggins III2f984942019-11-22 17:02:23 -0500299typedef struct AImageDecoderHeaderInfo AImageDecoderHeaderInfo;
300
301/**
302 * Return an opaque handle for reading header info.
303 *
304 * This is owned by the {@link AImageDecoder} and will be destroyed when the
305 * AImageDecoder is destroyed via {@link AImageDecoder_delete}.
306 */
307const AImageDecoderHeaderInfo* AImageDecoder_getHeaderInfo(
308 const AImageDecoder*) __INTRODUCED_IN(30);
309
310/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500311 * Report the native width of the encoded image. This is also the logical
312 * pixel width of the output, unless {@link AImageDecoder_setTargetSize} is
313 * used to choose a different size.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500314 */
315int32_t AImageDecoderHeaderInfo_getWidth(const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30);
316
317/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500318 * Report the native height of the encoded image. This is also the logical
319 * pixel height of the output, unless {@link AImageDecoder_setTargetSize} is
320 * used to choose a different size.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500321 */
322int32_t AImageDecoderHeaderInfo_getHeight(const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30);
323
324/**
325 * Report the mimeType of the encoded image.
326 *
327 * @return a string literal describing the mime type.
328 */
329const char* AImageDecoderHeaderInfo_getMimeType(
330 const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30);
331
332/**
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500333 * Report the {@link AndroidBitmapFormat} the AImageDecoder will decode to
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500334 * by default. {@link AImageDecoder} will try to choose one that is sensible
Leon Scroggins III2f984942019-11-22 17:02:23 -0500335 * for the image and the system. Note that this does not indicate the
336 * encoded format of the image.
337 */
Leon Scroggins III5d0445c2020-01-23 09:43:43 -0500338int32_t AImageDecoderHeaderInfo_getAndroidBitmapFormat(
Leon Scroggins III2f984942019-11-22 17:02:23 -0500339 const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30);
340
341/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500342 * Report how the {@link AImageDecoder} will handle alpha by default. If the image
Leon Scroggins III2f984942019-11-22 17:02:23 -0500343 * contains no alpha (according to its header), this will return
344 * {@link ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE}. If the image may contain alpha,
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500345 * this returns {@link ANDROID_BITMAP_FLAGS_ALPHA_PREMUL}, because
346 * {@link AImageDecoder_decodeImage} will premultiply pixels by default.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500347 */
348int AImageDecoderHeaderInfo_getAlphaFlags(
349 const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30);
350
351/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500352 * Report the dataspace the {@link AImageDecoder} will decode to by default.
Leon Scroggins III20d480c2020-01-15 15:32:59 -0500353 * AImageDecoder will try to choose one that is sensible for the
354 * image and the system. Note that this may not exactly match the ICC
355 * profile (or other color information) stored in the encoded image.
356 *
357 * @return The {@link ADataSpace} most closely representing the way the colors
358 * are encoded (or {@link ADATASPACE_UNKNOWN} if there is not an
359 * approximate ADataSpace). This specifies how to interpret the colors
360 * in the decoded image, unless {@link AImageDecoder_setDataSpace} is
361 * called to decode to a different ADataSpace.
362 *
363 * Note that ADataSpace only exposes a few values. This may return
364 * ADATASPACE_UNKNOWN, even for Named ColorSpaces, if they have no
365 * corresponding ADataSpace.
366 */
367int32_t AImageDecoderHeaderInfo_getDataSpace(
368 const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30);
369
370/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500371 * Return the minimum stride that can be used in
372 * {@link AImageDecoder_decodeImage).
373 *
374 * This stride provides no padding, meaning it will be exactly equal to the
375 * width times the number of bytes per pixel for the {@link AndroidBitmapFormat}
376 * being used.
377 *
378 * If the output is scaled (via {@link AImageDecoder_setTargetSize}) and/or
379 * cropped (via {@link AImageDecoder_setCrop}), this takes those into account.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500380 */
381size_t AImageDecoder_getMinimumStride(AImageDecoder*) __INTRODUCED_IN(30);
382
383/**
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500384 * Decode the image into pixels, using the settings of the {@link AImageDecoder}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500385 *
386 * @param decoder Opaque object representing the decoder.
387 * @param pixels On success, will be filled with the result
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500388 * of the decode. Must be large enough to hold |size| bytes.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500389 * @param stride Width in bytes of a single row. Must be at least
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500390 * {@link AImageDecoder_getMinimumStride} and a multiple of the
391 * bytes per pixel of the {@link AndroidBitmapFormat}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500392 * @param size Size of the pixel buffer in bytes. Must be at least
393 * stride * (height - 1) +
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500394 * {@link AImageDecoder_getMinimumStride}.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500395 * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success, or an error code
396 * from the same enum describing the failure.
Leon Scroggins III97fea5f2020-01-30 12:18:20 -0500397 * {@link ANDROID_IMAGE_DECODER_INCOMPLETE} or
398 * {@link ANDROID_IMAGE_DECODER_ERROR} means that a partial image was
399 * decoded, and undecoded lines have been initialized to all zeroes.
Leon Scroggins III2f984942019-11-22 17:02:23 -0500400 */
401int AImageDecoder_decodeImage(AImageDecoder* decoder,
402 void* pixels, size_t stride,
403 size_t size) __INTRODUCED_IN(30);
404
405#endif // __ANDROID_API__ >= 30
406
407#ifdef __cplusplus
408}
409#endif
410
411#endif // ANDROID_IMAGE_DECODER_H
412
413/** @} */