如何在cocos2d-x中生成ccFPSImage.c文件

如何在cocos2d-x中生成ccFPSImage.c文件,cocos2d-x,libpng,Cocos2d X,Libpng,我在cocos2d-x库中发现了一个名为ccFPSImage.c的文件,它是FPS图像的十六进制格式数组。Cocos2D-x用于显示FPS 我只是想知道如何生成该文件 文件内容如下所示: unsigned char cc_fps_images_png[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x03,

我在cocos2d-x库中发现了一个名为ccFPSImage.c的文件,它是FPS图像的十六进制格式数组。Cocos2D-x用于显示FPS

我只是想知道如何生成该文件

文件内容如下所示:

unsigned char cc_fps_images_png[] = {
  0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
  0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x36,
  0x08, 0x06, 0x00, 0x00, 0x00, 0xa5, 0x74, 0xe8, 0xab, 0x00, 0x00, 0x0a,
  0x41, 0x69, 0x43, 0x43, 0x50, 0x49, 0x43, 0x43, 0x20, 0x50, 0x72, 0x6f,
  0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x48, 0x0d, 0x9d, 0x96, 0x77, 0x54,
  0x53, 0xd9, 0x16, 0x87, 0xcf, 0xbd, 0x37, 0xbd, 0xd0, 0x12, 0x22, 0x20,
.... (There are a lot of hex values here, I just omit them here)
}
我已经使用ImageMagick工具生成了.h文件,但当它加载时,它只是报告:

cocos2d: the file is not a dds file!
cocos3d: the file is not a ktx file!
Image WARNING: unsupport true color tga data pixel format. FILE: 
Fails: init fps_images
cocos2d: the file is not a dds file!
cocos3d: the file is not a ktx file!
Image WARNING: unsupport true color tga data pixel format. FILE: 
Fails: init fps_images
cocos2d: the file is not a dds file!
cocos3d: the file is not a ktx file!
Image WARNING: unsupport true color tga data pixel format. FILE: 
Fails: init fps_images
我使用以下命令生成.h文件:

convert fps.png h:->fps.h
有人知道如何生成有效的ccFPSImage.c文件吗


谢谢。

到目前为止,ImageMagick的转换文件h:file.h将创建包含GIF或PPM图像的头文件

ImageMagick版本6.9.1-10将支持一个新的-define h:format=PNG选项,该选项将创建您期望的文件

convert fps.png -define h:format=PNG -define png:exclude-chunks=all h:fps.h
-define png:exclude chunks=all将导致convert忽略包含创建/修改日期等不需要的辅助png块


通过-define h:format=JPG,也将支持JPEG输出。

任何数据/文件到.h转换器都可以执行此操作job@LearnCocos2D你能给我举个例子吗?我正在使用MacOSX。@非常感谢,我的问题解决了:@子龙山人 你能解释一下你是如何创建数组和加载图像的吗?