Jump to content

Very basic question: How do I resize properly in .NET


Recommended Posts

Ok, once again a not STRICTLY plugin related question, but you guys helped me tremendously once, so I'm going to try again.

I want to perform a series of very simple transformations on a given image, and currently I fail to even take the first step properly.

This first step is resizing the base image, mostly reducing it's size to about 50% (but that can differ).

I thought performing such mundane task should be easy enough in the .NET framework, but I was proven wrong.

I found several different ways of doing this utilizing different methods from various namespaces, but they all bring the same problem to the table: whenever the job finishes, I end up with a (usually somewhat blurry) resized picture ... but it has a frame of semi-transparent pixels around it which disqualifies the image for the next step I would like to take.

I tried to google a solution, and found several things, but none of them actually solved the problem. The best one managed to get rid of those pixels to the top and to the left, but not on the bottom and to the right.

(It involved setting some sort of FlipXY property).

Appearently there's a glich in the DrawImage routine that causes it to think pixels outside of the resized image's boundaries are white, but I'm not sure.

Anyway, surely there must be a way to do a simple resize without getting such artifacts. Can anyone provide a code snippet that'll do the trick?

Thank you very much in advance.

-Refar

Link to comment
Share on other sites

You'll find better luck searching online or asking on StackOverflow ... this section of the forum really is meant only for Paint.NET plugin related conversation. It is not a place for general questions about programming, C#, .NET, GDI+, WPF, etc.

The 'frame of semi transparent pixels' is a bug in GDI+ (System.Drawing) and is the reason Paint.NET doesn't use their rubbish resizing routines.

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 might have better luck using portions of WPF under System.Windows.Media.Imaging, which is a wrapper for WIC (Windows Imaging Component). But for further help you really do need to ask/search elsewhere.

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

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