Hi Micah,

> There's a good example of this in action in the pgserver code for rotating
> bitmaps when entering and leaving a rotated mode. The syntax is different
> since it doesn't go through the gropnode layer, but semantically it's 
> the same. On line 518 of video/video_drivers.c, the bitmap_rotate function
> does exactly this to copy a bitmap while rotating it.

Thanks. I have get this portion of code, and adapted to use on gropnode
with pgWriteCmd ().

You say:

> The source rectangle is always in unrotated coordinates, on the source bitmap.
> The destination rectangle for the rotatebitmap gropnode has the unrotated top-left
> as its top-left coordinate, and the unrotated width and height. 

and my patch was:

> > diff -u -r1.48 render.c
> > --- render.c        1 Jan 2003 03:42:59 -0000       1.48
> > +++ render.c        15 Jan 2003 13:00:22 -0000
> > @@ -879,10 +879,7 @@
> >    case PG_GROP_ROTATEBITMAP:
> >      if (iserror(rdhandle((void**)&bit,PG_TYPE_BITMAP,-1,
> >                      n->param[0])) || !bit) break;
> > -    if (r->angle == 90 || r->angle==270)
> > -      VID(bitmap_getsize) (bit,&bh,&bw);
> > -    else
> > -      VID(bitmap_getsize) (bit,&bw,&bh);
> > +    VID(bitmap_getsize) (bit,&bw,&bh);
> >       
> >      /* Source rect clipping */
> >      clipsrc = r->src;

So, my patch seem OK for me. ;-)
Because the bw and bh is the coordinates of the _source_ rectangle. And
it is unrotated. If you compare the following rotating action:

    VID(rotateblit) (r->output,n->r.x,n->r.y,
                     bit,clipsrc.x,clipsrc.y,clipsrc.w,clipsrc.h,
                     &r->clip,r->angle,r->lgop);

clipsrc is used on the _source_ rectangle. Here is a sample: we have a
source bitmap of 100x50 pixels. You want to rotated it to 90. Without my
patch, you will have:
    - bw = 50
    - bh = 100
After that, you have the checks:
    if (clipsrc.x < 0) clipsrc.x = 0;
    if (clipsrc.y < 0) clipsrc.y = 0;
    if (clipsrc.w > (bw - clipsrc.x)) clipsrc.w = bw - clipsrc.x;
    if (clipsrc.h > (bh - clipsrc.y)) clipsrc.h = bh - clipsrc.y;
This will result of :
    - clipsrc.x = 0
    - clipsrc.x = 0
    - clipsrc.w = 50  (because bw was set to 50)
    - clipsrc.h = 50  (because clipsrc.h is 50)

So, the rotation is done correctly after that, but with only the first
part of the source bitmap copyed (and an empty space just after it).

Am I right ?

                Olivier
-- 
Olivier Bornet                      http://www.smartdata.ch/
[EMAIL PROTECTED]         SMARTDATA SA
Phone: +41-27-723'55'03             Rue du Coll�ge 5A
GPG key ID: C53D9218                CH-1920 Martigny

Attachment: msg01528/pgp00000.pgp
Description: PGP signature

Reply via email to