Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iPhone项目中使用libpng的问题_Iphone_Xcode_Libpng - Fatal编程技术网

在iPhone项目中使用libpng的问题

在iPhone项目中使用libpng的问题,iphone,xcode,libpng,Iphone,Xcode,Libpng,我正在尝试将libpng添加到我的iPhone项目中 我将.c和.h文件复制到它们自己的目录“thirdparty/libpng/”中,并将png.h包含在我的纹理类中: #ifndef PNG_H #include "thirdparty/libpng/png.h" #endif 此时,我的项目编译得非常好,没有任何警告和错误 接下来,我尝试添加一个函数来检查纹理是否是png,我在png\u sig\u cmp上得到一个编译错误,即使包括png.h: #define PNG_BYTE

我正在尝试将libpng添加到我的iPhone项目中

我将.c和.h文件复制到它们自己的目录“thirdparty/libpng/”中,并将png.h包含在我的纹理类中:

#ifndef PNG_H
    #include "thirdparty/libpng/png.h"
#endif
此时,我的项目编译得非常好,没有任何警告和错误

接下来,我尝试添加一个函数来检查纹理是否是png,我在png\u sig\u cmp上得到一个编译错误,即使包括png.h:

#define PNG_BYTES_TO_CHECK 4
int GETexture::CheckIfValidPNGTexture( const char* pTextureName, FILE **ppFp )
{
    char buf[PNG_BYTES_TO_CHECK];

    /* Open the prospective PNG file. */
    if ((*ppFp = fopen(pTextureName, "rb")) == NULL)
        return 0;

    /* Read in some of the signature bytes */
    if (fread(buf, 1, PNG_BYTES_TO_CHECK, *ppFp) != PNG_BYTES_TO_CHECK)
        return 0;

    /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
     Return nonzero (true) if they match */

    return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); // <- COMPILE ERROR

}
#定义PNG字节到检查4
int GETexture::checkifvalidpingTexture(常量字符*pTextureName,文件**ppFp)
{
char buf[PNG_BYTES_TO_CHECK];
/*打开PNG文件*/
if((*ppFp=fopen(pTextureName,“rb”))==NULL)
返回0;
/*读入一些签名字节*/
if(fread(buf,1,PNG字节到字节检查,*ppFp)!=PNG字节到字节检查)
返回0;
/*比较签名的第一个PNG字节与检查字节。
如果匹配,则返回非零(true)*/

return(!png_sig_cmp(buf,(png_size_t)0,png_BYTES_TO_CHECK));//我曾经遇到过完全相同的问题,帮助我的是简单的强制转换-因为如果查看png.h头文件,png_sig_cmp定义:

 png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)
第一个参数是png\u const\u bytep——定义如下:

PNG_CONST png_byte        FAR * png_const_bytep
这句话的意思是:

const unsigned char* 
我想用简单的打字:

return(!png_sig_cmp((png_const_bytep)buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
希望有帮助