Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1be112f2 authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Rename setAlphaFlags to setUnpremultipliedRequired

Bug: 135133301
Test: I48e49ee08ab1954eddf62ecae87942aeb128c10d

There is never any reason to request OPAQUE. If the image is already
opaque, using PREMUL or UNPREMUL has no effect. If the image is not
opaque, the requesting OPAQUE is an error. This behavior is not
helpful.

In addition, this matches the Java API for
android.graphics.ImageDecoder.

Lastly, the old API was confusing for animated images. It is possible
for the first frame to be opaque, while a later frame is not. Requesting
OPAQUE seems reasonable for this image, until decoding the non-opaque
frame, at which point the inconsistency shows. Having a setting of
unpremul or not makes it obvious what will happen for the later frame.

Change-Id: I3381582e27894e1072db9b8635f3762b801f5d69
parent f157a263
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -143,23 +143,20 @@ void AImageDecoder_delete(AImageDecoder* decoder) __INTRODUCED_IN(30);
int AImageDecoder_setAndroidBitmapFormat(AImageDecoder*,
        int32_t format) __INTRODUCED_IN(30);

/*
 * Choose the desired output format.
 *
 * Must be one of:
 * {@link ANDROID_BITMAP_FLAGS_ALPHA_PREMUL}
 * {@link ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE}
 * {@link ANDROID_BITMAP_FLAGS_ALPHA_UNPREMUL}
/**
 * Specify whether the output's pixels should be unpremultiplied.
 *
 * Note: An OPAQUE image may be set to any of them.
 *       A non-OPAQUE image may not be set to OPAQUE
 * By default, the decoder will premultiply the pixels, if they have alpha. Pass
 * false to this method to leave them unpremultiplied. This has no effect on an
 * opaque image.
 *
 * @param required Pass true to leave the pixels unpremultiplied.
 * @return - {@link ANDROID_IMAGE_DECODER_SUCCESS} on success
 *         - {@link ANDROID_IMAGE_DECODER_INVALID_CONVERSION} if the conversion
 *           is not possible
 *         - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} for bad parameters
 */
int AImageDecoder_setAlphaFlags(AImageDecoder*, int alphaFlags) __INTRODUCED_IN(30);
int AImageDecoder_setUnpremultipliedRequired(AImageDecoder*, bool required) __INTRODUCED_IN(30);

/**
 * Specify the output size for a decoded image.