Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

compositing.cpp File Reference

#include <stdio.h>
#include "agg_rendering_buffer.h"
#include "agg_renderer_base.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_scanline_u.h"
#include "agg_renderer_scanline.h"
#include "agg_rounded_rect.h"
#include "agg_pixfmt_rgba.h"
#include "agg_span_allocator.h"
#include "agg_span_gradient.h"
#include "agg_gsv_text.h"
#include "agg_span_interpolator_linear.h"
#include "platform/agg_platform_support.h"
#include "ctrl/agg_slider_ctrl.h"
#include "ctrl/agg_rbox_ctrl.h"

Go to the source code of this file.

Namespaces

namespace  agg

Classes

struct  gradient_linear_color< color >
class  the_application

Defines

#define pix_format   agg::pix_format_bgra32

Typedefs

typedef agg::rgba8 color
typedef agg::order_bgra order
typedef agg::int32u pixel_type
typedef agg::rendering_buffer rbuf_type
typedef agg::blender_rgba<
color, order
prim_blender_type
typedef agg::pixfmt_alpha_blend_rgba<
prim_blender_type, rbuf_type
prim_pixfmt_type
typedef agg::renderer_base<
prim_pixfmt_type
prim_ren_base_type

Enumerations

enum  flip_y_e { flip_y = true }

Functions

void force_comp_op_link ()
agg::trans_affine gradient_affine (double x1, double y1, double x2, double y2, double gradient_d2=100.0)
template<class RenBase>
void circle (RenBase &rbase, color c1, color c2, double x1, double y1, double x2, double y2, double shadow_alpha)
template<class RenBase>
void dst_shape (RenBase &rbase, color c1, color c2, double x1, double y1, double x2, double y2)
int agg_main (int argc, char *argv[])


Define Documentation

#define pix_format   agg::pix_format_bgra32
 

Definition at line 24 of file compositing.cpp.


Typedef Documentation

typedef agg::rgba8 color
 

Definition at line 20 of file compositing.cpp.

typedef agg::order_bgra order
 

Definition at line 21 of file compositing.cpp.

typedef agg::int32u pixel_type
 

Definition at line 22 of file compositing.cpp.

typedef agg::blender_rgba<color, order> prim_blender_type
 

Definition at line 26 of file compositing.cpp.

typedef agg::pixfmt_alpha_blend_rgba<prim_blender_type, rbuf_type> prim_pixfmt_type
 

Definition at line 27 of file compositing.cpp.

typedef agg::renderer_base<prim_pixfmt_type> prim_ren_base_type
 

Definition at line 28 of file compositing.cpp.

typedef agg::rendering_buffer rbuf_type
 

Definition at line 23 of file compositing.cpp.


Enumeration Type Documentation

enum flip_y_e
 

Enumerator:
flip_y 

Definition at line 18 of file compositing.cpp.

00018 { flip_y = true };


Function Documentation

int agg_main int  argc,
char *  argv[]
 

Definition at line 377 of file compositing.cpp.

References platform_support::caption(), flip_y, force_comp_op_link(), platform_support::img_ext(), platform_support::init(), platform_support::load_img(), platform_support::message(), pix_format, platform_support::run(), and agg::window_resize.

00378 {
00379     force_comp_op_link();
00380     the_application app(pix_format, flip_y);
00381     app.caption("AGG Example. Compositing Modes");
00382 
00383     const char* img_name = "compositing";
00384     if(argc >= 2) img_name = argv[1];
00385     if(!app.load_img(1, img_name)) 
00386     {
00387         char buf[256];
00388         if(strcmp(img_name, "compositing") == 0)
00389         {
00390             sprintf(buf, "File not found: %s%s. Download http://www.antigrain.com/%s%s\n"
00391                          "or copy it from another directory if available.",
00392                     img_name, app.img_ext(), img_name, app.img_ext());
00393         }
00394         else
00395         {
00396             sprintf(buf, "File not found: %s%s", img_name, app.img_ext());
00397         }
00398         app.message(buf);
00399         return 1;
00400     }
00401 
00402 
00403     if(app.init(600, 400, agg::window_resize))
00404     {
00405         return app.run();
00406     }
00407     return 1;
00408 }

