Click here to Skip to main content
15,880,608 members
Articles / Programming Languages / VBScript

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 77.1K   1K   9   15
An article on using ActiveX control to display JPEG 2000 images in your VisualBasic applications

Introduction

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.

Background

"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():

VBScript
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 http://j2k-codec.com.

History

  • 20th May, 2005 - Initial version

License

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


Written By
Web Developer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHas anyone heard from Alex? Pin
Leo Davidson12-Mar-09 0:27
Leo Davidson12-Mar-09 0: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 21:56
shilan_hk26-Nov-07 21:56 
GeneralCompatbility J2K-Codec and .NET PictureBox Pin
Saied Javadi12-Jul-06 22:40
Saied Javadi12-Jul-06 22:40 
GeneralRe: Compatbility J2K-Codec and .NET PictureBox Pin
Alex Saveliev12-Jul-06 22:58
Alex Saveliev12-Jul-06 22:58 
GeneralRe: Compatbility J2K-Codec and .NET PictureBox Pin
Saied Javadi26-Jul-06 4:35
Saied Javadi26-Jul-06 4:35 
GeneralEncoding Images Pin
Jeffreyhorncastle29-Mar-06 4:53
Jeffreyhorncastle29-Mar-06 4:53 
GeneralRe: Encoding Images Pin
Alex Saveliev29-Mar-06 6:01
Alex Saveliev29-Mar-06 6:01 
GeneralRe: Encoding Images Pin
Jeffreyhorncastle29-Mar-06 7:54
Jeffreyhorncastle29-Mar-06 7:54 
GeneralRe: Encoding Images Pin
Jeffreyhorncastle29-Mar-06 7:58
Jeffreyhorncastle29-Mar-06 7:58 
Generalgetting the image to a variable Pin
caliasp13-Dec-05 12:48
caliasp13-Dec-05 12:48 
GeneralRe: getting the image to a variable Pin
Alex Saveliev13-Dec-05 14:33
Alex Saveliev13-Dec-05 14:33 
GeneralRe: getting the image to a variable Pin
caliasp13-Dec-05 23:26
caliasp13-Dec-05 23:26 
GeneralGenerality Pin
moxjake20-May-05 8:48
moxjake20-May-05 8:48 
GeneralRe: Generality Pin
Alex Saveliev20-May-05 20:03
Alex Saveliev20-May-05 20:03 
Questionbeep? Pin
Huisheng Chen20-May-05 4:37
Huisheng Chen20-May-05 4: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.