mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibGfx: Introduce ICC::Profile::create
This can be used to programmatically create ICC::Profile objects.
This commit is contained in:
parent
130a84d830
commit
8f415e7b21
2 changed files with 13 additions and 7 deletions
|
@ -1316,7 +1316,12 @@ ErrorOr<NonnullRefPtr<Profile>> Profile::try_load_from_externally_owned_memory(R
|
||||||
bytes = bytes.trim(header.on_disk_size);
|
bytes = bytes.trim(header.on_disk_size);
|
||||||
auto tag_table = TRY(read_tag_table(bytes));
|
auto tag_table = TRY(read_tag_table(bytes));
|
||||||
|
|
||||||
auto profile = TRY(try_make_ref_counted<Profile>(header, move(tag_table)));
|
return create(header, move(tag_table));
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<NonnullRefPtr<Profile>> Profile::create(ProfileHeader const& header, OrderedHashMap<TagSignature, NonnullRefPtr<TagData>> tag_table)
|
||||||
|
{
|
||||||
|
auto profile = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Profile(header, move(tag_table))));
|
||||||
|
|
||||||
TRY(profile->check_required_tags());
|
TRY(profile->check_required_tags());
|
||||||
TRY(profile->check_tag_types());
|
TRY(profile->check_tag_types());
|
||||||
|
|
|
@ -211,12 +211,7 @@ struct ProfileHeader {
|
||||||
class Profile : public RefCounted<Profile> {
|
class Profile : public RefCounted<Profile> {
|
||||||
public:
|
public:
|
||||||
static ErrorOr<NonnullRefPtr<Profile>> try_load_from_externally_owned_memory(ReadonlyBytes);
|
static ErrorOr<NonnullRefPtr<Profile>> try_load_from_externally_owned_memory(ReadonlyBytes);
|
||||||
|
static ErrorOr<NonnullRefPtr<Profile>> create(ProfileHeader const& header, OrderedHashMap<TagSignature, NonnullRefPtr<TagData>> tag_table);
|
||||||
Profile(ProfileHeader const& header, OrderedHashMap<TagSignature, NonnullRefPtr<TagData>> tag_table)
|
|
||||||
: m_header(header)
|
|
||||||
, m_tag_table(move(tag_table))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<PreferredCMMType> preferred_cmm_type() const { return m_header.preferred_cmm_type; }
|
Optional<PreferredCMMType> preferred_cmm_type() const { return m_header.preferred_cmm_type; }
|
||||||
Version version() const { return m_header.version; }
|
Version version() const { return m_header.version; }
|
||||||
|
@ -262,6 +257,12 @@ public:
|
||||||
bool is_v4() const { return version().major_version() == 4; }
|
bool is_v4() const { return version().major_version() == 4; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Profile(ProfileHeader const& header, OrderedHashMap<TagSignature, NonnullRefPtr<TagData>> tag_table)
|
||||||
|
: m_header(header)
|
||||||
|
, m_tag_table(move(tag_table))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<void> check_required_tags();
|
ErrorOr<void> check_required_tags();
|
||||||
ErrorOr<void> check_tag_types();
|
ErrorOr<void> check_tag_types();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue