Move the image to data conversion to MP42Image

This commit is contained in:
Damiano Galassi committed 2024-07-18 11:26:52 +02:00
1 parent d2d3365d92
commit a83c7e8e79
2 files changed
+20 -24

No files matched your search

+14 -2
View File
@@ -32,9 +32,11 @@ MP42_OBJC_DIRECT_MEMBERS
- (instancetype)initWithImage:(NSImage *)image
{
if (self = [super init])
if (self = [super init]) {
_image = [image copy];
_type = MP42_ART_PNG;
}
return self;
}
@@ -92,6 +94,11 @@ MP42_OBJC_DIRECT_MEMBERS
} else if (_url) {
NSError *outError = nil;
_data = [NSData dataWithContentsOfURL:_url options:NSDataReadingUncached error:&outError];
} else if (_image) {
NSArray<NSImageRep *> *representations = _image.representations;
if (representations.count) {
_data = [NSBitmapImageRep representationOfImageRepsInArray:representations usingType:NSBitmapImageFileTypePNG properties:@{}];
}
}
}
@@ -111,6 +118,11 @@ MP42_OBJC_DIRECT_MEMBERS
return _image;
}
- (NSString *)debugDescription
{
return [NSString stringWithFormat:@"<%@: %p> type: %d", [self class], self, _type];
}
+ (BOOL)supportsSecureCoding
{
return YES;