iOS上的PNG验证 [英] PNG validation on iOS

查看:145
本文介绍了iOS上的PNG验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS上编写地图应用程序,使用OpenStreetMap图块。
地图图块图像以异步方式下载并存储在字典中,或者保存在SQLite DB中。

Writing a mapping application on iOS, making use of OpenStreetMap tiles. Map tile images are downloaded asynchronously and stored in a dictionary, or persisted in a SQLite DB.

有时,无论出于何种原因,在尝试渲染地图时平铺图像,我收到以下错误:

ImageIO:< ERROR> PNGinvalid距离太远

Occasionally, for whatever reason, while attempting to render a map tile image, I get the following error:
ImageIO: <ERROR> PNGinvalid distance too far back

这会导致令人讨厌的黑色方块出现在我的地图上。

This causes nasty black squares to appear over my map.

这是发生这种情况的代码:

This is the piece of code in which this occurs:

NSData *imageData = [TileDownloader RetrieveDataAtTileX:(int)tilex Y:(int)tiley Zoom:(int)zoomLevel];  
if (imageData != nil) {
    NSLog(@"Obtained image data\n");
    UIImage *img = [[UIImage imageWithData:imageData] retain];
    // Perform the image render on the current UI context.  
    // ERROR OCCURS BETWEEN PUSH AND POP
    UIGraphicsPushContext(context);
    [img drawInRect:[self rectForMapRect:mapRect] blendMode:kCGBlendModeNormal alpha:1.0f];
    UIGraphicsPopContext();
    [img release];
}

现在,我正在寻找的方法是确保png是在尝试将其渲染到我的地图之前有效。

Now, what I'm looking for is a way to ensure a png is valid before attempting to render it to my map.

编辑:系统偶尔会抛出此错误:

ImageIO:< ERROR> PNGIDAT:CRC错误

The system also occasionally throws this error:
ImageIO: <ERROR> PNGIDAT: CRC error

推荐答案

从我自己的异步下载队列管理器切换到All Seeing I实现。问题变得没有实际意义。

Switched from my own Asynchronous Download Queue Manager to the All Seeing I implementation. Problem became a moot point.

这篇关于iOS上的PNG验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