[Lazarus] AggPas transformations not working

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Jul 19 20:08:17 CEST 2010


On Sun, 18 Jul 2010 17:26:39 -0300
Horacio Jamilis <hjamilis at pymesoft.com.ar> wrote:

> Hi,
> 
> I am traying to use AggPas included in the lazarus SVN tree to draw maps 
> (GIS application).
> I was able to draw the map correctly but my next step is to rotate the 
> map ... and the AggRotate method seems to not work... and the same for 
> the AggTranslate method...
> 
> Was anybody able to make any of this transformations to work? (specially 
> the rotate one).
> 
> My code is like this:
> 
> procedure TForm1 .Button1Click (Sender : TObject );
> const
>    fTextAngle = 300;
>    fImageAngle = 45;
>    fWidth = 200;
>    fHeight = 200;
> var
>          fMap : TBitmap;
>          fMapCanvas : TAggLCLCanvas;
> begin
>        fMap := TBitmap.Create;
>        fMap.PixelFormat := pf32bit;
>        fMapCanvas := TAggLCLCanvas.Create;
>        fMapCanvas.Image.PixelFormat:= afpimRGBA32;
>        fMapCanvas.Image.SetSize(fWidth,fHeight);
> // Start of drawing routines
>        fMapCanvas.FillRect(Rect(0,0,fWidth-1,fHeight-1));
>        fMapCanvas.Pen.Color := $FF0000;
>        fMapCanvas.Pen.Width := 2;
>        fMapCanvas.MoveTo(50,10);
>        fMapCanvas.LineTo(50,70);
> // in fact lots of lines... one is enaught for the sample
>        fMapCanvas.Font.Color := clMaroon;
>        
> fMapCanvas.Font.LoadFromFile('Tahoma',12,false,false,AGG_VectorFontCache,degtorad(fTextAngle),True);
>        fMapCanvas.Font.AggAlignX := AGG_AlignLeft;
>        fMapCanvas.Font.AggAlignY := AGG_AlignCenter;
>        fMapcanvas.AggTextOut(10,160,'Sample Angled Text',false,0,0);
> // End of drawing routines
>          fMapCanvas.AggTranslate(-fWidth / 2 ,-fHeight / 2 );
>          fMapCanvas.AggRotate   (DegToRad(fImageAngle));
>          fMapCanvas.AggTranslate(fWidth / 2 ,fHeight / 2 );

AggRotate rotates the coordinate system, not the image.
You have to put the AggRotate in front of drawing operations, not
behind.


>          fMap.LoadFromIntfImage(fMapCanvas.Image.IntfImg);
>          fMap.SaveToFile('c:\test.bmp');
>       fMapCanvas.Free;
>      fMap.Free;
> end;
> 
> Any help is apprecaited.


Mattias




More information about the Lazarus mailing list