Sign in to follow this  
Followers 0
Gumboot

JPEG 2000 plug-in

43 posts in this topic

This plugin has been updated (13/8/2012) !

Get the new version here: http://forums.getpaint.net/index.php?/topic/25170-

OK, so I was bored and decided to spend the weekend writing a JPEG 2000 plug-in for Paint.NET... (yes, I know).

Download

This is basically untested, so I need people to post a message if it works for them. Especially those with 32-bit Windows (I have x64 so I'm reasonably sure that one works).

[update 19/3/06 - Requires VC8 runtime]

[update 20/3/06 - Hopefully fixed 32-bit crash issues]

Edited by Ego Eram Reputo
Linked to updated version
0

Share this post


Link to post
Share on other sites

x86 on regular windows. I have 32 bit apparently.

"Unspecified error while saving"

And then it hobbles around and expires without saving anything.

0

Share this post


Link to post
Share on other sites

Hey Gumboot, regarding aatwo's error. Looks like this was written in Managed C++ ... did you compile with the static or dynamic linked C runtime?

Works on my system though (x64, and have VS2k5 installed as well). JPEG 2000 is very slow :)

0

Share this post


Link to post
Share on other sites

Holey abomination!!!!!

It kind of works now after I did what you said Mr Brewster. It saves files with some random file extension that my computer can't handle and won't let me open. But now when ever I close paint.net I get this message...

error4mi.th.png

Is it broken?

0

Share this post


Link to post
Share on other sites
Hey Gumboot, regarding aatwo's error. Looks like this was written in Managed C++ ... did you compile with the static or dynamic linked C runtime?

Not sure... whatever the default is. I want the static runtime, right? Where do I set this?

Is it broken?

I guess... yes! ;-) I must not be cleaning up all the memory correctly. I'll have another look, see if I can track it down.

It saves files with some random file extension that my computer can't handle and won't let me open.

What, you can't open them even with Paint.NET?

BTW, thanks for the feedback aatwo!

0

Share this post


Link to post
Share on other sites

Oh yes, and the slowness is partially because I'm doing a conversion between the JasPer image format (I'm using JasPer to do the actual work) and the .net image format.

In other words, it could be made faster :-)

0

Share this post


Link to post
Share on other sites

According to this page I can't use the static CRT because I'm compiling with /clr turned on. :-(

If you are using the /clr compiler switch, your code will be linked with an import library, msvcmrt.lib. The import library references a new library, msvcm80.dll, which provides a proxy between your managed code and the native CRT. You cannot use the statically linked CRT ( /MT or /MTd options) with /clr. Use the dynamically-linked libraries (/MD or /MDd) instead.

Which I guess means users will have to install the runtime files to get this thing to work.

0

Share this post


Link to post
Share on other sites

No I can't open the .jp2 files even with paint.net

I get the error message saying there was an unspecified error while opening the file.

0

Share this post


Link to post
Share on other sites

Where would somebody look to see if they are running 32 bit or 64 bit Windows?

0

Share this post


Link to post
Share on other sites
Where would somebody look to see if they are running 32 bit or 64 bit Windows?

If you have to ask, you're probably on 32-bit.

But seriously, go to System Properties (right click My Computer, click Properties). If you're on 64-bit it'll say something like "Microsoft Windows XP Professional x64 Edition".

0

Share this post


Link to post
Share on other sites
Oh yes, and the slowness is partially because I'm doing a conversion between the JasPer image format (I'm using JasPer to do the actual work) and the .net image format.

In other words, it could be made faster :-)

You're converting to a System.Drawing.Bitmap, or to a PaintDotNet.Document (which contains a PaintDotNet.BitmapLayer that contains a PaintDotNet.Surface) ?

