Click here to Skip to main content
15,113,057 members
Articles / Programming Languages / VBScript
Posted 20 May 2005


9 bookmarked

Easy Way of Displaying JPEG 2000 Images in VisualBasic

Rate me:
Please Sign up or sign in to vote.
2.31/5 (9 votes)
20 May 2005CPOL2 min read
An article on using ActiveX control to display JPEG 2000 images in your VisualBasic applications


The new millennium standard - JPEG2000 - has become more and more popular. It has many useful features and superior compression performance. Pictures, compressed with JPEG2000 are usually smaller, yet look better!

Unfortunately, there are almost no components or libraries that support VisualBasic. Most of them are aimed to C/C++ or Java. And writing your own JPEG2000 decoder completely in VisualBasic from scratch is, to put it mildly, impractical.

This article suggests an easy way to add JPEG2000 viewing capabilities to your VisualBasic application.


"JPEG2000 is a new image-encoding standard than provides high compression with image quality superior to all existing standard encoding techniques. This high compression and quality performance is due to the adaptation of wavelet transforms. Wavelet transforms are mathematical formulas that represent complex structures in the image, thereby compressing an extremely large amount of image data into a relatively small amount of compressed data. This compression technique allows applications to save compressed images with higher compression ratios and better image quality as compared to any other software currently in production".

Using the Code

Probably the easiest way to display JPEG 2000 images is to use a special ActiveX control, which will do all the work for you. First of all, you need to download it from here or use its stripped version from the demo project of this article.

Here I'll show how to make it work with minimal programming.

1. Register the Control

Execute the following command:

regsvr32.exe j2k-control.dll

To unregister the control, you need to use:

regsvr32.exe /u j2k-control.dll 

2. Add Component to your VB Toolbox

Right click on the toolbox, select "Components"

Image 1

and mark the "J2K_Control 1.0 Type Library" check-box:

Image 2

3. Place the Control on your Form

Using "J2" button,

Image 3

draw a rectangle on your form, where the images will be displayed. You should see a white area with "J2K-Control" text in the center.

4. Finally, a Little Coding

Assuming your form has Form1 name and the J2K-Control has J2K_Codec1 name, add the following 2 lines into the Form_Load():

Private Sub Form_Load()

    ' This method will load and decode J2K or JP2 file and display it
    ' in the control area

    J2K_Codec1.OpenFile "test.j2k"
    Form1.Caption = "J2K: " + CStr(J2K_Codec1.ImageWidth) + _
	"x" + CStr(J2K_Codec1.ImageHeight)

End Sub

That's it! I told you - it's easy. :)
Now you can try to run your application and you should see the test.j2k image (included in the demo project).

NOTE: This control is free for your own use, but if you want to distribute your application publicly, you will need to purchase it.
For more information - please visit


  • 20th May, 2005 - Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Alex Saveliev
Web Developer
Russian Federation Russian Federation
No Biography provided

Comments and Discussions

QuestionHas anyone heard from Alex? Pin
Leo Davidson12-Mar-09 1:27
MemberLeo Davidson12-Mar-09 1:27 
Alex and the J2K-Codec website seemed to vanish in the latter half of last year. I'm wondering if anybody knows what happened.
QuestionConverting a JPEG2000 file (.JP2) to string or byte to write it on smart card Pin
shilan_hk26-Nov-07 22:56
Membershilan_hk26-Nov-07 22:56 
GeneralCompatbility J2K-Codec and .NET PictureBox Pin
Saied Javadi12-Jul-06 23:40
MemberSaied Javadi12-Jul-06 23:40 
GeneralRe: Compatbility J2K-Codec and .NET PictureBox Pin
Alex Saveliev12-Jul-06 23:58
MemberAlex Saveliev12-Jul-06 23:58 
GeneralRe: Compatbility J2K-Codec and .NET PictureBox Pin
Saied Javadi26-Jul-06 5:35
MemberSaied Javadi26-Jul-06 5:35 
GeneralEncoding Images Pin
Jeffreyhorncastle29-Mar-06 5:53
MemberJeffreyhorncastle29-Mar-06 5:53 
GeneralRe: Encoding Images Pin
Alex Saveliev29-Mar-06 7:01
MemberAlex Saveliev29-Mar-06 7:01 
GeneralRe: Encoding Images Pin
Jeffreyhorncastle29-Mar-06 8:54
MemberJeffreyhorncastle29-Mar-06 8:54 
GeneralRe: Encoding Images Pin
Jeffreyhorncastle29-Mar-06 8:58
MemberJeffreyhorncastle29-Mar-06 8:58 
Generalgetting the image to a variable Pin
caliasp13-Dec-05 13:48
Membercaliasp13-Dec-05 13:48 
GeneralRe: getting the image to a variable Pin
Alex Saveliev13-Dec-05 15:33
MemberAlex Saveliev13-Dec-05 15:33 
GeneralRe: getting the image to a variable Pin
caliasp14-Dec-05 0:26
Membercaliasp14-Dec-05 0:26 
GeneralGenerality Pin
moxjake20-May-05 9:48
Membermoxjake20-May-05 9:48 
GeneralRe: Generality Pin
Alex Saveliev20-May-05 21:03
MemberAlex Saveliev20-May-05 21:03 
Questionbeep? Pin
Huisheng Chen20-May-05 5:37
MemberHuisheng Chen20-May-05 5:37 

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.