Merge "Implement encoding alpha8 gainmaps" into udc-dev
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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()
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user