成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

AGG第四十三課例子image1從橢圓到矩形替換問題-創(chuàng)新互聯(lián)

I am basing my code on the p_w_picpaths1 example and I have changed

網(wǎng)站建設(shè)、網(wǎng)站設(shè)計,成都做網(wǎng)站公司-創(chuàng)新互聯(lián)建站已向上千多家企業(yè)提供了,網(wǎng)站設(shè)計,網(wǎng)站制作,網(wǎng)絡(luò)營銷等服務(wù)!設(shè)計與技術(shù)結(jié)合,多年網(wǎng)站推廣經(jīng)驗,合理的價格為您打造企業(yè)品質(zhì)網(wǎng)站。

the p_w_picpath 'partner' shape from an ellipse to a rectangle.

The partner rectangle comes out at X,Y and scales and rotates,

but the top left-hand corner of the p_w_picpath is always stuck at

(x,y)=3D(0,0). Only the part of the p_w_picpath that overlaps the=20

rectangle is visible, but that part scales and rotates properly.=20

When there is no overlap, there is no p_w_picpath.

I do not understand much of the the p_w_picpath2 example, so I am

lost as to what might be.the cause. Code is attached.

Would be most grateful for help and/or example code.

void p_w_picpath ( HAGG * h , int x , int y , TCHAR * imgfilename )

  {

  if ( !loadp_w_picpath ( h , imgfilename ) ) // sets p_w_picpath details in h

   {

   return ;

   }

  agg::rendering_buffer rbuf(h->pixels ,

               h->frame_width ,=20

               h->frame_height ,=20

               -(h->frame_width * h->bytesperpixel) ) ;=20

  typedef agg::renderer_base<pixfmt>           renderer_base;

  typedef agg::renderer_base<pixfmt_pre>         =

renderer_base_pre;

  typedef agg::renderer_scanline_aa_solid<renderer_base> =

renderer_solid;

  pixfmt       pixf(rbuf);

  pixfmt_pre     pixf_pre(rbuf);

  renderer_base   rb(pixf);

  renderer_base_pre rb_pre(pixf_pre);

  renderer_solid   rs(rb);

  rb.clear(agg::rgba(1.0, 1.0, 1.0));

  agg::rasterizer_scanline_aa<> pf;

  agg::scanline_u8 sl;

  IMGINFO * i =3D &h->imgs [ 0 ] ;

  double imgwd =3D i->width ;    // p_w_picpath width

  double imght =3D i->height  ;   // p_w_picpath height

  agg::trans_affine src_mtx;

  src_mtx *=3D agg::trans_affine_translation(-x,-y);

  src_mtx *=3D agg::trans_affine_rotation(-h->t.angle);  // in radians

  src_mtx *=3D agg::trans_affine_scaling(h->t.scalex , h->t.scaley);

  src_mtx *=3D agg::trans_affine_translation(x,y);

  agg::trans_affine img_mtx;

  img_mtx *=3D agg::trans_affine_translation(-x,-y);

  img_mtx *=3D agg::trans_affine_rotation(-h->t.angle);

  img_mtx *=3D agg::trans_affine_scaling(h->t.scalex , h->t.scaley);

  img_mtx *=3D agg::trans_affine_translation(x,y);

  img_mtx.invert();

  typedef agg::span_allocator<color_type> span_alloc_type;

  span_alloc_type sa;

  typedef agg::span_interpolator_linear<> interpolator_type;

  interpolator_type interpolator(img_mtx);

  // "hardcoded" bilinear filter

  typedef agg::span_p_w_picpath_filter_rgb_bilinear<color_type, =

component_order,=20

                        interpolator_type> =

span_gen_type;

  typedef agg::renderer_scanline_aa<renderer_base_pre, span_gen_type> =

renderer_type;

  agg::rendering_buffer rbuf_img(i->pixels ,

                 (int)imgwd ,=20

                 (int)imght ,=20

                 -i->stride ) ;=20

  span_gen_type sg(sa,=20

          rbuf_img,  // rendering buf with p_w_picpath pixels

          agg::rgba_pre(0, 0.4, 0, 0.5),

          interpolator);

  renderer_type ri(rb_pre, sg);

  agg::path_storage path; // partner rectangle

  path.move_to( x,y);

  path.line_to( x+imgwd, y );

  path.line_to( x+imgwd, y+imght);

  path.line_to( x, y+imght);

  path.close_polygon();

  agg::conv_transform<agg::path_storage> tr(path, src_mtx);

     =20

  pf.add_path(tr);

  agg::render_scanlines(pf, sl, ri);

  }

