Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, June 10, 2010 11:35:08 PM(UTC)
Cidolfus

Groups: Registered
Posts: 10


Hi,

I'm able to successfully convert a jpg file into jp2 format with the following code in C#

byte[] imgData = File.ReadAllBytes("depp.jpg");
MemoryStream ms = new MemoryStream(imgData);
RasterCodecs.Startup();
RasterCodecs objImageCodec = new RasterCodecs();
RasterImage image = objImageCodec.Load(ms);
MemoryStream jp2MS = new MemoryStream();
objImageCodec.Save(image, jp2MS, RasterImageFormat.Jp2, 24);
byte[] jp2Data = jp2MS.ToArray();
RasterCodecs.Shutdown();

the jpg file size is 13k, however, the output of the jp2 file is 70k, why did it bloat up so much? How can I compress this? I'd like the file size to be around half of the jpg version. Is this possible?

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, June 13, 2010 5:42:20 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

You can try to change the CodecsJpeg2000SaveOptions.CompressionControl Property and choose a different compression controls (such as the TargetSize mode for example) and then set the desired output size using the CodecsJpeg2000SaveOptions.TargetFileSize Property as follows:
objImageCodec.Options.Jpeg2000.Save.CompressionControl = CodecsJpeg2000CompressionControl.TargetSize;
objImageCodec.Options.Jpeg2000.Save.TargetFileSize = 1000;
Please check the .NET help file for more information regarding compression control.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.059 seconds.