Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-07

AggPas transformations not working

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Horacio Jamilis

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 );
         fMap.LoadFromIntfImage(fMapCanvas.Image.IntfImg);
         fMap.SaveToFile('c:\test.bmp');
      fMapCanvas.Free;
     fMap.Free;
end;

Any help is apprecaited.

Horacio

Reply by email

Mattias Gaertner
to Horacio Jamilis
Show quoted text 45 lines
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.

Show quoted text 7 lines
fMap.LoadFromIntfImage(fMapCanvas.Image.IntfImg); fMap.SaveToFile('c:\test.bmp'); fMapCanvas.Free; fMap.Free; end; Any help is apprecaited.

Mattias

Reply by email

Horacio Jamilis
to Mattias Gaertner

Thank you very much! It WORKS!
After all the week end looking for this ...
Now I could continue
Thanks again!

Horacio

El 19/07/2010 15:08, Mattias Gaertner escribi?:

Show quoted text 9 lines
AggRotate rotates the coordinate system, not the image. You have to put the AggRotate in front of drawing operations, not behind. Mattias --

Reply by email