- x_offset = srcpixx + double(i) < 0.0 ? 0 : (srcpixx + double(i) >= M_IMGDATA->m_width ? M_IMGDATA->m_width - 1 : srcpixx + i);
-
- // Calculate the exact position where the source data should be pulled from based on the x_offset and y_offset
- src_pixel_index = (y_offset * M_IMGDATA->m_width) + x_offset;
-
- // Calculate the weight for the specified pixel according to the bicubic b-spline kernel we're using for interpolation
- pixel_weight = spline_weight(double(i) - dx) * spline_weight(double(k) - dy);
-
- // Create a sum of all velues for each color channel adjusted for the pixel's calculated weight
- sum_r += double(src_data[src_pixel_index * 3 + 0]) * pixel_weight;
- sum_g += double(src_data[src_pixel_index * 3 + 1]) * pixel_weight;
- sum_b += double(src_data[src_pixel_index * 3 + 2]) * pixel_weight;
- if(src_alpha)
- sum_a += double(src_alpha[src_pixel_index]) * pixel_weight;
+ int x_offset = srcpixx + i < 0.0
+ ? 0
+ : srcpixx + i >= M_IMGDATA->m_width
+ ? M_IMGDATA->m_width - 1
+ : (int)(srcpixx + i);
+
+ // Calculate the exact position where the source data
+ // should be pulled from based on the x_offset and y_offset
+ int src_pixel_index = y_offset*M_IMGDATA->m_width + x_offset;
+
+ // Calculate the weight for the specified pixel according
+ // to the bicubic b-spline kernel we're using for
+ // interpolation
+ double
+ pixel_weight = spline_weight(i - dx)*spline_weight(k - dy);
+
+ // Create a sum of all velues for each color channel
+ // adjusted for the pixel's calculated weight
+ sum_r += src_data[src_pixel_index * 3 + 0] * pixel_weight;
+ sum_g += src_data[src_pixel_index * 3 + 1] * pixel_weight;
+ sum_b += src_data[src_pixel_index * 3 + 2] * pixel_weight;
+ if ( src_alpha )
+ sum_a += src_alpha[src_pixel_index] * pixel_weight;