Hi all, I hope that somone here can help me out as I'm racking my brain over this and something is telling me that should be a realtively simple problem to solve but I just can't see the wood for the trees.

In short I'm converting a floating point bilinear image resampling routine into one that only uses fixed point arithmetic. I've gotten rid of nearly all the floats now, in fact all but one and the results at the moment are in distinguishable from the floating point version. It's a maths issue really so I hope that there's a whizz on here that can help. Some pseudocode goes like this.

Code:
for( int xx=0; xx<ow; xx++ )
{
   int_center = (ccx >> 16);
   int temp = xx * 2;

   for (j = int_center; j <= int_center + 1; j++)
   {
     t_weight = abs((int)(float)(((int)ccx - (j << 16))  * FILTER_FACTOR));
     int_weight = t_weight < 65536 ? 65536 - t_weight : 0;

     hv_pixel[temp + index] = j;
     int_hv_weight[temp + index] = int_weight;
     ++index;
   }/* j */

   ccx += dx;
   index = 0;
}
Where ccx is and integer error accumulator that gives me a scaled integer. Shifting down buy 16 gives me the relative pixel I need to be working on. The line just after where the inner loop begins is where I have the last remaining float. FILTER_FACTOR is essentially a percentage by which I scale the error accumulator to the correct amount.

For example.

ccx = 98303. Which is a value of 1.5 when shited down by 16 bits. Obviously I can shift it because it will round and I lose the precision. Lets say FILTER_FACTOR is 39321. Which is 60% of 1 (65535) So what I'd like to know is, is it possible to use the FILTER_FACTOR as an integer and do some fancy integer math to scale the result from (ccx - (j<<16)) by the representative amount that is FILTER_FACTOR. In this example 60%. Effectively getting 40% of (ccx - (j<<16)) At the moment FILTER_FACTOR is still a float and therefore 0.6, which of course works just fine.

Many thanks for all the replies in advance.