diff options
Diffstat (limited to 'agg/inc/agg_span_image_filter_rgb.h')
-rwxr-xr-x | agg/inc/agg_span_image_filter_rgb.h | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/agg/inc/agg_span_image_filter_rgb.h b/agg/inc/agg_span_image_filter_rgb.h index d8f8142bfffb..1750cba5589e 100755 --- a/agg/inc/agg_span_image_filter_rgb.h +++ b/agg/inc/agg_span_image_filter_rgb.h @@ -2,8 +2,8 @@ // Anti-Grain Geometry - Version 2.3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // @@ -13,12 +13,12 @@ // http://www.antigrain.com //---------------------------------------------------------------------------- // -// Adaptation for high precision colors has been sponsored by +// Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. -// +// //---------------------------------------------------------------------------- #ifndef AGG_SPAN_IMAGE_FILTER_RGB_INCLUDED @@ -35,10 +35,10 @@ namespace agg //==============================================span_image_filter_rgb_nn template<class ColorT, - class Order, + class Order, class Interpolator, - class Allocator = span_allocator<ColorT> > - class span_image_filter_rgb_nn : + class Allocator = span_allocator<ColorT> > + class span_image_filter_rgb_nn : public span_image_filter<ColorT, Interpolator, Allocator> { public: @@ -60,16 +60,16 @@ namespace agg //-------------------------------------------------------------------- span_image_filter_rgb_nn(alloc_type& alloc, - const rendering_buffer& src, + const rendering_buffer& src, const color_type& back_color, interpolator_type& inter) : - base_type(alloc, src, back_color, inter, 0) + base_type(alloc, src, back_color, inter, 0) {} //-------------------------------------------------------------------- color_type* generate(int x, int y, unsigned len) { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[3]; @@ -89,7 +89,7 @@ namespace agg y >>= image_subpixel_shift; if(x >= 0 && y >= 0 && - x <= maxx && y <= maxy) + x <= maxx && y <= maxy) { fg_ptr = (const value_type*)base_type::source_image().row(y) + x + x + x; fg[0] = *fg_ptr++; @@ -123,10 +123,10 @@ namespace agg //=========================================span_image_filter_rgb_bilinear template<class ColorT, - class Order, - class Interpolator, - class Allocator = span_allocator<ColorT> > - class span_image_filter_rgb_bilinear : + class Order, + class Interpolator, + class Allocator = span_allocator<ColorT> > + class span_image_filter_rgb_bilinear : public span_image_filter<ColorT, Interpolator, Allocator> { public: @@ -148,16 +148,16 @@ namespace agg //-------------------------------------------------------------------- span_image_filter_rgb_bilinear(alloc_type& alloc, - const rendering_buffer& src, + const rendering_buffer& src, const color_type& back_color, interpolator_type& inter) : - base_type(alloc, src, back_color, inter, 0) + base_type(alloc, src, back_color, inter, 0) {} //-------------------------------------------------------------------- color_type* generate(int x, int y, unsigned len) { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[3]; calc_type src_alpha; @@ -177,7 +177,7 @@ namespace agg { int x_hr; int y_hr; - + base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); @@ -188,17 +188,17 @@ namespace agg unsigned weight; if(x_lr >= 0 && y_lr >= 0 && - x_lr < maxx && y_lr < maxy) + x_lr < maxx && y_lr < maxy) { - fg[0] = - fg[1] = + fg[0] = + fg[1] = fg[2] = image_subpixel_size * image_subpixel_size / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source_image().row(y_lr) + x_lr + x_lr + x_lr; - weight = (image_subpixel_size - x_hr) * + weight = (image_subpixel_size - x_hr) * (image_subpixel_size - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; @@ -238,15 +238,15 @@ namespace agg } else { - fg[0] = - fg[1] = - fg[2] = + fg[0] = + fg[1] = + fg[2] = src_alpha = image_subpixel_size * image_subpixel_size / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; - weight = (image_subpixel_size - x_hr) * + weight = (image_subpixel_size - x_hr) * (image_subpixel_size - y_hr); if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) @@ -355,10 +355,10 @@ namespace agg //=========================================span_image_filter_rgb_2x2 template<class ColorT, - class Order, - class Interpolator, - class Allocator = span_allocator<ColorT> > - class span_image_filter_rgb_2x2 : + class Order, + class Interpolator, + class Allocator = span_allocator<ColorT> > + class span_image_filter_rgb_2x2 : public span_image_filter<ColorT, Interpolator, Allocator> { public: @@ -380,17 +380,17 @@ namespace agg //-------------------------------------------------------------------- span_image_filter_rgb_2x2(alloc_type& alloc, - const rendering_buffer& src, + const rendering_buffer& src, const color_type& back_color, interpolator_type& inter, const image_filter_lut& filter) : - base_type(alloc, src, back_color, inter, &filter) + base_type(alloc, src, back_color, inter, &filter) {} //-------------------------------------------------------------------- color_type* generate(int x, int y, unsigned len) { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[3]; calc_type src_alpha; @@ -402,8 +402,8 @@ namespace agg const value_type *fg_ptr; color_type* span = base_type::allocator().span(); - const int16* weight_array = base_type::filter().weight_array() + - ((base_type::filter().diameter()/2 - 1) << + const int16* weight_array = base_type::filter().weight_array() + + ((base_type::filter().diameter()/2 - 1) << image_subpixel_shift); int maxx = base_type::source_image().width() - 1; @@ -413,7 +413,7 @@ namespace agg { int x_hr; int y_hr; - + base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); @@ -424,7 +424,7 @@ namespace agg unsigned weight; if(x_lr >= 0 && y_lr >= 0 && - x_lr < maxx && y_lr < maxy) + x_lr < maxx && y_lr < maxy) { fg[0] = fg[1] = fg[2] = image_filter_size / 2; @@ -432,17 +432,17 @@ namespace agg y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source_image().row(y_lr) + x_lr + x_lr + x_lr; - weight = (weight_array[x_hr + image_subpixel_size] * - weight_array[y_hr + image_subpixel_size] + - image_filter_size / 2) >> + weight = (weight_array[x_hr + image_subpixel_size] * + weight_array[y_hr + image_subpixel_size] + + image_filter_size / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; - weight = (weight_array[x_hr] * - weight_array[y_hr + image_subpixel_size] + - image_filter_size / 2) >> + weight = (weight_array[x_hr] * + weight_array[y_hr + image_subpixel_size] + + image_filter_size / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; @@ -450,17 +450,17 @@ namespace agg fg_ptr = (const value_type*)base_type::source_image().next_row(fg_ptr - 6); - weight = (weight_array[x_hr + image_subpixel_size] * - weight_array[y_hr] + - image_filter_size / 2) >> + weight = (weight_array[x_hr + image_subpixel_size] * + weight_array[y_hr] + + image_filter_size / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; - weight = (weight_array[x_hr] * - weight_array[y_hr] + - image_filter_size / 2) >> + weight = (weight_array[x_hr] * + weight_array[y_hr] + + image_filter_size / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; @@ -492,9 +492,9 @@ namespace agg x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; - weight = (weight_array[x_hr + image_subpixel_size] * - weight_array[y_hr + image_subpixel_size] + - image_filter_size / 2) >> + weight = (weight_array[x_hr + image_subpixel_size] * + weight_array[y_hr + image_subpixel_size] + + image_filter_size / 2) >> image_filter_shift; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) @@ -515,9 +515,9 @@ namespace agg x_lr++; - weight = (weight_array[x_hr] * - weight_array[y_hr + image_subpixel_size] + - image_filter_size / 2) >> + weight = (weight_array[x_hr] * + weight_array[y_hr + image_subpixel_size] + + image_filter_size / 2) >> image_filter_shift; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) @@ -539,9 +539,9 @@ namespace agg x_lr--; y_lr++; - weight = (weight_array[x_hr + image_subpixel_size] * - weight_array[y_hr] + - image_filter_size / 2) >> + weight = (weight_array[x_hr + image_subpixel_size] * + weight_array[y_hr] + + image_filter_size / 2) >> image_filter_shift; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) @@ -562,9 +562,9 @@ namespace agg x_lr++; - weight = (weight_array[x_hr] * - weight_array[y_hr] + - image_filter_size / 2) >> + weight = (weight_array[x_hr] * + weight_array[y_hr] + + image_filter_size / 2) >> image_filter_shift; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) @@ -616,10 +616,10 @@ namespace agg //=================================================span_image_filter_rgb template<class ColorT, - class Order, - class Interpolator, - class Allocator = span_allocator<ColorT> > - class span_image_filter_rgb : + class Order, + class Interpolator, + class Allocator = span_allocator<ColorT> > + class span_image_filter_rgb : public span_image_filter<ColorT, Interpolator, Allocator> { public: @@ -641,17 +641,17 @@ namespace agg //-------------------------------------------------------------------- span_image_filter_rgb(alloc_type& alloc, - const rendering_buffer& src, + const rendering_buffer& src, const color_type& back_color, interpolator_type& inter, const image_filter_lut& filter) : - base_type(alloc, src, back_color, inter, &filter) + base_type(alloc, src, back_color, inter, &filter) {} //-------------------------------------------------------------------- color_type* generate(int x, int y, unsigned len) { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); int fg[3]; @@ -677,7 +677,7 @@ namespace agg int maxx2 = base_type::source_image().width() - start - 1; int maxy2 = base_type::source_image().height() - start - 1; - int x_count; + int x_count; int weight_y; do @@ -689,7 +689,7 @@ namespace agg int x_hr = x; int y_hr = y; - + int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; @@ -699,7 +699,7 @@ namespace agg unsigned y_count = diameter; if(x_lr >= -start && y_lr >= -start && - x_lr <= maxx && y_lr <= maxy) + x_lr <= maxx && y_lr <= maxy) { y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); fg_ptr = (const value_type*)base_type::source_image().row(y_lr + start) + (x_lr + start) * 3; @@ -711,10 +711,10 @@ namespace agg do { - int weight = (weight_y * weight_array[x_hr] + - image_filter_size / 2) >> + int weight = (weight_y * weight_array[x_hr] + + image_filter_size / 2) >> image_filter_shift; - + fg[0] += *fg_ptr++ * weight; fg[1] += *fg_ptr++ * weight; fg[2] += *fg_ptr++ * weight; @@ -744,7 +744,7 @@ namespace agg else { if(x_lr < start1 || y_lr < start1 || - x_lr > maxx2 || y_lr > maxy2) + x_lr > maxx2 || y_lr > maxy2) { fg[order_type::R] = back_r; fg[order_type::G] = back_g; @@ -766,12 +766,12 @@ namespace agg do { - int weight = (weight_y * weight_array[x_hr] + - image_filter_size / 2) >> + int weight = (weight_y * weight_array[x_hr] + + image_filter_size / 2) >> image_filter_shift; - if(x_lr >= 0 && y_lr >= 0 && - x_lr < int(base_type::source_image().width()) && + if(x_lr >= 0 && y_lr >= 0 && + x_lr < int(base_type::source_image().width()) && y_lr < int(base_type::source_image().height())) { fg_ptr = (const value_type*)base_type::source_image().row(y_lr) + x_lr * 3; |