void circle RenBase &  rbase,
color  c1,
color  c2,
double  x1,
double  y1,
double  x2,
double  y2,
double  shadow_alpha
 

Definition at line 121 of file compositing.cpp.

References rasterizer_scanline_aa::add_path(), agg::calc_distance(), gradient_affine(), ellipse::init(), agg::render_scanlines_aa(), and agg::render_scanlines_aa_solid().

Referenced by the_application::render_scene().

00124 {
00125     typedef RenBase renderer_base_type;
00126     typedef agg::gradient_x gradient_func_type;
00127     typedef agg::gradient_linear_color<color> color_func_type;
00128     typedef agg::span_interpolator_linear<> interpolator_type;
00129     typedef agg::span_allocator<color> span_allocator_type;
00130     typedef agg::span_gradient<color, 
00131                                interpolator_type, 
00132                                gradient_func_type, 
00133                                color_func_type> span_gradient_type;
00134 
00135     gradient_func_type  gradient_func;                   // The gradient function
00136     agg::trans_affine   gradient_mtx = gradient_affine(x1, y1, x2, y2, 100);
00137     interpolator_type   span_interpolator(gradient_mtx); // Span interpolator
00138     span_allocator_type span_allocator;                  // Span Allocator
00139     color_func_type     color_func(c1, c2);
00140     span_gradient_type  span_gradient(span_interpolator, 
00141                                       gradient_func, 
00142                                       color_func, 
00143                                       0, 100);
00144     agg::rasterizer_scanline_aa<> ras;
00145     agg::scanline_u8 sl;
00146 
00147     double r = agg::calc_distance(x1, y1, x2, y2) / 2;
00148     agg::ellipse ell((x1+x2)/2+5, (y1+y2)/2-3, r, r, 100);
00149 
00150     ras.add_path(ell);
00151     agg::render_scanlines_aa_solid(ras, sl, rbase, 
00152                                    agg::rgba(0.6, 0.6, 0.6, 0.7*shadow_alpha));
00153 
00154     ell.init((x1+x2)/2, (y1+y2)/2, r, r, 100);
00155     ras.add_path(ell);
00156     agg::render_scanlines_aa(ras, sl, rbase, span_allocator, span_gradient);
00157 }

void dst_shape RenBase &  rbase,
color  c1,
color  c2,
double  x1,
double  y1,
double  x2,
double  y2
 

Definition at line 162 of file compositing.cpp.

References rasterizer_scanline_aa::add_path(), gradient_affine(), and agg::render_scanlines_aa().

Referenced by the_application::render_scene().

00164 {
00165     typedef RenBase renderer_base_type;
00166     typedef agg::gradient_x gradient_func_type;
00167     typedef agg::gradient_linear_color<color> color_func_type;
00168     typedef agg::span_interpolator_linear<> interpolator_type;
00169     typedef agg::span_allocator<color> span_allocator_type;
00170     typedef agg::span_gradient<color, 
00171                                interpolator_type, 
00172                                gradient_func_type, 
00173                                color_func_type> span_gradient_type;
00174 
00175     gradient_func_type  gradient_func;                   // The gradient function
00176     agg::trans_affine   gradient_mtx = gradient_affine(x1, y1, x2, y2, 100);
00177     interpolator_type   span_interpolator(gradient_mtx); // Span interpolator
00178     span_allocator_type span_allocator;                  // Span Allocator
00179     color_func_type     color_func(c1, c2);
00180     span_gradient_type  span_gradient(span_interpolator, 
00181                                       gradient_func, 
00182                                       color_func, 
00183                                       0, 100);
00184     agg::rasterizer_scanline_aa<> ras;
00185     agg::scanline_u8 sl;
00186 
00187     agg::rounded_rect shape(x1, y1, x2, y2, 40);
00188 //    agg::ellipse shape((x1+x2)/2, (y1+y2)/2, fabs(x2-x1)/2, fabs(y2-y1)/2, 100);
00189 
00190     ras.add_path(shape);
00191     agg::render_scanlines_aa(ras, sl, rbase, span_allocator, span_gradient);
00192 }

