Click here to Skip to main content
Licence CPOL
First Posted 20 May 2005
Views 44,435
Downloads 268
Bookmarked 8 times

Easy Way of Displaying JPEG 2000 Images in VisualBasic

By | 20 May 2005 | Article
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"

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

3. Place the Control on your Form

Using "J2" button,

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 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)

About the Author

Alex Saveliev

Web Developer

Russian Federation Russian Federation

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHas anyone heard from Alex? PinmemberLeo Davidson0:27 12 Mar '09  
QuestionConverting a JPEG2000 file (.JP2) to string or byte to write it on smart card Pinmembershilan_hk21:56 26 Nov '07  
GeneralCompatbility J2K-Codec and .NET PictureBox PinmemberSaied Javadi22:40 12 Jul '06  
GeneralRe: Compatbility J2K-Codec and .NET PictureBox PinmemberAlex Saveliev22:58 12 Jul '06  
GeneralRe: Compatbility J2K-Codec and .NET PictureBox PinmemberSaied Javadi4:35 26 Jul '06  
GeneralEncoding Images PinmemberJeffreyhorncastle4:53 29 Mar '06  
GeneralRe: Encoding Images PinmemberAlex Saveliev6:01 29 Mar '06  
GeneralRe: Encoding Images PinmemberJeffreyhorncastle7:54 29 Mar '06  
GeneralRe: Encoding Images PinmemberJeffreyhorncastle7:58 29 Mar '06  
Generalgetting the image to a variable Pinmembercaliasp12:48 13 Dec '05  
GeneralRe: getting the image to a variable PinmemberAlex Saveliev14:33 13 Dec '05  
GeneralRe: getting the image to a variable Pinmembercaliasp23:26 13 Dec '05  
GeneralGenerality Pinmembermoxjake8:48 20 May '05  
GeneralRe: Generality PinmemberAlex Saveliev20:03 20 May '05  
Questionbeep? PinmemberUnruled Boy4:37 20 May '05  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 20 May 2005
Article Copyright 2005 by Alex Saveliev
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid

The Code Project Insider. Free each morning.