Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
Merge branch '1.2.1-development'
Browse files Browse the repository at this point in the history
* 1.2.1-development:
  Bump version
  Update source to match Xcode 6.0 beta 3
  Remove CFRelease() calls
  Remove info.plist files from targets
  Bump version
  • Loading branch information
bahlo committed Jul 13, 2014
2 parents 2fbb73f + 34e185e commit 3b0193a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
4 changes: 0 additions & 4 deletions SwiftGif.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
1419B389194EFBFD005DF6D0 /* adventure-time.gif in Resources */ = {isa = PBXBuildFile; fileRef = 1419B37F194EFBFD005DF6D0 /* adventure-time.gif */; };
1419B38A194EFBFD005DF6D0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1419B380194EFBFD005DF6D0 /* AppDelegate.swift */; };
1419B38B194EFBFD005DF6D0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1419B381194EFBFD005DF6D0 /* Images.xcassets */; };
1419B38C194EFBFD005DF6D0 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1419B382194EFBFD005DF6D0 /* Info.plist */; };
1419B38D194EFBFD005DF6D0 /* jeremy.gif in Resources */ = {isa = PBXBuildFile; fileRef = 1419B383194EFBFD005DF6D0 /* jeremy.gif */; };
1419B38E194EFBFD005DF6D0 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1419B384194EFBFD005DF6D0 /* RootViewController.swift */; };
1419B38F194EFC11005DF6D0 /* GifTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1419B378194EFBE7005DF6D0 /* GifTests.swift */; };
1419B390194EFC15005DF6D0 /* test.gif in Resources */ = {isa = PBXBuildFile; fileRef = 1419B379194EFBE7005DF6D0 /* test.gif */; };
1482D738194EFC940038192B /* test.gif in Resources */ = {isa = PBXBuildFile; fileRef = 1419B379194EFBE7005DF6D0 /* test.gif */; };
1482D73A194EFCE00038192B /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1482D739194EFCE00038192B /* Info.plist */; };
1482D73B194EFCF10038192B /* UIImage+Gif.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1419B37D194EFBFD005DF6D0 /* UIImage+Gif.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -194,7 +192,6 @@
buildActionMask = 2147483647;
files = (
1482D738194EFC940038192B /* test.gif in Resources */,
1419B38C194EFBFD005DF6D0 /* Info.plist in Resources */,
1419B38D194EFBFD005DF6D0 /* jeremy.gif in Resources */,
1419B38B194EFBFD005DF6D0 /* Images.xcassets in Resources */,
1419B389194EFBFD005DF6D0 /* adventure-time.gif in Resources */,
Expand All @@ -205,7 +202,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1482D73A194EFCE00038192B /* Info.plist in Resources */,
1419B390194EFC15005DF6D0 /* test.gif in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
24 changes: 11 additions & 13 deletions SwiftGifCommon/UIImage+Gif.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ extension UIImage {
class func animatedImageWithData(data: NSData) -> UIImage? {
let source = CGImageSourceCreateWithData(data, nil).takeRetainedValue()
let image = UIImage.animatedImageWithSource(source)
// CFRelease(source) // We need to do this, because source is from type Unmanaged<CGImageSource>

return image
}
Expand All @@ -23,24 +22,23 @@ extension UIImage {
var delay = 0.1

// Get dictionaries
let cfProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil)
let properties: NSDictionary = cfProperties.takeRetainedValue() // Make NSDictionary
let cfProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil).takeRetainedValue()
let properties: NSDictionary = cfProperties // Make NSDictionary

var gifProperties : NSDictionary = properties[String(kCGImagePropertyGIFDictionary)] as NSDictionary

// Get delay time
var number : AnyObject! = gifProperties[String(kCGImagePropertyGIFUnclampedDelayTime)]
if number == nil || number.doubleValue == 0 {
if number.doubleValue == 0 {
number = gifProperties[String(kCGImagePropertyGIFDelayTime)]
}

delay = number as Double

if delay < 0.1 {
delay = 0.1 // Make sure, they're not too fast
delay = 0.1 // Make sure they're not too fast
}

// CFRelease(cfProperties)


return delay
}
Expand Down Expand Up @@ -94,11 +92,11 @@ extension UIImage {

class func animatedImageWithSource(source: CGImageSource) -> UIImage? {
let count = CGImageSourceGetCount(source)
var images = CGImageRef[]()
var delays = Int[]()
var images = [CGImageRef]()
var delays = [Int]()

// Fill arrays
for i in 0..count {
for i in 0..<count {
// Add image
images.append(CGImageSourceCreateImageAtIndex(source, i, nil).takeRetainedValue())

Expand All @@ -120,15 +118,15 @@ extension UIImage {

// Get frames
let gcd = gcdForArray(delays)
var frames = UIImage[]()
var frames = [UIImage]()

var frame: UIImage
var frameCount: Int
for i in 0..count {
for i in 0..<count {
frame = UIImage(CGImage: images[Int(i)])
frameCount = Int(delays[Int(i)] / gcd)

for j in 0..frameCount {
for j in 0..<frameCount {
frames.append(frame)
}
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftGifDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit 3b0193a

Please sign in to comment.