MJW Posted October 20, 2013 Posted October 20, 2013 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? Quote
Rick Brewster Posted October 20, 2013 Posted October 20, 2013 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. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
MJW Posted October 20, 2013 Author Posted October 20, 2013 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. Quote
Rick Brewster Posted October 20, 2013 Posted October 20, 2013 The performance would be better, yes. They would have to do their own coordinate space clamping, although that's very easy of course. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
MJW Posted October 20, 2013 Author Posted October 20, 2013 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.