Thinking about scaling code, and how you would render into a higher resolution buffer,

Thinking about scaling code, and how you would render into a higher resolution buffer, but then map that back to a lower resolution pixel grid.

A while ago @Mark_Kriegsman posted an example of how this was done in 1-D, and I understood it and could adapt the code pretty easily. Basically you use n of the most significant bits of your x value as the pixel address, and the remaining m as the brightness of the adjacent pixel.

But my mental model broke down when I tried to move into 2-D. What do the pros call this, and has anyone got some simple example code?

(I think I’ve got the idea in theory, as illustrated—the real pixels with 1 “sub pixel” lit get 1/4 brightness in my example, those with 2, 1/2) but I’m not sure how that translates in practice. is it simply enough to logical AND the “fractional” parts of each x and y pixel address to get the brightness for that pixel?)

http://en.m.wikipedia.org/wiki/Xiaolin_Wu’s_line_algorithm ?

What is wrong with the scaling function we discussed here some days ago? It does exactely the job you describe. Give it a try.
https://plus.google.com/115124694226931502095/posts/iMKuvhM14Vk
Interpolation for mapping a high-res grid into a low-res one? For what?

Btw. while thinking about an even faster scaling routine I wondered, if the Bresenham line algorythm could be abused for that, as well.

Because I’m not sure if the scaling function you’re pointing to there quite does what I want?

It’s not just lines I want to scale/antialias—it’s points and dots. Actually, I think sprites really. Explain to me what the x1, y1, x2, y2 inputs to your MapNoiseToRectangle() function actually represent?

So I probably understood your post wrong. I still wonder which sense an interpolation has for scaling something DOWN. I would expect it to blur the result. For scaling something UP in my opinion it makes totally sense - to fill the missing points with smooth gradients. Maybe I do not see a relevant detail or I still do not understand the main problem you are going to solve. If so, sorry.

Robert , did you happen to find a way to reproduce a higher resolution matrix into a lower one ?
i fully understand what the intention is and totally agree, a way to “average” the pixel values inside the high res matrix and use the result as low res matrix brightness seams good, is there a better one ? thanks

I didn’t follow this any further. Check out the Blur2D function though, it might do what you want: https://github.com/FastLED/FastLED/blob/149f36aa23b73bb2c777d6e973368f3c8718ca7b/colorutils.h#L320