浏览代码

add comments

cyberta 4 年之前
父节点
当前提交
2e8445a986
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      deltachat-ios/Helper/ImageFormat.swift

+ 6 - 0
deltachat-ios/Helper/ImageFormat.swift

@@ -7,6 +7,8 @@ enum ImageFormat: String {
 }
 }
 
 
 extension ImageFormat {
 extension ImageFormat {
+
+    // magic bytes can be found here: https://en.wikipedia.org/wiki/List_of_file_signatures
     static func get(from data: Data) -> ImageFormat {
     static func get(from data: Data) -> ImageFormat {
         switch data[0] {
         switch data[0] {
         case 0x89:
         case 0x89:
@@ -45,6 +47,10 @@ extension ImageFormat {
         return .unknown
         return .unknown
     }
     }
 
 
+
+    // Theoretically, SDAnimatedImage should be able to read data of all kinds of images.
+    // In practive, JPG files haven't been read correctly, for now we're using SDAnimatedImage
+    // only for file formats that support animated content.
     static func loadImageFrom(data: Data) -> UIImage? {
     static func loadImageFrom(data: Data) -> UIImage? {
         switch ImageFormat.get(from: data) {
         switch ImageFormat.get(from: data) {
         case .gif, .png, .webp, .heic:
         case .gif, .png, .webp, .heic: