Jump to content

Render only once


harold
 Share

Recommended Posts

"Content Aware Resize" is a little effect I've written in a couple of hours that uses Seam Carving to make an image less wide in a way that somewhat respects the content.

It probably shouldn't really be an effect because it effectively changes the size of the picture, but there is little choice.. so it just leaves some transparent space, which works well enough.

As you can see in the source, I use an ugly hack to render only once. It's fundamentally impossible to render it in parts - it has to calculate the globally least-energy seam, which means it has to look at the entire image all at once (well the entire selection really, but I had no idea how to do that). Once it knows the seam it could theoretically build the output row by row, I suppose.

Is there a good way to render just once, preferrably in a way that handles rectangular selections?

edit: I know the code is lame and I recalculate far too much for every seam, I'll fix that later..

ContentAwareResize.zip

Edited by harold

I would write plugins, if I knew what kind of plugins were needed.. :(

Link to comment
Share on other sites

You can override OnSetRenderInfo() and do your rendering in there instead of Render(). Keep in mind that this will make Paint.NET's progress bar useless (it'll be stuck at 0% while your plugin works, then jump to 100% when done) so try to keep things snappy.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

It probably shouldn't really be an effect because it effectively changes the size of the picture, but there is little choice.. so it just leaves some transparent space, which works well enough.

Your effect changes the size of the image, but not the canvas or selection region. This is perfectly OK. Several effects do exactly that. Filling the excess with transparent pixels is the natural consequence to the resizing operation so that isn't a problem either.

Processing your heavy calculations in OnSetRenderInfo() is the preferred method, not a hack. See Rick's post here: http://forums.getpai...in/#entry358957

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.

 Share

×
×
  • Create New...