Jump to content
How to Install Plugins ×

JPEG 2000 plug-in


Gumboot

Recommended Posts

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
Link to comment
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 :)

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

aatwo, try installing the VC8 runtime redistributable and see if that helps it to work for you:

http://www.eecs.wsu.edu/paint.net/misc/vcredist.zip [contains both x86 and x64 redistributables, both should be digitally signed by Microsoft]

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
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?

Link to comment
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!

Link to comment
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 :-)

Link to comment
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.

Link to comment
Share on other sites

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

BK_BloodSaw_sig.png

- DO NOT contact me asking for the .pdn of my avatar or the PDN logo. Thank you. Have a nice day.

Link to comment
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".

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
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.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
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.

Link to comment
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.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
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...

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 4 weeks later...

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?

RuneScapeBorn2killxSig.png

I built my first computer at age 11!

Link to comment
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?

RuneScapeBorn2killxSig.png

I built my first computer at age 11!

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...