-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
5,252 additions
and
5,521 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// NSData+PTEX.swift | ||
// PooTools_Example | ||
// | ||
// Created by 邓杰豪 on 6/12/22. | ||
// Copyright © 2022 crazypoo. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension NSData | ||
{ | ||
@objc func getImageDataType() -> PTAboutImageType { | ||
var c: UInt8 = 0 | ||
self.getBytes(&c, length: 1) | ||
switch c { | ||
case 0xff: | ||
return .JPEG | ||
case 0x89: | ||
return .PNG | ||
case 0x47: | ||
return .GIF | ||
case 0x49, 0x4d: | ||
return .TIFF | ||
case 0x52: | ||
if (self.count) < 12 { | ||
return .UNKNOW | ||
} | ||
var testString = NSString(data: self.subdata(with: NSMakeRange(0, 12)), encoding: NSASCIIStringEncoding) | ||
|
||
if testString?.hasPrefix("RIFF") ?? false && testString?.hasSuffix("WEBP") ?? false { | ||
return .WEBP | ||
} | ||
return .UNKNOW | ||
default: | ||
break | ||
} | ||
return .UNKNOW | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.