为什么在iPhone或iPad设备上更改png格式 [英] Why does png format get changed when on iPhone or iPad Device

查看:548
本文介绍了为什么在iPhone或iPad设备上更改png格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对此感兴趣.我确实对它做了一些谷歌搜索,但是我们开始了.我有这个png文件.我要做的是将其安装在iPhone上,然后将其发送到Windows上的服务器应用程序.我用这样的东西:

Interesting one this. I did do a bit Googling on the it but here we go. I have this png file. What I want to do is have it on my iPhone and send it to a server application on Windows. I use something like this:

NSString *filePath = [[NSBundle mainBundle] pathForResource:IconFile ofType:@"png"]; 

NSData *icon = [[NSData alloc ] initWithContentsOfFile:filePath];             
NSLog(@"File path is %@",filePath);
NSLog(@" Bytes to send in Icon File %d",icon.length);

现在,当我在iPhone模拟器上时,此方法就可以正常工作.当我转到设备时,尽管png格式的大小会增加.例如,我有一个2514字节的字节,然后上升到2652字节.当我传输此文件时-Windows应用程序无法读取该文件.

Now this works just fine when I am on the iPhone simulator. When I go to the device though the png format grows in size. For example I had one that was 2514 bytes and went up to 2652 bytes. When I transmit this file - its not able to be read by the Windows app.

因此,我假设当png文件在资源包中被复制时-必须对其进行优化或进行其他操作.我可以通过将扩展名改为.txt来解决这个问题-然后文件不会改变.

So I assume that when a png file gets copied over in the resource bundle - it must get optimised or something. I can get round it by changing the extension to say .txt - then the file doesnt change.

有人知道为什么吗?并且您可以防止更改它,因为我宁愿保留正确的扩展名.我已经看到,当从iPhone中获取png格式时,需要对其进行转换,但是我不知道为什么在上载时会发生这种情况,并且在模拟器模式下无法使用.在iOS 5上同时发生在iPhone和iPad上.

Does anyone know why that is ? And can you prevent it being changed as I'd rather keep the correct extension. I have seen that png formats need to be converted when you get them from the iPhone but I dont know why this would happen when you upload one and it doesn't work in the simulator mode. Happens with both iPhone and iPad at iOS 5.

推荐答案

在构建设置中可以防止对png图像进行修改-在打包"下,有一个压缩PNG文件的选项:

The modifying of the png images can be prevented in the build settings - under Packaging there is an option to compress PNG files:

将此设置为NO应该可以解决您的问题.

Setting this to NO should solve your problem.

这篇关于为什么在iPhone或iPad设备上更改png格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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