Icon-O-Matic: Save alpha of reference images

Change-Id: I821521c2f58052d70e9f27c7ffc9849095e540a0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6658
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Zardshard
2023-06-27 19:19:36 +00:00
committed by Adrien Destugues
parent d1e42115d0
commit 4ed150bdc3
+15 -1
View File
@@ -65,6 +65,7 @@ ReferenceImage::ReferenceImage(const ReferenceImage& other)
SetName(other.Name());
SetImage(bitmap);
SetTransform(other);
Style()->SetAlpha(other.Style()->Alpha());
}
@@ -92,7 +93,7 @@ ReferenceImage::Unarchive(BMessage* archive)
if (ret < B_OK)
return ret;
// read transformation
// transformation
const double* matrix;
ssize_t dataSize;
ret = archive->FindData("transformation", B_DOUBLE_TYPE,
@@ -103,11 +104,18 @@ ReferenceImage::Unarchive(BMessage* archive)
return B_BAD_VALUE;
LoadFrom(matrix);
// image
BBitmap* bitmap = dynamic_cast<BBitmap*>(BBitmap::Instantiate(archive));
if (bitmap == NULL)
return B_ERROR;
SetImage(bitmap);
// alpha
uint8 alpha;
if(archive->FindUInt8("alpha", &alpha) < B_OK)
alpha = 255;
Style()->SetAlpha(alpha);
return B_OK;
}
@@ -130,6 +138,12 @@ ReferenceImage::Archive(BMessage* into, bool deep) const
// image
ret = Style()->Bitmap()->Archive(into, deep);
if (ret < B_OK)
return ret;
// alpha
ret = into->AddUInt8("alpha", Style()->Alpha());
return ret;
}