位图写入字符串insted的FILE *或XImage来PNG [英] Writing Bitmap to string insted of FILE* or XImage to PNG
本文介绍了位图写入字符串insted的FILE *或XImage来PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将我的code为位图的输出XImage,但输出的文件是巨大的,所以我想到了COM $ P $使用lzrw pssing它
我用这个code写的位图到文件
i converted the output XImage of my code to Bitmap, but the output file is massive, so i thought about compressing it using lzrw i use this code to write the bitmap to file
fwrite(&bmpFileHeader, sizeof(bmpFileHeader), 1, fp);
fwrite(&bmpInfoHeader, sizeof(bmpInfoHeader), 1, fp);
fwrite(pImage->data, 4*pImage->width*pImage->height, 1, fp);
有反正我可以写一个(字符*)insted的(FILE *),所以我可以用它lzrw COM pression?
甚至更好,一些方式来XImage转换成PNG直接...
is there anyway i could write it to a (char *) insted of (FILE *) so i can use lzrw compression on it? or even better, some way to convert the XImage to PNG directly...
感谢;
推荐答案
使用的memcpy
而不是 FWRITE
char* tmp = buf;
memcpy(tmp, &bmpFileHeader, sizeof(bmpFileHeader));
tmp += sizeof(bmpFileHeader);
memcpy(tmp, &bmpInfoHeader, sizeof(bmpInfoHeader));
tmp += sizeof(bmpInfoHeader);
memcpy(tmp, pImage->data, 4*pImage->width*pImage->height);
编辑:我更新code,thaks @bdk您指出
I update code, thaks @bdk for pointing out
这篇关于位图写入字符串insted的FILE *或XImage来PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文