Xcode - Animating with PNG sequence - ios

I have made an animation with After Effect and added it to my Xcode project as a PNG sequence. This leave me with a folder with 164 images, i am animating with a timer. How is that for the app performance? And could i add more animations like this without any problem?

if its images,
first get those images in an array
#IBOutlet weak var animatingImageView: UIImageView!
var imageList = [UIImage]()
now call function
func playAnimation() {
self.animatingImageView.animationImages = imageList
self.animatingImageView.animationDuration = 2.0
self.animatingImageView.startAnimating()
}
you can use
self.animatingImageView. animationRepeatCount
for repeat count,
and also, if you want to stop it after some time interval, do it with a timer, and on timer completion
self.animatingImageView.stopAnimating()
for better performance:
try using image of size close to the imageview
try using cached image
try making image opaque

Related

Take ARSCNView snapshot with subview

I am using ARSCNView.snapshot() to take a snapshot in my iOS app with a picture as a frame. The picture frame is a UIImageView which is a subview to the ARSCNView. However, I can only get the scene in the taken picture without the image. I also tried to use this method (https://stackoverflow.com/a/45346555/10057340) to render the ARSCNView as an image but I only got the image frame with a white background rather than the image frame with the camera scene. Can anyone suggest a way for doing this? Thanks!!
Below is how I used snaphot():
var frameImageView: UIImageView!
var sceneView: ARSCNView!
func takeSnapShot() {
frameImageView.image = UIImage(named:"frame")
frameImageView.ishidden = false
sceneView.addSubView(frameImageView)
UIImageWriteToSavedPhotosAlbum(sceneView.snapshot(), nil, nil. nil)
}
I don't fully understand what you are asking specifically but you might find this video from the WWDC 2017 useful: https://www.youtube.com/watch?v=eBt1p799L3Q
Check out the project they make at 18 min.

How to control multiple skeletal animations independently with SceneKit?

I am trying to control multiple skeletal animations at the same time with multiple inputs, each of which points to a different frame of an animation. Imagine the way you set weight for a morpher with setWeight(_:forTargetAt:), but with input as a frame which I want the animation to be in state of.
I achieved this for just one animation by doing something like
#IBOutlet weak var sceneView: SCNView!
var animationPlayer: SCNAnimationPlayer! = nil
override func viewDidLoad() {
super.viewDidLoad()
//add a node on the scene and give animationPlayer the node's animation player
animationPlayer.animation.usesSceneTimeBase = true
}
#IBAction func sliderChanged(_ sender: UISlider) {
sceneView.sceneTime = Double(sender.value) * animationPlayer.animation.duration
}
where a slider is put to change the sceneTime of sceneView. This could only work if the node has just one animation.
But what I want to achieve is controlling all the animations asynchronously but on one node. I cannot simply play with sceneTime because that will cause all the animations to be played on the same time base in sync.
Is there any way to play all the animations with different input time or any value that works as a pointer to a specific frame of the animation?
(e.g. at one point, first animation is playing the 5th frame while second is in state of 8th. At next frame of rendering, the first animation is playing 4th frame and the second is playing 12th frame.)
Thanks.

animate image once using SwiftGifOrigin swift4

I am trying to animate once using SwiftGifOrigin pod but it does not work, using .loadgif the image can animate unlimited times but I want to animate image once
image outlet
#IBOutlet weak var gifimage: UIImageView!
using this method image animate unlimited times
gifimage.loadGif(name: "1_splash1")
and using this method nothing happened it does not show any image
let animated_image = UIImage.gif(name: "1_splash1")
gifimage.animationImages = animated_image?.images
gifimage.animationDuration = (animated_image?.duration)!
gifimage.animationRepeatCount = 1
gifimage.startAnimating()

Loading UIImages for flip animation unbelievably slow

I am using the UIImageView animationImages property to display a small flipbook animation. That works fine, but loading 35 frames that is only ~200kb takes over 4 seconds on an iPhone 7. This is the code I am using to load the frames:
//start timer
var imgListArray = [UIImage]()
for countValue in 0...34 {
if let image = UIImage(named: "anim_\(countValue).jpg") {
imgListArray.append(image)
}
}
//end timer
self.imageView.animationImages = imgListArray
Given that I can load in a multi-megabyte image in less than a second, I just can't believe it takes so long to load in these little frames (pixel dimensions are 507x189). I have tried using 8-bit and 24-bit PNGs and JPEGs and they all take about the same amount of time.
If I don't append the images to the array it takes about the same amount of time, so the only thing that it can be is calling UIImage(named:).
Can anyone suggest a faster way to load these frames in or faster way to display a flip book animation?

Change filter intensity like brightness from 0 to 100 via slider control in gpuimage2 swift

I followed the example of changing filter intensity on video camera from GPUImage2 examples, I am trying to change the filter intensity on a static image with iOS slider control, but it's not changing the intensity.
#IBOutlet weak var renderView: RenderView!
var filterContrast:ContrastAdjustment!
#IBOutlet weak var sliderContrast: UISlider!
let inputImage = UIImage(named:"WID-small.jpg")!
var picture:PictureInput!
// setting dynamic observable property.
dynamic var filterValue = 3.0 {
didSet {
filterContrast.contrast = GLfloat(filterValue)
picture.processImage()
}
}
on viewDidLayoutSubviews
picture = PictureInput(image: inputImage)
filterContrast = ContrastAdjustment();
picture --> filterContrast --> renderView
filterValue = 3; // will call did set property and call processimage from it
on Slider Update
filterValue = Double(nm);
is there any thing wrong, with this approach?
Thanks
Every time your slider value changes, you're creating a new ContrastAdjustment filter instance and attaching it to the picture. Your old filter instance is still there, and the RenderView will ignore any inputs beyond the first one that goes into it. In fact, you should have been seeing warnings on the console telling you about that fact that you're adding too many inputs to the RenderView.
Instead of creating a whole new ContrastAdjustment filter each time, simply save your contrast filter as an instance variable and adjust its contrast property when the slider changes.

Resources