在solaris 10中生成的图片文件在windows中打开后显示不正常

xlstc7 2008-01-18 09:34:14
用的第三方图形库是cximage或GD,同样的代码在windows下编译运行后生成的图片打开后能正常显示,可是在solaris 10下编译后运行生成的图片,拿到windows中打开后显示的却是一些乱七八糟的颜色,cximage和gd的源码都是直接从官方下的最新版本,测试gd时用的示例代码也是官方的。在另一个分论坛有人拿我的代码去他的环境中试,据说是可以在windows中正常显示的,不清楚他用的是什么系统,可能是linux吧。不清楚是不是跟solaris的环境或者别的什么什么有关。我的solaris没针对图形装过其它什么东西。

以下是GD的示例代码:

#include "gd.h"
#include "gdfontl.h"
#include <string.h>
#include <stdio.h>

int main(int argv, char** argc)
{
/* Declare the image */
gdImagePtr im;
/* Declare output files */
FILE *pngout, *jpegout;
/* Declare color indexes */
int black; int white;
/* Allocate the image: 64 pixels across by 64 pixels tall */

im = gdImageCreate(64, 64);
/* Allocate the color black (red, green and blue all minimum). Since this is the first color in a new image, it will be the background color. */
black = gdImageColorAllocate(im, 0, 0, 0);
/* Allocate the color white (red, green and blue all maximum). */
white = gdImageColorAllocate(im, 255, 255, 255);
/* Draw a line from the upper left to the lower right, using white color index. */
gdImageLine(im, 0, 0, 63, 63, white);
/* Open a file for writing. "wb" means "write binary", important under MSDOS, harmless under Unix. */
pngout = fopen("test.png", "wb");
/* Do the same for a JPEG-format file. */
jpegout = fopen("test.jpg", "wb");
/* Output the image to the disk file in PNG format. */
gdImagePng(im, pngout);
/* Output the same image in JPEG format, using the default JPEG quality setting. */
gdImageJpeg(im, jpegout, -1); /* Close the files. */
fclose(pngout);
fclose(jpegout);
/* Destroy the image in memory. */
gdImageDestroy(im);
}
...全文
186 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
UltraBejing 2008-05-01
  • 打赏
  • 举报
回复
我也想了解,谢谢LZ.

1,544

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 Solaris
社区管理员
  • Solaris
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