新手求标准C的BMP 转 JPEG的代码,谢谢

sncel 2004-09-09 09:15:42
如题
...全文
317 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
maxcode 2004-09-09
  • 打赏
  • 举报
回复
http://www.catenary.com/download/vic5e.html
这里有库vic不过是试用版的
maxcode 2004-09-09
  • 打赏
  • 举报
回复
这里有一个例子,不过得有库:Victor Image Processing Library
BMP to JPEG - the C Source Code
Requires Victor Image Processing Library v 4.25 or higher.
int bmp2jpeg(char far *src_fname, char far *des_fname)
{
imgdes tmpimage;
int rcode, quality=75, vbitcount;
BITMAPINFOHEADER bdat; // Reserve space for BMP struct

// Get info on the file we're to load
rcode = bmpinfo(src_fname, &bdat);
if(rcode != NO_ERROR) {
return(rcode);
}

vbitcount = bdat.biBitCount;
if(vbitcount >= 16) // 16-, 24-, or 32-bit image is loaded into 24-bit buffer
vbitcount = 24;

// Allocate space for an image
rcode = allocimage(&tmpimage, (int)bdat.biWidth, (int)bdat.biHeight, vbitcount);
if(rcode != NO_ERROR) {
return(rcode);
}

// Load image
rcode = loadbmp(src_fname, &tmpimage);
if(rcode != NO_ERROR) {
freeimage(&tmpimage); // Free image on error
return(rcode);
}


if(vbitcount == 1) { // If we loaded a 1-bit image, convert to 8-bit grayscale
// because jpeg only supports 8-bit grayscale or 24-bit color images
imgdes tmp2image;

rcode = allocimage(&tmp2image, (int)bdat.biWidth, (int)bdat.biHeight, 8);
if(rcode == NO_ERROR) {
convert1bitto8bit(&tmpimage, &tmp2image);
freeimage(&tmpimage); // Replace 1-bit image with grayscale image
copyimgdes(&tmp2image, &tmpimage);
}
}

// Save image
rcode = savejpg(des_fname, &tmpimage, quality);

freeimage(&tmpimage);
return(rcode);
}

Squall1009 2004-09-09
  • 打赏
  • 举报
回复
www.google.com
好象比较快^^
wwwooowww 2004-09-09
  • 打赏
  • 举报
回复
楼主一出道,就做这么复杂的东西,真是志向博大呀,自愧弗如。
积木 2004-09-09
  • 打赏
  • 举报
回复
这个玩意儿我做了一个月~ 呜呜,可能是我很菜吧
从BMP的格式到JPEG的各种tag,然后还有各种编码变换(就有要命的离散余弦变换)
当然还有行程编码,Huffman编码,呵呵,反正是多多了,不过csdn上有几个代码
你可以参考一下。
http://dev.csdn.net/develop/article/22/22948.shtm
http://dev.csdn.net/develop/article/1/1940.shtm
不过第一篇文章里面的代码有一点小bug,呵呵,转换一次再转换第二次就不好使了
也不知道是不是作者特意的,实际上就是落了两个语句而已,ft。
hongfeeling 2004-09-09
  • 打赏
  • 举报
回复
确实是 比较 浩大的一个工程
JPEG2000和以前的压缩原理也是不样的。
我以前找过JPEG2000标准的详细描述文档,楼主要是找到了,给我留个言。
nicknide 2004-09-09
  • 打赏
  • 举报
回复
楼主数学很鸟吗?傅立叶卷积知道吗?数据性号分析也需要使用……我数学菜,闪了……
junmayang 2004-09-09
  • 打赏
  • 举报
回复
kao,楼主想自己写一个JPEG库?
sncel 2004-09-09
  • 打赏
  • 举报
回复
有没有不需要库的啊.

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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