If the latter (PaintDotNet format), don't use the Surface class' indexer (i.e. don't use surface[x,y] = whatever format). Use pointers and Surface.GetRowAddress() instead.

0

Share this post


Link to post
Share on other sites
You're converting to a System.Drawing.Bitmap, or to a PaintDotNet.Document (which contains a PaintDotNet.BitmapLayer that contains a PaintDotNet.Surface) ?

If the latter (PaintDotNet format), don't use the Surface class' indexer (i.e. don't use surface[x,y] = whatever format). Use pointers and Surface.GetRowAddress() instead.

To a System.Drawing.Bitmap. And yes, I'm using LockBits(), UnlockBits(). My idea around how to speed this up was to reimplement the JasPer image type on top of a System.Drawing.Bitmap. That way, no conversion would be required.

0

Share this post


Link to post
Share on other sites

But why not just copy directly to a Surface?

BitmapLayer layer = new BitmapLayer(width, height);
Surface surface = layer.Surface;

for (int y = 0; y {
   ... copy from jasper image to the surface ...
}

document.Layers.Add(layer);

Plus, System.Drawing.Bitmap is a sealed class.

The most efficient way to do this would be to decode straight into a PaintDotNet.Surface. Otherwise you're allocating a lot of memory by loading into a jasper image, then doing conversions. I noticed hundreds of megabytes of memory being allocated for the images I was trying out this plugin with.

0

Share this post


Link to post
Share on other sites

**pause nerd talk**

I just saw a squirrel fall out of a tree :(

**unpause**

0

Share this post


Link to post
Share on other sites

OK, I've had another go at it. aatwo, would you mind redownloading the plug-in and trying again? (The squirrel can wait...)

0

Share this post


Link to post
Share on other sites

Oh and Rick, the reason I was copying to a Bitmap rather than a Surface was, erm, because I didn't realize Document.FromImage() did a copy...

0

Share this post


Link to post
Share on other sites

YYYYYYay I dont have error messages when I save it, Open it, or close my paint.net

So what's the deal with these .jp2 files?

Why would I ever use it and what does it do and what are the advantages and disadvantages etc etc etc.

0

Share this post


Link to post
Share on other sites

Whoa that web page.... blah blah blah blah blah waffle.

Well I guess jp2 is a good thing! since it might become the new jpg. You should integrate it's file support with paint.net if you like! If not then I will shut up. I have no preference.

0

Share this post


Link to post
Share on other sites

I don't know what to do with that jp2 extension because I don't think my friends will be able to see it. Can you see it with the Windows Picture and Fax Viewer?

0

Share this post


Link to post
Share on other sites

No you can't. On my computer at least the only way to see a JP2 file is to use this plugin in conjunction with paint.net.

0

Share this post


Link to post
Share on other sites

oh then i guess it would be useless for my friends at my forum <_<. is png or jp2 better in your opinion?

0

Share this post


Link to post
Share on other sites

well you can't really compare the two cause each is globally (or will be globally) used for different things. They both have their own strengths and weaknesses.

The thing is, at the moment jpg is primarily used for photos because I believe it optimises the colours in the image which is where is alters the colours of pixels very slightly to give the best compression with out changing the overall appearence of the image. It can give very good compression for images, and the colour optimisation that takes place does not really matter in photos because the image have thousands of colour variations in it anyways... and so that's what it is mainly used for.

I am assuming that jp2 will work essentially the same way and so will essentially be used for the same purposes as the current jpg.

With png people tend to use it more for cartoons, web page grapics, and stuff like that. With png if you use it to save a photo the file size will be much bigger than that of a jpg. This is because it will save the image exactly the same as the original and does not optimise it like a jpg.

I personally use png for everything because it saves the image perfectly. I use it for photos and everything, not because I hate jpg, but because I am slightly compulsive and I like things to be exact.

An example of jpg colour optimisation "ruining" an image would be this lagybird I drew ages ago before I knew any better...

ladybug.jpg

If you look at the red parts around the dots on its back you can see the image has been distorted a bit. In the originial image the back was completely red but saving as a jpg optimised the colours in this way.

If I had saved the image as a png it would have saved it exactly as I drew it.

The End

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0