打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
AGG 图像访问器(Image Accessor)
AGG 图像访问器(Image Accessor)
2010-07-11 21:59

图像访问器Image Accessor

也许有不少同学看到开头的线段生成器一节时,已经尝试修改示例代码中的span_image_filter_rgb_bilinear_clip了(比如改成span_image_filter_rgb_bilinear)。不过编译时会出错,这是因为大部分的线段生成器类接受的Source模板不是 PixelFormat Renderer,而是Image Accessor即图像存取器。

头文件

  1. #include <agg_image_accessors.h>

类型

  1. template<class PixFmt>
  2. class agg::image_accessor_clip // 图像以外的地方用指定颜色填充
  3. template<class PixFmt>
  4. class agg::image_accessor_clone // 图像以外的地方以图像边缘填充
  5. template<class PixFmt>
  6. class agg::image_accessor_no_clip // 图像以外不可读取,否则引发异常
  7. template<class PixFmt, class WrapX, class WrapY>
  8. class agg::image_accessor_wrap // 平铺图像,平铺方式由WrapX和WrapY指定

实验代码

示例代码中的span_image_filter_rgb_bilinear_clip部分改成下面的代码

  1. ...
  2. // 线段生成器
  3. //typedef agg::span_image_filter_rgb_bilinear_clip<agg::pixfmt_bgr24,
  4. //interpolator_type > span_gen_type; // 这个就是Span Generator
  5. //span_gen_type span_gen(pixf_img, agg::rgba(0,1,0), ip);
  6. // 图像访问器
  7. typedef agg::image_accessor_clone<agg::pixfmt_bgr24> image_accessor_type;
  8. image_accessor_type     accessor(pixf_img);
  9. // 使用span_image_filter_rgb_bilinear
  10. typedef agg::span_image_filter_rgb_bilinear<
  11.      image_accessor_type,
  12.      interpolator_type > span_gen_type;
  13. span_gen_type span_gen(accessor, ip);
  14. ...

建议把后面的ras.add_path(ell)改成ras.add_path(ccell)

显示效果


image_accessor_wrap类要指定WrapX和WrapY,可选的有:

wrap_mode_reflect    wrap_mode_reflect_auto_pow2    wrap_mode_pow2    wrap_mode_repeat    wrap_mode_repeat_auto_pow2    wrap_mode_repeat_pow2

比如我们把本例中的image_accessor_type定义改成

  1. //typedef agg::image_accessor_clone<agg::pixfmt_bgr24> image_accessor_type;
  2. typedef agg::image_accessor_wrap<agg::pixfmt_bgr24,
  3.      agg::wrap_mode_reflect,agg::wrap_mode_repeat> image_accessor_type;

显示效果是


(为了突出效果,用矩阵img_mtx把源缩小了)

图像过滤器(Image Filter)

在一些线段生成器里,比如span_image_filter_[gray|rgb|rgba],span_image_resample_[gray|rgb|rgba]等类,它们的构造函数还有一个“const image_filter_lut &filter”参数,这个参数用于变换图像的像素值。它们的名称都以image_filter作为前缀,AGG中称为Image Filter(图像过滤器)。

头文件

  1. #include <agg_image_filters.h>

类型

  1. image_filter_bilinear;
  2. image_filter_blackman;
  3. image_filter_blackman[36|64|100|144|196|256];
  4. image_filter_kaiser;
  5. image_filter_lanczos;
  6. image_filter_lanczos[36|64|100|144|196|256];
  7. image_filter_mitchell;
  8. ...还有很多呢...

实验代码

把上面的span_image_filter_rgb_bilinear改成span_image_resample_rgb_affine

  1. ...
  2. //typedef agg::image_accessor_clone<agg::pixfmt_bgr24> image_accessor_type;
  3. typedef agg::image_accessor_wrap<agg::pixfmt_bgr24,
  4.      agg::wrap_mode_reflect,agg::wrap_mode_repeat> image_accessor_type;
  5. image_accessor_type     accessor(pixf_img);
  6.             
  7. //typedef agg::span_image_filter_rgb_bilinear<
  8. //     image_accessor_type,
  9. //     interpolator_type > span_gen_type;
  10. //span_gen_type span_gen(accessor, ip);
  11. typedef agg::span_image_resample_rgb_affine<image_accessor_type> span_gen_type;
  12. span_gen_type span_gen(accessor, ip, agg::image_filter_sinc36());
  13. ...

显示效果

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Weighted Guided Image Filtering 论文学习
[翻译] AGG Reference 之 Basic Renderers(基础渲染器)
基于jQuery图像碎片切换效果插件FragmentFly
span 文本内容超过宽度自动换行
使用 HTML、CSS 和 JS 创建响应式可过滤的游戏+工具展示页面
HALCON算子函数(五)Filter
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服