<legend id='CmNUa'><style id='CmNUa'><dir id='CmNUa'><q id='CmNUa'></q></dir></style></legend>

    1. <tfoot id='CmNUa'></tfoot>
      • <bdo id='CmNUa'></bdo><ul id='CmNUa'></ul>

      <small id='CmNUa'></small><noframes id='CmNUa'>

      <i id='CmNUa'><tr id='CmNUa'><dt id='CmNUa'><q id='CmNUa'><span id='CmNUa'><b id='CmNUa'><form id='CmNUa'><ins id='CmNUa'></ins><ul id='CmNUa'></ul><sub id='CmNUa'></sub></form><legend id='CmNUa'></legend><bdo id='CmNUa'><pre id='CmNUa'><center id='CmNUa'></center></pre></bdo></b><th id='CmNUa'></th></span></q></dt></tr></i><div id='CmNUa'><tfoot id='CmNUa'></tfoot><dl id='CmNUa'><fieldset id='CmNUa'></fieldset></dl></div>

      ImageIO:&lt;错误&gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 -

      ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)

        <small id='TWKfi'></small><noframes id='TWKfi'>

            <bdo id='TWKfi'></bdo><ul id='TWKfi'></ul>
          • <i id='TWKfi'><tr id='TWKfi'><dt id='TWKfi'><q id='TWKfi'><span id='TWKfi'><b id='TWKfi'><form id='TWKfi'><ins id='TWKfi'></ins><ul id='TWKfi'></ul><sub id='TWKfi'></sub></form><legend id='TWKfi'></legend><bdo id='TWKfi'><pre id='TWKfi'><center id='TWKfi'></center></pre></bdo></b><th id='TWKfi'></th></span></q></dt></tr></i><div id='TWKfi'><tfoot id='TWKfi'></tfoot><dl id='TWKfi'><fieldset id='TWKfi'></fieldset></dl></div>
              <tbody id='TWKfi'></tbody>

            <tfoot id='TWKfi'></tfoot>
            <legend id='TWKfi'><style id='TWKfi'><dir id='TWKfi'><q id='TWKfi'></q></dir></style></legend>

                本文介绍了ImageIO:&lt;错误&gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我通过 HTTP 下载图像时收到此错误.我查看了 此处的答案,但即使是有效图像不要从函数返回 YES.

                I get this error by downloading an image by HTTP. I have looked at the answer here but even the valid images don't return YES from the function.

                还有其他想法吗?

                获取图像的代码很简单.这发生在后台线程中.

                The code to get the image is simple enough. This happens in a background thread.

                NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
                UIImage *image = [UIImage imageWithData:data];
                

                这是来自该线程的函数:

                This is the function from that thread:

                - (BOOL)isJPEGValid:(NSData *)jpeg {
                    if ([jpeg length] < 4) return NO;
                    const char * bytes = (const char *)[jpeg bytes];
                    if (bytes[0] != 0xFF || bytes[1] != 0xD8) return NO;
                    if (bytes[[jpeg length] - 2] != 0xFF || 
                            bytes[[jpeg length] - 1] != 0xD9) return NO;
                    return YES;
                }
                

                推荐答案

                使用无符号字符.然后比较应该可以工作.

                Use an unsigned char. Then comparing should work.

                const unsigned char * bytes = (const unsigned char *)[jpeg bytes];
                

                而不是

                const char * bytes = (const char *)[jpeg bytes];
                

                这篇关于ImageIO:&lt;错误&gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                EAAccessory/EASession teardown during background(EAAccessory/EASession 在后台拆除)
                Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                How to get indexPath.row of tableView which is currently being displayed?(如何获取当前正在显示的 tableView 的 indexPath.row?)
                Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                How to add and get the values from .plist in iOS(如何在 iOS 中从 .plist 添加和获取值)

                    <bdo id='d0M4q'></bdo><ul id='d0M4q'></ul>
                        <tbody id='d0M4q'></tbody>

                      <small id='d0M4q'></small><noframes id='d0M4q'>

                    • <i id='d0M4q'><tr id='d0M4q'><dt id='d0M4q'><q id='d0M4q'><span id='d0M4q'><b id='d0M4q'><form id='d0M4q'><ins id='d0M4q'></ins><ul id='d0M4q'></ul><sub id='d0M4q'></sub></form><legend id='d0M4q'></legend><bdo id='d0M4q'><pre id='d0M4q'><center id='d0M4q'></center></pre></bdo></b><th id='d0M4q'></th></span></q></dt></tr></i><div id='d0M4q'><tfoot id='d0M4q'></tfoot><dl id='d0M4q'><fieldset id='d0M4q'></fieldset></dl></div>
                      • <legend id='d0M4q'><style id='d0M4q'><dir id='d0M4q'><q id='d0M4q'></q></dir></style></legend>

                      • <tfoot id='d0M4q'></tfoot>