AGG 映像訪問器(Image Accessor)

來源:互聯網
上載者:User
文章目錄
  • 映像訪問器Image Accessor
  • 映像過濾器(Image Filter)
映像訪問器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. ...
顯示效果

 

www.cppprog.com

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.