Move the image to data conversion to MP42Image
This commit is contained in:
2 files changed
+20
-24
No files matched your search
+14
-2
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user