void force_comp_op_link  ) 
 

Definition at line 30 of file compositing.cpp.

References comp_op_rgba_color_dodge::blend_pix().

Referenced by agg_main().

00031 {
00032     // For unknown reason Digital Mars C++ doesn't want to link these 
00033     // functions if they are not specified explicitly. 
00034     agg::int8u p[4] = {0};
00035     agg::comp_op_rgba_contrast   <color, order>::blend_pix(p,0,0,0,0,0);
00036     agg::comp_op_rgba_darken     <color, order>::blend_pix(p,0,0,0,0,0);
00037     agg::comp_op_rgba_lighten    <color, order>::blend_pix(p,0,0,0,0,0);
00038     agg::comp_op_rgba_color_dodge<color, order>::blend_pix(p,0,0,0,0,0);
00039     agg::comp_op_rgba_color_burn <color, order>::blend_pix(p,0,0,0,0,0);
00040     agg::comp_op_rgba_hard_light <color, order>::blend_pix(p,0,0,0,0,0);
00041     agg::comp_op_rgba_soft_light <color, order>::blend_pix(p,0,0,0,0,0);
00042     agg::comp_op_rgba_difference <color, order>::blend_pix(p,0,0,0,0,0);
00043     agg::comp_op_rgba_exclusion  <color, order>::blend_pix(p,0,0,0,0,0);
00044     agg::comp_op_rgba_src_atop   <color, order>::blend_pix(p,0,0,0,0,0);
00045     agg::comp_op_rgba_dst_atop   <color, order>::blend_pix(p,0,0,0,0,0);
00046     agg::comp_op_rgba_xor        <color, order>::blend_pix(p,0,0,0,0,0);
00047     agg::comp_op_rgba_plus       <color, order>::blend_pix(p,0,0,0,0,0);
00048     agg::comp_op_rgba_minus      <color, order>::blend_pix(p,0,0,0,0,0);
00049     agg::comp_op_rgba_multiply   <color, order>::blend_pix(p,0,0,0,0,0);
00050     agg::comp_op_rgba_screen     <color, order>::blend_pix(p,0,0,0,0,0);
00051     agg::comp_op_rgba_overlay    <color, order>::blend_pix(p,0,0,0,0,0);
00052     agg::comp_op_rgba_src        <color, order>::blend_pix(p,0,0,0,0,0);
00053     agg::comp_op_rgba_dst        <color, order>::blend_pix(p,0,0,0,0,0);
00054     agg::comp_op_rgba_src_over   <color, order>::blend_pix(p,0,0,0,0,0);
00055     agg::comp_op_rgba_dst_over   <color, order>::blend_pix(p,0,0,0,0,0);
00056     agg::comp_op_rgba_src_in     <color, order>::blend_pix(p,0,0,0,0,0);
00057     agg::comp_op_rgba_dst_in     <color, order>::blend_pix(p,0,0,0,0,0);
00058     agg::comp_op_rgba_src_out    <color, order>::blend_pix(p,0,0,0,0,0);
00059     agg::comp_op_rgba_dst_out    <color, order>::blend_pix(p,0,0,0,0,0);
00060     agg::comp_op_rgba_clear      <color, order>::blend_pix(p,0,0,0,0,0);
00061 }

agg::trans_affine gradient_affine double  x1,
double  y1,
double  x2,
double  y2,
double  gradient_d2 = 100.0
 

Definition at line 104 of file compositing.cpp.

References trans_affine::invert(), and trans_affine::reset().

Referenced by circle(), and dst_shape().

00106 {
00107     agg::trans_affine mtx;
00108     double dx = x2 - x1;
00109     double dy = y2 - y1;
00110     mtx.reset();
00111     mtx *= agg::trans_affine_scaling(sqrt(dx * dx + dy * dy) / gradient_d2);
00112     mtx *= agg::trans_affine_rotation(atan2(dy, dx));
00113     mtx *= agg::trans_affine_translation(x1, y1);
00114     mtx.invert();
00115     return mtx;
00116 }


© sourcejam.com 2005-2008