开发者

Cocoa resize NSImage while preserving animation

开发者 https://www.devze.com 2023-02-15 20:03 出处:网络
is there a way to resize a NSImage (animated gif) and preserve the animation? I want to make the animated gif with 512x256px size, fit a rect of 256x256px.

is there a way to resize a NSImage (animated gif) and preserve the animation? I want to make the animated gif with 512x256px size, fit a rect of 256x256px.

[newImage lockFocus];

[animatedGif drawInRect:newRect
        fromRect:NSMakeRect(0.0f, 0.0f, self.size.width, self.size.height)
        operation:NSCompositeCopy
        fraction:1.0f];开发者_JAVA百科

[newImage unlockFocus];


I would save the first picture of the animated gif. When you are going to resize the NSImage, just draw the first image of the animation.

I hope I understood your question correctly.


perhaps you can animate it manually with a timer which shows every 0.1 second another frame?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号