static void drawp_w_picpath ( )

  {

  RECT rt ;

  GetClientRect(hwndmain, &rt);

  int width =3D rt.right - rt.left;

  int height =3D rt.bottom - rt.top;

  HAGG * h =3D gethandle ( mybuf , width , height , 4 ) ;

  settrans_scale ( h , scale ) ;

  settrans_rotate ( h , degrees ) ;

//  p_w_picpath ( h , 20,50 , "bmpeivor.bmp"  ) ; // does not work

  p_w_picpath ( h , 0,0 , "bmpeivor.bmp"  ) ;  // works

  display ( h , hwndmain ) ;  // on screen

  }

作者的回答:

Transforming p_w_picpaths is tricky, especially proper calculation of the affine

matrix.

But first, if you don't need to transform it you can directly copy or blend

the p_w_picpath, it will work much faster. See renderer_base<>::copy_from(),

blend_from().

For the transformer there's a simple way of calculating the matrix as a

parallelogram, see p_w_picpath_perspective.cpp

// Note that we consruct an affine matrix that transforms

// a parallelogram to a rectangle, i.e., it's inverted.

// It's actually the same as:

// tr(0, 0, img_width, img_height, para); tr.invert();

agg::trans_affine tr(para, 0, 0, img_width, img_height);

Where "para" is double[6] that defines 3 point of the parallelogram.

困惑:

I have replaced

  agg::path_storage path; // partner rectangle

  path.move_to( x,y);

  path.line_to( x+imgwd, y );

  pathmline_to( x+imgwd, y+imght);

  path.line_to( x, y+imght);

  path.close_polygon();

  agg::conv_transform<agg::path_storage> tr(path, src_mtx);

  pf.add_path(tr);

  agg::render_scanlines(pf, sl, ri);

at the and of my p_w_picpath proc (code of the whole proc is at

the end of my original post (and at the end of this email))

by

  double para [ 6 ]

  = { 0,100 ,  0,0 , 100.0 } ; // 3 points (0,100) (0,0) and (100,0)

  agg::trans_affine tr(para, 0, 0, imgwd, imght);

  pf.add_path(tr);

  agg::render_scanlines(pf, sl, ri);

Q1.  is this the right way?

Q2.  what should the para points be expressed as functions of

    p_w_picpath top-left hand corner, p_w_picpath width and p_w_picpath height, i.e.

    x,y, imgwd, imght?

My test cases includes p_w_picpath (x,y)=(0,0), so I defined para points

(0,100), (0,0) and (100,0) just to see what would happen.

but got compilation errors:

..\agg23\include\agg_rasterizer_scanline_aa.h(465) : error C2039: 'rewind' :

is not a member of 'trans_affine'

 ..\agg23\include\agg_trans_affine.h(88) : see declaration of

'trans_affine'

and one more very similar:  'vertex' : is not a member of 'trans_affine'

作者的回答:

> double para [ 6 ] = { 0,100 ,  0,0 , 100,0 } ; // 3 points (0,100) (0,0)

> and (100,0)

> agg::trans_affine mtx(para, 0, 0, imgwd, imght);

> agg::path_storage path; // partner rectangle

> path.move_to( x,y);

> path.line_to( x+imgwd, y );

> path.line_to( x+imgwd, y+imght);

> path.line_to( x, y+imght);

> path.close_polygon();

> agg::conv_transform<agg::path_storage, agg::trans_affine> trans(path,

> mtx);

>

> pf.add_path(trans); // Note you add "trans"

>

> Then, if you want your p_w_picpath to fit exactly your parallelogram path (you

> also may want to do differently!), you need to create a copy of the matrix

> and invert it:

>

> agg::trans_affine img_mtx(mtx);

> img_mtx.invert();

I'm sorry, Ken, this is not correct; I have confused myself, so, please

discard the code above. :)

So, suppose you have an p_w_picpath of imgwd, imght and a destination

parallelogram. To define the parallelogram you need 3 points, x1,y1 - bottom

left, x2,y2 - bottom right, x3,y3 - top right. The parallelogram can also

define a 2D affine matrix: rotation, scaling, translation and skewing. You

can rasterize your destination parallelogram directly:

agg::rasterizer_scanline_aa<> ras;

ras.move_to_d(x1,y1);

ras.line_to_d(x2,y2);

ras.line_to_d(x3,y3);

ras.line_to_d(x1 + x3 - x2, y1 + y3 - y2);

So that, you can draw a solid parallelogram (well, you can also use the

path_storage if you want).

To map an p_w_picpath to it you need to create the matrix:

