Implement AImageDecoder_computeSampledSize

Bug: 135133301
Test: If9ed79d8dcf1169369ba454723f4ac8d26427b7b
Change-Id: I4926188cf66e2693c09dd7f1197173441936080c
This commit is contained in:
Leon Scroggins III
2020-01-19 21:22:18 -05:00
parent 380f3c9ae6
commit f89de63304
2 changed files with 17 additions and 0 deletions

View File

@@ -131,6 +131,10 @@ static ImageDecoder* toDecoder(AImageDecoder* d) {
return reinterpret_cast<ImageDecoder*>(d);
}
static const ImageDecoder* toDecoder(const AImageDecoder* d) {
return reinterpret_cast<const ImageDecoder*>(d);
}
// Note: This differs from the version in android_bitmap.cpp in that this
// version returns kGray_8_SkColorType for ANDROID_BITMAP_FORMAT_A_8. SkCodec
// allows decoding single channel images to gray, which Android then treats
@@ -258,6 +262,18 @@ int AImageDecoder_setTargetSize(AImageDecoder* decoder, int width, int height) {
? ANDROID_IMAGE_DECODER_SUCCESS : ANDROID_IMAGE_DECODER_INVALID_SCALE;
}
int AImageDecoder_computeSampledSize(const AImageDecoder* decoder, int sampleSize,
int* width, int* height) {
if (!decoder || !width || !height || sampleSize < 1) {
return ANDROID_IMAGE_DECODER_BAD_PARAMETER;
}
SkISize size = toDecoder(decoder)->mCodec->getSampledDimensions(sampleSize);
*width = size.width();
*height = size.height();
return ANDROID_IMAGE_DECODER_SUCCESS;
}
int AImageDecoder_setCrop(AImageDecoder* decoder, ARect crop) {
if (!decoder) {
return ANDROID_IMAGE_DECODER_BAD_PARAMETER;

View File

@@ -10,6 +10,7 @@ LIBJNIGRAPHICS {
AImageDecoder_getMinimumStride; # introduced=30
AImageDecoder_decodeImage; # introduced=30
AImageDecoder_setTargetSize; # introduced=30
AImageDecoder_computeSampledSize; # introduced=30
AImageDecoder_setCrop; # introduced=30
AImageDecoderHeaderInfo_getWidth; # introduced=30
AImageDecoderHeaderInfo_getHeight; # introduced=30