Post

Replies

Boosts

Views

Activity

Reply to Is it possible to compile images into an APNG using Swift?
I was hoping to find a Swift-based solution but there seems to be none. For whatever reason, both the AFathi's GIF generator and my APNG adaptation of it simply doesn't work. I suspect it has something to do with the UTType mess after kUTType was deprecated in iOS 15. I went ahead and adapted the Obj-C solution by Radif Sharafullin at https://github.com/radif/MSSticker-Images. I've included the updated code that has been confirmed to be working with iOS 17.2 below. The code is, as far as I can tell, basically the same as the Swift code, so I'm baffled as to why the Swift version doesn't work. If anyone figures out why, please let us know here! I won't mark this thread as having an answer since my stop-gap solution isn't Swift-based: #import "mcbAnimatedImagePersister.h" #import <ImageIO/ImageIO.h> #import <MobileCoreServices/MobileCoreServices.h> #import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> @implementation mcbAnimatedImagePersister +(instancetype)shared{ static mcbAnimatedImagePersister * instance=nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance=mcbAnimatedImagePersister.new; }); return instance; } -(void)persistAnimatedImageSequenceGIF:(NSArray<UIImage *> *)images frameDelay:(CGFloat)frameDelay numberOfLoops:(NSInteger)numberOfLoops toURL:(NSURL *)toURL{ NSDictionary *fileProperties = @{ (__bridge id)kCGImagePropertyGIFDictionary: @{ (__bridge id) kCGImagePropertyGIFLoopCount: @(numberOfLoops), } }; NSDictionary *frameProperties = @{ (__bridge id)kCGImagePropertyGIFDictionary: @{ (__bridge id)kCGImagePropertyGIFDelayTime: @(frameDelay), } }; CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)toURL, (__bridge CFStringRef)UTTypeGIF.identifier, images.count, NULL); CGImageDestinationSetProperties(destination, (__bridge CFDictionaryRef)fileProperties); for (UIImage * image in images) { CGImageDestinationAddImage(destination, image.CGImage, (__bridge CFDictionaryRef)frameProperties); } if (!CGImageDestinationFinalize(destination)) { NSLog(@"failed to finalize image destination"); } CFRelease(destination); } -(void)persistAnimatedImageSequenceAPNG:(NSArray<UIImage *> *)images frameDelay:(CGFloat)frameDelay numberOfLoops:(NSInteger)numberOfLoops toURL:(NSURL *)toURL{ NSDictionary *fileProperties = @{ (__bridge id)kCGImagePropertyPNGDictionary: @{ (__bridge id)kCGImagePropertyAPNGLoopCount: @(numberOfLoops), } }; NSDictionary *frameProperties = @{ (__bridge id)kCGImagePropertyPNGDictionary: @{ (__bridge id)kCGImagePropertyAPNGDelayTime: @(frameDelay), } }; CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)toURL, (__bridge CFStringRef)UTTypePNG.identifier, images.count, NULL); CGImageDestinationSetProperties(destination, (__bridge CFDictionaryRef)fileProperties); for (UIImage * image in images) { CGImageDestinationAddImage(destination, image.CGImage, (__bridge CFDictionaryRef)frameProperties); } if (!CGImageDestinationFinalize(destination)) { NSLog(@"failed to finalize image destination"); } CFRelease(destination); } @end
Topic: Media Technologies SubTopic: General Tags:
Dec ’23
Reply to How do I implement low-latency streaming between two local iOS devices?
Edit: @Eskimo Err come to think about it I should ask for one clarification regarding APs not forwarding STA-to-STA traffic before I burn myself: In your previous response you were ambiguous about the device brand, probably due to all the Peer-to-Peer Wi-Fi specifications out there. My use case is only between Apple products. Period. Does the phenomenon of some APs not forwarding STA-to-STA traffic apply to iPhone Hotspots talking with iPhones or iPads or Macs? E.g. Can an iPhone hosting a Hotspot Connection (being both AP and STA) and the iPhone being hosted (the pure STA) communicate with each other (e.g. cross streaming videos)? I did a double take and came back to ask because this is critical to me.
Feb ’22
Reply to Is it possible to compile images into an APNG using Swift?
I was hoping to find a Swift-based solution but there seems to be none. For whatever reason, both the AFathi's GIF generator and my APNG adaptation of it simply doesn't work. I suspect it has something to do with the UTType mess after kUTType was deprecated in iOS 15. I went ahead and adapted the Obj-C solution by Radif Sharafullin at https://github.com/radif/MSSticker-Images. I've included the updated code that has been confirmed to be working with iOS 17.2 below. The code is, as far as I can tell, basically the same as the Swift code, so I'm baffled as to why the Swift version doesn't work. If anyone figures out why, please let us know here! I won't mark this thread as having an answer since my stop-gap solution isn't Swift-based: #import "mcbAnimatedImagePersister.h" #import <ImageIO/ImageIO.h> #import <MobileCoreServices/MobileCoreServices.h> #import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> @implementation mcbAnimatedImagePersister +(instancetype)shared{ static mcbAnimatedImagePersister * instance=nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance=mcbAnimatedImagePersister.new; }); return instance; } -(void)persistAnimatedImageSequenceGIF:(NSArray<UIImage *> *)images frameDelay:(CGFloat)frameDelay numberOfLoops:(NSInteger)numberOfLoops toURL:(NSURL *)toURL{ NSDictionary *fileProperties = @{ (__bridge id)kCGImagePropertyGIFDictionary: @{ (__bridge id) kCGImagePropertyGIFLoopCount: @(numberOfLoops), } }; NSDictionary *frameProperties = @{ (__bridge id)kCGImagePropertyGIFDictionary: @{ (__bridge id)kCGImagePropertyGIFDelayTime: @(frameDelay), } }; CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)toURL, (__bridge CFStringRef)UTTypeGIF.identifier, images.count, NULL); CGImageDestinationSetProperties(destination, (__bridge CFDictionaryRef)fileProperties); for (UIImage * image in images) { CGImageDestinationAddImage(destination, image.CGImage, (__bridge CFDictionaryRef)frameProperties); } if (!CGImageDestinationFinalize(destination)) { NSLog(@"failed to finalize image destination"); } CFRelease(destination); } -(void)persistAnimatedImageSequenceAPNG:(NSArray<UIImage *> *)images frameDelay:(CGFloat)frameDelay numberOfLoops:(NSInteger)numberOfLoops toURL:(NSURL *)toURL{ NSDictionary *fileProperties = @{ (__bridge id)kCGImagePropertyPNGDictionary: @{ (__bridge id)kCGImagePropertyAPNGLoopCount: @(numberOfLoops), } }; NSDictionary *frameProperties = @{ (__bridge id)kCGImagePropertyPNGDictionary: @{ (__bridge id)kCGImagePropertyAPNGDelayTime: @(frameDelay), } }; CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)toURL, (__bridge CFStringRef)UTTypePNG.identifier, images.count, NULL); CGImageDestinationSetProperties(destination, (__bridge CFDictionaryRef)fileProperties); for (UIImage * image in images) { CGImageDestinationAddImage(destination, image.CGImage, (__bridge CFDictionaryRef)frameProperties); } if (!CGImageDestinationFinalize(destination)) { NSLog(@"failed to finalize image destination"); } CFRelease(destination); } @end
Topic: Media Technologies SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to How to display sprites in RealityKit?
A partial answer can be found in the following sample code: Implementing Special Rendering Effects with RealityKit Postprocessing This sort of solves my problem, but doesn't change the fact that I'm still depending on SpriteKit to render my 2D content.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to How to limit RealityKit's framerate?
The following sample code shows how to implement SpriteKit within RealityKit: Implementing Special Rendering Effects with RealityKit Postprocessing RealityKit will still be running at 60 FPS, but the SpriteKit View's framerate should be adjustable.
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to How do I implement low-latency streaming between two local iOS devices?
Edit: @Eskimo Err come to think about it I should ask for one clarification regarding APs not forwarding STA-to-STA traffic before I burn myself: In your previous response you were ambiguous about the device brand, probably due to all the Peer-to-Peer Wi-Fi specifications out there. My use case is only between Apple products. Period. Does the phenomenon of some APs not forwarding STA-to-STA traffic apply to iPhone Hotspots talking with iPhones or iPads or Macs? E.g. Can an iPhone hosting a Hotspot Connection (being both AP and STA) and the iPhone being hosted (the pure STA) communicate with each other (e.g. cross streaming videos)? I did a double take and came back to ask because this is critical to me.
Replies
Boosts
Views
Activity
Feb ’22