double para[6] = {x1,y1,x2,y2,x3,y3};

agg::trans_affine img_mtx(0, 0, imgwd, imght, para);

img_mtx.invert();

Or, which is the same:

double para[6] = {x1,y1,x2,y2,x3,y3};

agg::trans_affine img_mtx(para, 0, 0, imgwd, imght);

The first one construicts a matrix to transform a rectangle to a a

parellelogram, the second one - parallelogram to rectangle. The p_w_picpath

transformer requires namely inverse matrix, so that, you transform your

parallelogram (destination) to rectangle (p_w_picpath).

Technically that's it. But you may want to apply additional transformations.

To do that you will need two matrices:

agg::trans_affine master_mtx;

master_mtx *= agg::trans_affine_translation(. . .);

master_mtx *= agg::trans_affine_rotation(. . .);

. . .

agg::rasterizer_scanline_aa<> ras;

agg::path_storage path; // partner rectangle

path.move_to(x1,y1);

path.line_to(x2,y2);

path.line_to(x3,y3);

path.line_to(x1 + x3 - x2, y1 + y3 - y2);

path.close_polygon();

agg::conv_transform<agg::path_storage, agg::trans_affine> trans(path,

master_mtx);

Then you prepare the p_w_picpath matrix:

double para[6] = {x1,y1,x2,y2,x3,y3};

agg::trans_affine img_mtx(0, 0, imgwd, imght, para);

img_mtx *= master_mtx; //!!!!!!!!!!!!! Integrate the master transforms

img_mtx.invert();

ras.add_path(trans);

. . .Render

Now, whatever transformations you use in the master_mtxà they will be

synchronized with the p_w_picpath.

Sorry for the delay, I was kinda busy last time. and besides, I'm suffering

from constant problems with the Internet (Verizon in NYC sucks, I'm

switching to cable).

Well, I understand everyone is busy, but could someone else answer the

questions too?

First, you need to understand that a path is the primary thing in AGG.

Without path you can't draw anything. So that, to rotate an p_w_picpath you need

to create a respective path as if you wanted to fill this area with a solid

color. And then, you just substitute an p_w_picpath renderer for your solid fill.

Obviously, to transform the whole p_w_picpath you need to create a parallelogram

path (a rectangle in particular). You can do that calculating the points

manually:

ras.move_to_d(x1, y1);

ras.line_to_d(x2, y2);

. . .

You you can use transformations.

Next, trans_affine doesn't have any "VertexSource" interface, it can't

generate vertices. It can only transform them: affine.transform(&x, &y); To

add affine transformer into your pipeline you also need conv_transform:

double para [ 6 ] = { 0,100 ,  0,0 , 100,0 } ; // 3 points (0,100) (0,0) and

(100,0)

agg::trans_affine mtx(para, 0, 0, imgwd, imght);

agg::path_storage path; // partner rectangle

path.move_to( x,y);

path.line_to( x+imgwd, y );

path.line_to( x+imgwd, y+imght);

path.line_to( x, y+imght);

path.close_polygon();

agg::conv_transform<agg::path_storage, agg::trans_affine> trans(path, mtx);

pf.add_path(trans); // Note you add "trans"

Then, if you want your p_w_picpath to fit exactly your parallelogram path (you

also may want to do differently!), you need to create a copy of the matrix

and invert it:

agg::trans_affine img_mtx(mtx);

img_mtx.invert();

Well, I realize that it all is pretty confusing. But this kind of a design

is most flexible.

摘自:http://sourceforge.net/p/vector-agg/mailman/vector-agg-general/?viewmonth=200511&page=0

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

網(wǎng)頁名稱:AGG第四十三課例子image1從橢圓到矩形替換問題-創(chuàng)新互聯(lián)
分享URL:http://jinyejixie.com/article16/issgg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站Google、面包屑導(dǎo)航、移動網(wǎng)站建設(shè)、搜索引擎優(yōu)化、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
双城市| 康保县| 阿鲁科尔沁旗| 任丘市| 蒙山县| 阜城县| 巴彦县| 隆昌县| 天台县| 惠东县| 保亭| 高清| 汉沽区| 汾阳市| 永年县| 新建县| 汾阳市| 耿马| 策勒县| 剑河县| 易门县| 扎赉特旗| 祁东县| 潮州市| 长海县| 桓仁| 新建县| 兰考县| 宿松县| 南丹县| 宁化县| 牟定县| 山东省| 沙田区| 海阳市| 涞源县| 双牌县| 绥化市| 蒙山县| 晋江市| 岱山县|