Re: [Pgui-devel] Bitmap rotation

2003-01-15 Thread Olivier Bornet
Hello,

> In our app, we want to turn an image from 90 or 270 degres.
> To achieve this we thought about displaying the bitmap in a canvas and
> using the PG_GROP_ROTATEBITMAP parameter with something like :

After some tests, I have found the solution. This require 3 calls to
pgWriteCmd (). Here are they for a rotation of 90, assuming h and w are
height and width of the original image:

pgWriteCmd (canvas,
PGCANVAS_GROP, 2,
PG_GROP_SETANGLE, 90);

pgWriteCmd (canvas,
PGCANVAS_GROP, 5,
PG_GROP_SETSRC, 0, 0, w, h);

pgWriteCmd (canvas,
PGCANVAS_GROP, 6,
PG_GROP_ROTATEBITMAP, 0, w, h, w, image);

Unfortunately, if w != h, this don't work. For having this working, we
need to patch gcore/render.c with the attached patch. Mainly, it get the
bitmap width and height always correctly, and not swap them if we rotate
of 90 or 270. I think the patch is OK, because we don't need to have the
rotate values, but the original values.

If this is OK, I will apply the patch. If not, it may be because I don't
use the pgWriteCmd correctly for rotate the bitmap, so, if anyone has a
tip...

Good day.

Olivier

PS. Here are the values to change for other angles:

switch (angle) {
case 0:
  pgWriteCmd (canvas,
  PGCANVAS_GROP, 6,
  PG_GROP_ROTATEBITMAP, 0, 0, w, h, image);
  break;
case 90:
  pgWriteCmd (canvas,
  PGCANVAS_GROP, 6,
  PG_GROP_ROTATEBITMAP, 0, w, h, w, image);
  break;
case 180:
  pgWriteCmd (canvas,
  PGCANVAS_GROP, 6,
  PG_GROP_ROTATEBITMAP, w, h, w, h, image);
  break;
case 270:
  pgWriteCmd (canvas,
  PGCANVAS_GROP, 6,
  PG_GROP_ROTATEBITMAP, h, 0, h, w, image);
  break;
default:
}
-- 
Olivier Bornet  http://www.smartdata.ch/
[EMAIL PROTECTED] SMARTDATA SA
Phone: +41-27-723'55'03 Rue du Collège 5A
GPG key ID: C53D9218CH-1920 Martigny

Index: render.c
===
RCS file: /cvsroot/pgui/pgserver/gcore/render.c,v
retrieving revision 1.48
diff -u -r1.48 render.c
--- render.c1 Jan 2003 03:42:59 -   1.48
+++ render.c15 Jan 2003 13:00:22 -
@@ -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;



msg01524/pgp0.pgp
Description: PGP signature


Re: [Pgui-devel] Bitmap rotation

2003-01-15 Thread Olivier Bornet
Hello again,

another question is : can we use a bitmap instead of a canvas. This
mean, instead of:

> pgWriteCmd (canvas,
> PGCANVAS_GROP, 6,
> PG_GROP_ROTATEBITMAP, 0, w, h, w, image);

can I use:
  pgRender (bitmap,
PGCANVAS_GROP, 6,
PG_GROP_ROTATEBITMAP, 0, w, h, w, image);

assuming bitmap was created correctly before (with pgCreateBitmap). I
have try this without success (just a little time tough). I can do other
pgRender things, like PG_GROP_RECT or PG_GROP_LINE, but the use of
PG_GROP_ROTATEBITMAP or PG_GROP_BITMAP do nothing.

Thanks in advance.

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: C53D9218CH-1920 Martigny



msg01525/pgp0.pgp
Description: PGP signature