Click here to Skip to main content
15,886,780 members
Articles / Desktop Programming / MFC
Article

Classes to read and write BMP, JPEG and JPEG 2000

Rate me:
Please Sign up or sign in to vote.
4.49/5 (58 votes)
1 Feb 20031 min read 2.2M   22.6K   92   74
Classes to read and write BMP, JPEG and JPEG 2000

Introduction

This sample is an MFC application using the document/view architecture that can load, display and transcode files such as BMP (bitmap), JPEG, JPP (my private format using jpeg algorithm but with fewer overheads), jpc (jpeg 2000 code stream) and jp2 (jpeg 2000 format). It shows:

  1. Two classes, CMiniJpegEncoder and CMiniJpegDecoder, to support .jpp format. JPP is my private format using jpeg algorithm but with few overheads. These two classes are made in 2001 for one application that compress, transmit, and decompress PC screen image. Someone might ask, we have a jpeg format, so what is the JPP format for? The answer is, the jpeg format is a little complex and may have a 600-byte fileheader. So I made a 6-byte header format called .jpp. Also, no FF markers are needed for .jpp. With simple format of .jpp, you could clearly watch the jpeg algorithm, that would be useful to someone learning jpeg.
  2. Two classes, CTonyJpegEncoder and CTonyJpegDecoder, to support baseline jpeg format. I have no time to support other formats such as progressive + Huffman coding. It works for almost jpeg files, just with one-thousand-line codes! But if you want powerful functionality, please use IJG code. In this demo, you could choose the jpeg codec.
  3. To show the capability of JPEG-2000, by Jasper implementation.

Contact

If you have any question, or any comments, please contact me: lintong@cis.pku.edu.cn.

History

  • 1 Feb, 2003 - First revision.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
Dr. Tony Lin, received his PhD degree from Peking University, Beijing, China, in 2001. His interests are in Pattern Recognition, Wavelets, and Programming.

Comments and Discussions

 
QuestionI use TonyJpegLib at Screen Capture Tool Pin
player.5-Jun-20 4:03
player.5-Jun-20 4:03 
Question你能发给我一份技术规范文档吗 Pin
surenyufu14-May-13 14:59
surenyufu14-May-13 14:59 
QuestionHow to build the program ? Pin
vhmau30-Aug-12 23:32
vhmau30-Aug-12 23:32 
AnswerRe: How to build the program ? Pin
surenyufu11-May-13 23:24
surenyufu11-May-13 23:24 
GeneralMy vote of 5 Pin
hoummass10-Mar-11 12:20
hoummass10-Mar-11 12:20 
QuestionWhere "J2kDll.dll" comes from? Pin
ZexinDing15-Sep-09 17:30
ZexinDing15-Sep-09 17:30 
QuestionHow to run the program Pin
fayefu26-Jun-09 16:01
fayefu26-Jun-09 16:01 
Generalthank you Pin
futurejo5-Jan-09 19:32
futurejo5-Jan-09 19:32 
GeneralGreat Code, Crap Article! Pin
stevepqr24-Nov-08 0:35
stevepqr24-Nov-08 0:35 
GeneralSimply Incredible Pin
software_chotmail27-Sep-08 0:09
software_chotmail27-Sep-08 0:09 
QuestionHow to run the program Pin
Member 465780529-May-08 5:48
Member 465780529-May-08 5:48 
GeneralJpg decoder Pin
NIkhilesh Reddy15-Apr-08 1:22
NIkhilesh Reddy15-Apr-08 1:22 
GeneralThe Lib fails to decode some images Pin
Silvio Reis24-Jan-08 1:17
Silvio Reis24-Jan-08 1:17 
QuestionImageTranscode Pin
dejavu13-Dec-07 20:31
dejavu13-Dec-07 20:31 
Questionhow to reduce memory usage while loading background image in MFC Application? Pin
Khathar8-Aug-07 20:45
Khathar8-Aug-07 20:45 
GeneralBad quality on Jpeg image Pin
davidlks11-Jul-07 22:35
davidlks11-Jul-07 22:35 
Questiontroubles with CminiJpegEncoder/decoder Pin
patkarbo20-Jun-07 8:41
patkarbo20-Jun-07 8:41 
Generaljpeg progressive Pin
edatul muliana20-May-07 21:06
edatul muliana20-May-07 21:06 
GeneralMotion Pin
MrPMorris6-Mar-07 5:49
MrPMorris6-Mar-07 5:49 
GeneralFixed marker problem Pin
LukeMulder2-Oct-06 2:30
LukeMulder2-Oct-06 2:30 
Hi,

i use our Jpeg - Lib and found a small bug.
If you decode an image it is allowed than am 0xFF marker
may be followed by additional 0xFF marker.

The following code will fix this issue. May you want to update your CodeProject site...

int CTonyJpegDecoder::ReadOneMarker(void)
{
if( INPUT_BYTE(m_pData) != 255 )
return -1;
int marker;
do
{
marker = INPUT_BYTE(m_pData);
} while (marker == 255); return marker;
}

Mr. Mulder
General16 bits color cannot encoder Pin
mba66-Sep-06 0:35
mba66-Sep-06 0:35 
Generalcontrast tiff Pin
HoangManh3-Jun-06 16:08
HoangManh3-Jun-06 16:08 
GeneralImageTranscode Pin
Adi DEDIC23-May-06 0:02
Adi DEDIC23-May-06 0:02 
GeneralNeed JPEG Decoder Pin
kiran_siva13-Mar-06 19:00
kiran_siva13-Mar-06 19:00 
GeneralRe: Need JPEG Decoder Pin
AghaKhan22-Apr-06 20:38
AghaKhan22-Apr-06 20:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.