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

Commit 73ba53d8 authored by John Reck's avatar John Reck Committed by Automerger Merge Worker
Browse files

Merge "Implement encoding alpha8 gainmaps" into udc-dev am: 492ddfb5

parents fb405fa0 492ddfb5
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -2001,7 +2001,7 @@ public final class Bitmap implements Parcelable {
        checkPixelAccess(x, y);
        checkPixelAccess(x, y);


        final ColorSpace cs = getColorSpace();
        final ColorSpace cs = getColorSpace();
        if (cs.equals(ColorSpace.get(ColorSpace.Named.SRGB))) {
        if (cs == null || cs.equals(ColorSpace.get(ColorSpace.Named.SRGB))) {
            return Color.valueOf(nativeGetPixel(mNativePtr, x, y));
            return Color.valueOf(nativeGetPixel(mNativePtr, x, y));
        }
        }
        // The returned value is in kRGBA_F16_SkColorType, which is packed as
        // The returned value is in kRGBA_F16_SkColorType, which is packed as
+7 −0
Original line number Original line Diff line number Diff line
@@ -463,6 +463,13 @@ bool Bitmap::compress(JavaCompressFormat format, int32_t quality, SkWStream* str
    if (hasGainmap() && format == JavaCompressFormat::Jpeg) {
    if (hasGainmap() && format == JavaCompressFormat::Jpeg) {
        SkBitmap baseBitmap = getSkBitmap();
        SkBitmap baseBitmap = getSkBitmap();
        SkBitmap gainmapBitmap = gainmap()->bitmap->getSkBitmap();
        SkBitmap gainmapBitmap = gainmap()->bitmap->getSkBitmap();
        if (gainmapBitmap.colorType() == SkColorType::kAlpha_8_SkColorType) {
            SkBitmap greyGainmap;
            auto greyInfo = gainmapBitmap.info().makeColorType(SkColorType::kGray_8_SkColorType);
            greyGainmap.setInfo(greyInfo, gainmapBitmap.rowBytes());
            greyGainmap.setPixelRef(sk_ref_sp(gainmapBitmap.pixelRef()), 0, 0);
            gainmapBitmap = std::move(greyGainmap);
        }
        SkJpegEncoder::Options options{.fQuality = quality};
        SkJpegEncoder::Options options{.fQuality = quality};
        return SkJpegGainmapEncoder::EncodeHDRGM(stream, baseBitmap.pixmap(), options,
        return SkJpegGainmapEncoder::EncodeHDRGM(stream, baseBitmap.pixmap(), options,
                                                 gainmapBitmap.pixmap(), options, gainmap()->info);
                                                 gainmapBitmap.pixmap(), options, gainmap()->info);
+20 −14
Original line number Original line Diff line number Diff line
@@ -174,8 +174,14 @@ class GainmapImage(context: Context, attrs: AttributeSet?) : FrameLayout(context
        if (bitmap == null) return
        if (bitmap == null) return


        imageView.setImage(ImageSource.cachedBitmap(when (outputMode) {
        imageView.setImage(ImageSource.cachedBitmap(when (outputMode) {
            R.id.output_hdr -> { bitmap!!.gainmap = gainmap; bitmap!! }
            R.id.output_hdr -> {
            R.id.output_sdr -> { bitmap!!.gainmap = null; bitmap!! }
                bitmap!!.gainmap = gainmap; bitmap!!
            }

            R.id.output_sdr -> {
                bitmap!!.gainmap = null; bitmap!!
            }

            R.id.output_gainmap -> gainmapVisualizer!!
            R.id.output_gainmap -> gainmapVisualizer!!
            else -> throw IllegalStateException()
            else -> throw IllegalStateException()
        }))
        }))