Jump to content
Paint.NET 5.1 is now available! ×

Recommended Posts

Posted

To me, one of the most confusing aspects of writing plugins is knowing what the various callable functions do, since, as far as I know, they aren't documented anywhere (I'd be thrilled to be wrong about that). Given the name of this function, and that fact it takes two floating point arguments, I assume it bilinearly interpolates between the four nearest pixels. However, in most examples where I've seen it called, the arguments have been integer coordinates. If I'm correct about what the function does, that would seem to do nothing (other than perhaps automatic clamping) that couldn't be done by directly indexing into the image buffer, and would seem to lose the advantage of bilinear interpolation. So, I guess my question is: Do I correctly understand what GetBilinearSampleClamped does, and if not, what does it do?

Posted

If you're calling it with integer coordinates, then it's not really doing much of anything useful for you, as you suspected.

 

"Clamped" means that it clamps the input coordinates to the dimensions of the image. If your image is 100 pixels X 100 pixels and you pass in values outside that range, they'll be clamped to the edge.

 

Another version uses the "Wrapped" suffix, which means the input coordinates wrap around to the other edge.

 

Without either suffix (GetBilinearSample), if you request a pixel outside of the bounds of the image then you'll get a transparent color returned to you.

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

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

forumSig_bmwE60.jpg

Posted

Thanks for the information, Rick. I've seen code for several quite impressive plugins which convert the coordinates to integers before calling the routine, and I think they might produce smoother results if the calls were made with untruncated values.

Posted

The performance might be slightly better, but by "smoother," I meant the rendering would be less blocky. It would, of course, be somewhat blurrier, but that's almost always preferable to blockiness.

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