Recent

Author Topic: AggPas and raster background  (Read 4614 times)

scrat

  • New member
  • *
  • Posts: 8
AggPas and raster background
« on: June 27, 2010, 11:29:20 pm »
Hello,

I try to use aggpas to draw polyline, elipse ... on a raster background.
I use this sample code:

Code: [Select]
Unit Unit1;

{$mode objfpc}{$H+}

Interface

Uses
Classes, SysUtils, LCLProc, FileUtil, LResources, Forms, Controls, Graphics,
Dialogs, ExtCtrls, FPimage, agg_fpimage, Agg_LCL;

Type

  { TForm1 }

  TForm1 = Class(TForm)
    Image1: TImage;
    Procedure FormCreate(Sender: TObject);
    Private
    Public
  End;

Var
  Form1: TForm1;

  Implementation

{ TForm1 }

Procedure TForm1.FormCreate(Sender: TObject);

Var
  png: tportablenetworkgraphic;
  back: TaggFpimage;
  Agg: TAggLCLCanvas;

Begin
  Form1.Width := 256;
  form1.Height := 256;
  Try
    back := TaggFpImage.Create(256,256);
    back.PixelFormat := afpimRGBA32;
    png := tportablenetworkgraphic.Create;
    Agg := TAggLCLCanvas.Create;

    With Agg Do
      Begin
        Image.PixelFormat := afpimRGBA32;
        Image.SetSize(256,256);

        //Chargement du background depuis png
        back.LoadFromFile('back.png');
        agg.AggCopyImage(back,0,0);

        //elipse bleu interieur rouge alpha
        Brush.fpColor := fpcolor($ffff,0,0,$5000);
        Pen.fpColor := FPColor(0,0,$ffff,$FFFF);
        pen.Width := 3;
        aggEllipse(128,128,60,85);
        // chargement du canvas dans un png
        png.LoadFromIntfImage(Agg.Image.IntfImg);
        png.SaveToFile('test.png');

        image1.Picture.Assign(png);
      End;

  Finally
    agg.free;
    png.Free;
    back.Free;
  End;
End;

initialization
  {$I unit1.lrs}

End.
                                             

The background is this png
(http://img685.imageshack.us/img685/5302/backsu.png)


and the result :
(http://img706.imageshack.us/img706/1940/reult.png)


Background Picture is black and white and appears four times smaller than the original

Have you an idea

Thanks

Fpc 2.5.1
Lazarus Svn 26308
Linux ubuntu 10.04
« Last Edit: June 27, 2010, 11:30:56 pm by scrat »

 

TinyPortal © 2005-2018