Write a DIB to a JPEG File (BMP2JPG)

To get jpeg.lib:

1) Go to Ulrich von Zadow's  "Class library for image file decoding" article, and click on the "Links" link.

2) Click on the "LIBJPEG ver 6b" link to download the "vanilla" libjpeg.

3) Do not use Mr. von Zadow's "Paintlib" version of libjpeg, because he seems to have made some internal changes for his own use.

The jpeg.lib project (LibJpeg) is set up to compile under numerous operating systems. The download includes a file called install.doc. Read the sections relevant to VC++/Windows. You have to rename a couple of files, etc.

The first time I installed and compiled libjpeg, it took a long time and was very aggravating. I then re-read the instructions, and it took about fifteen minutes. I'm sure there's a lesson here...

Testing Notes:

To test the code, I used MS Paint to create bitmap files in the four supported formats.

I then set up a VC++ project which read the bitmap files, and used the functions below to turn them into JPEG files (.jpg).

I then used Julian Smart's CImage demo application to display them.

I also used Internet Explorer as well as MS Word to display them.

I also created a jpeg file by loading an internal resource (see the example below). The largest bitmap file I dealt with was about 390 KB.

Error trapping:

libjpeg includes a number of provisions for improving error detection, and reporting them in a good manner. I have not investigated these, and the code does not include any of them. Right now, an internal error will simply cause the code to stop cold.

To get at jpeg.lib properly in your project:
  1. Under tools->options, directories tab:
    1. Set the Include Files to include the path to your jpeg.lib project
    2. Set the Library Files to include the path to your jpeg.lib release directory
  2. Under Project->Settings, Link tab:
    1. Add jpeg.lib to the Object/library modules list
Note on Quality Settings:

For the IDB_TEST resource, I tried two quality settings: 10 and 100. At "10", the image had a lot of black spottiness, and took up 1 KB. At "100" the image looked very good, and took up 4 KB.

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值