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

+6 -22
View File
@@ -1102,36 +1102,20 @@
NSArray<MP42MetadataItem *> *artworks = [self metadataItemsFilteredByIdentifier:MP42MetadataKeyCoverArt];
for (uint32_t i = 0; i < artworks.count; i++) {
MP42Image *artwork;
MP4TagArtwork newArtwork;
artwork = (MP42Image *)artworks[i].value;
MP42Image *artwork = (MP42Image *)artworks[i].value;
if (artwork.data && artwork.data.length < UINT32_MAX) {
MP4TagArtwork newArtwork;
newArtwork.data = (void *)artwork.data.bytes;
newArtwork.size = (uint32_t)artwork.data.length;
newArtwork.type = (MP4TagArtworkType)artwork.type;
}
else {
NSArray<NSImageRep *> *representations = artwork.image.representations;
if (representations.count) {
NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations
usingType:NSBitmapImageFileTypePNG properties:@{}];
if (bitmapData && bitmapData.length < UINT32_MAX) {
newArtwork.data = (void *)bitmapData.bytes;
newArtwork.size = (uint32_t)bitmapData.length;
newArtwork.type = MP4_ART_PNG;
}
if (tags->artworkCount > i) {
MP4TagsSetArtwork(tags, i, &newArtwork);
} else {
MP4TagsAddArtwork(tags, &newArtwork);
}
}
if (tags->artworkCount > i) {
MP4TagsSetArtwork(tags, i, &newArtwork);
} else {
MP4TagsAddArtwork(tags, &newArtwork);
}
}
}