diff options
-rw-r--r-- | core/jni/android/graphics/BitmapFactory.cpp | 19 | ||||
-rw-r--r-- | tools/aapt/Images.cpp | 16 |
2 files changed, 11 insertions, 24 deletions
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index d8ec22a0f697..92f781268732 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -260,6 +260,15 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding return nullObjectReturn("SkAndroidCodec::NewFromStream returned null"); } + // Do not allow ninepatch decodes to 565. In the past, decodes to 565 + // would dither, and we do not want to pre-dither ninepatches, since we + // know that they will be stretched. We no longer dither 565 decodes, + // but we continue to prevent ninepatches from decoding to 565, in order + // to maintain the old behavior. + if (peeker.mPatch && kRGB_565_SkColorType == prefColorType) { + prefColorType = kN32_SkColorType; + } + // Determine the output size and return if the client only wants the size. SkISize size = codec->getSampledDimensions(sampleSize); if (options != NULL) { @@ -369,15 +378,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding case SkCodec::kIncompleteInput: break; default: - return nullObjectReturn("codec->getAndoridPixels() failed."); - } - - // Some images may initially report that they have alpha due to the format - // of the encoded data, but then never use any colors which have alpha - // less than 100%. Here we check if the image really had alpha, and - // mark it as opaque if it is actually opaque. - if (kOpaque_SkAlphaType != alphaType && !codec->reallyHasAlpha()) { - decodingBitmap.setAlphaType(kOpaque_SkAlphaType); + return nullObjectReturn("codec->getAndroidPixels() failed."); } int scaledWidth = size.width(); diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index e4738f5eda7d..5ad337949bee 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -1095,13 +1095,6 @@ static void write_png(const char* imageName, analyze_image(imageName, imageInfo, grayscaleTolerance, rgbPalette, alphaPalette, &paletteEntries, &hasTransparency, &color_type, outRows); - // If the image is a 9-patch, we need to preserve it as a ARGB file to make - // sure the pixels will not be pre-dithered/clamped until we decide they are - if (imageInfo.is9Patch && (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)) { - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - } - if (kIsDebug) { switch (color_type) { case PNG_COLOR_TYPE_PALETTE: @@ -1180,18 +1173,11 @@ static void write_png(const char* imageName, } for (int i = 0; i < chunk_count; i++) { - unknowns[i].location = PNG_HAVE_PLTE; + unknowns[i].location = PNG_HAVE_IHDR; } png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS, chunk_names, chunk_count); png_set_unknown_chunks(write_ptr, write_info, unknowns, chunk_count); -#if PNG_LIBPNG_VER < 10600 - /* Deal with unknown chunk location bug in 1.5.x and earlier */ - png_set_unknown_chunk_location(write_ptr, write_info, 0, PNG_HAVE_PLTE); - if (imageInfo.haveLayoutBounds) { - png_set_unknown_chunk_location(write_ptr, write_info, 1, PNG_HAVE_PLTE); - } -#endif } |