2015-10-15 47 views

回答

2

JPEG Format包含several markers

的渐进标记是

\xFF\xC2 
\xFF\xDA 

如果您在文件中找到这些,那么你正在处理的渐进式JPEG。

2

在做了一些更多的研究之后,我发现了一些关于它可以在iOS中完成的更多信息。

继我在Technical Q&A QA1654 - Accessing image properties with ImageIO看我做了这样的:

//Example of progressive JPEG 
NSString *imageUrlStr = @"http://cetus.sakura.ne.jp/softlab/software/spibench/pic_22p.jpg"; 

CFURLRef url = (__bridge CFURLRef)[NSURL URLWithString:imageUrlStr]; 

CGImageSourceRef myImageSource = CGImageSourceCreateWithURL(url, NULL); 

CFDictionaryRef imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(myImageSource,0, NULL); 

的imagePropertiesDictionary字典看起来像这样的渐进式JPEG:

Printing description of imagePropertiesDictionary: 
{ 
    ColorModel = RGB; 
    Depth = 8; 
    PixelHeight = 1280; 
    PixelWidth = 1024; 
    "{JFIF}" =  { 
     DensityUnit = 0; 
     IsProgressive = 1; 
     JFIFVersion =   (
      1, 
      0, 
      1 
     ); 
     XDensity = 1; 
     YDensity = 1; 
    }; 
} 

IsProgressive = 1意味着它是一个渐进/隔行JPEG。你可以检查这样的值:

CFDictionaryRef JFIFDictionary = (CFDictionaryRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyJFIFDictionary); 

CFBooleanRef isProgressive = (CFBooleanRef)CFDictionaryGetValue(JFIFDictionary, kCGImagePropertyJFIFIsProgressive); 

if(isProgressive == kCFBooleanTrue) 
    NSLog(@"It's a progressive JPEG"); 
相关问题