- if(tw == 0.0) \
- { \
- ttx = 0.0; \
- tty = 0.0; \
- } \
- else \
- if(tw != 1.0) \
- { \
- ttx = tx / tw; \
- tty = ty / tw; \
- } \
- else \
- { \
- ttx = tx; \
- tty = ty; \
- } \
- itx = (int)ttx; \
- ity = (int)tty; \
- \
- int row1 = ity - 1; \
- int row2 = ity; \
- int row3 = ity + 1; \
- int row4 = ity + 2; \
- CLAMP(row1, min_in_y, max_in_y); \
- CLAMP(row2, min_in_y, max_in_y); \
- CLAMP(row3, min_in_y, max_in_y); \
- CLAMP(row4, min_in_y, max_in_y); \
- \
-/* Set destination pixels if in clipping region */ \
- if(!interpolate && \
- x >= min_out_x && \
- x < max_out_x) \
- { \
- if(itx >= min_in_x && \
- itx <= max_in_x && \
- ity >= min_in_y && \
- ity <= max_in_y) \
- { \
- type *src = in_rows[ity] + itx * components; \
- *out_row++ = *src++; \
- *out_row++ = *src++; \
- *out_row++ = *src++; \
- if(components == 4) *out_row++ = *src; \
- } \
- else \
-/* Fill with chroma */ \
- { \
- *out_row++ = 0; \
- *out_row++ = chroma_offset; \
- *out_row++ = chroma_offset; \
- if(components == 4) *out_row++ = 0; \
- } \
- } \
- else \
-/* Bicubic algorithm */ \
- if(interpolate && \
- x >= min_out_x && \
- x < max_out_x) \
- { \
-/* clipping region */ \
- if ((itx + 2) >= min_in_x && \
- (itx - 1) <= max_in_x && \
- (ity + 2) >= min_in_y && \
- (ity - 1) <= max_in_y) \
- { \
- float dx, dy; \
- \
-/* the fractional error */ \
- dx = ttx - itx; \
- dy = tty - ity; \
- \
-/* Row and column offsets in cubic block */ \
- int col1 = itx - 1; \
- int col2 = itx; \
- int col3 = itx + 1; \
- int col4 = itx + 2; \
- CLAMP(col1, min_in_x, max_in_x); \
- CLAMP(col2, min_in_x, max_in_x); \
- CLAMP(col3, min_in_x, max_in_x); \
- CLAMP(col4, min_in_x, max_in_x); \
- int col1_offset = col1 * components; \
- int col2_offset = col2 * components; \
- int col3_offset = col3 * components; \
- int col4_offset = col4 * components; \
- \
- type *row1_ptr = in_rows[row1]; \
- type *row2_ptr = in_rows[row2]; \
- type *row3_ptr = in_rows[row3]; \
- type *row4_ptr = in_rows[row4]; \
- temp_type r, g, b, a; \
- \
- r = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(row1_ptr, 0x0), \
- CUBIC_ROW(row2_ptr, 0x0), \
- CUBIC_ROW(row3_ptr, 0x0), \
- CUBIC_ROW(row4_ptr, 0x0)) + \
- round_factor); \
- \
- row1_ptr++; \
- row2_ptr++; \
- row3_ptr++; \
- row4_ptr++; \
- g = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(row1_ptr, chroma_offset), \
- CUBIC_ROW(row2_ptr, chroma_offset), \
- CUBIC_ROW(row3_ptr, chroma_offset), \
- CUBIC_ROW(row4_ptr, chroma_offset)) + \
- round_factor); \
- g += chroma_offset; \
- \
- row1_ptr++; \
- row2_ptr++; \
- row3_ptr++; \
- row4_ptr++; \
- b = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(row1_ptr, chroma_offset), \
- CUBIC_ROW(row2_ptr, chroma_offset), \
- CUBIC_ROW(row3_ptr, chroma_offset), \
- CUBIC_ROW(row4_ptr, chroma_offset)) + \
- round_factor); \
- b += chroma_offset; \
- \
- if(components == 4) \
- { \
- row1_ptr++; \
- row2_ptr++; \
- row3_ptr++; \
- row4_ptr++; \
- a = (temp_type)(transform_cubic(dy, \
- CUBIC_ROW(row1_ptr, 0x0), \
- CUBIC_ROW(row2_ptr, 0x0), \
- CUBIC_ROW(row3_ptr, 0x0), \
- CUBIC_ROW(row4_ptr, 0x0)) + \
- round_factor); \
- } \
- \
- if(sizeof(type) < 4) \
- { \
- *out_row++ = CLIP(r, 0, max); \
- *out_row++ = CLIP(g, 0, max); \
- *out_row++ = CLIP(b, 0, max); \
- if(components == 4) *out_row++ = CLIP(a, 0, max); \
- } \
- else \
- { \
- *out_row++ = r; \
- *out_row++ = g; \
- *out_row++ = b; \
- if(components == 4) *out_row++ = a; \
- } \
- } \
- else \
-/* Fill with chroma */ \
- { \
- *out_row++ = 0; \
- *out_row++ = chroma_offset; \
- *out_row++ = chroma_offset; \
- if(components == 4) *out_row++ = 0; \
- } \
- } \
- else \
- { \
- out_row += components; \
- } \