# Choosing pixels in resize (More)

I figured that in order to resize an image using a float for the scale factor I could pick the pixels to copy from the source image's scanlines as follows:

For example, if the source image is 3px wide and we want to scale it by a factor of 0.5 then we would have an output image that's 3*0.5 = 1.5px or 2px wide if we round up.

Next we go to the original scanline and pick the pixel that is 1/2 the width across (that would be the second one since 3/0.5 is 1.5 or 1 as an int) and the one that is 2/2 across is the third pixel.

In summary

``````new = old
new = old
``````

However, in the walkthrough video the sequence is this:

``````new = old
new = old
``````

Can anybody help me understand how this sequnce is created?

I'm dealing with that at the moment, and as far as I can tell the form is

``````newArray[i] = oldArray[(int)floor(i / factor)]
``````

Then, if factor = 0.5

``````floor(0/0.5) = 0 /* newArray = oldArray */
floor(1/0.5) = 2 /* newArray = oldArray */
floor(2/0.5) = 4 /* newArray = oldArray */
``````

And so on.