Recent

Author Topic: This code works under Windows, but not under Linux :(  (Read 4646 times)

daspuner

  • Newbie
  • Posts: 1
This code works under Windows, but not under Linux :(
« on: November 01, 2005, 10:12:49 am »
Good morning/evening/night every body.

This piece of code works perfectly under Windows and generates a PNG image  corresponding in the expected result, but the same code under Linux generates a black image..


Quote
procedure TfrmMain.HandleOnSaveBitmapWU(AIsFahLog : Boolean);
var
   Bitmap: TBitmap;
   Source: TRect;
   Dest: TRect;
   aFile : String;
begin
  if assigned(self.CurrentWU) then
  begin
    Bitmap := TBitmap.Create;
    try
      with Bitmap do
      begin
        Width := TaChart1.Width;
        Height := TaChart1.Height;
        Dest := Rect(0, 0,Width,Height);
      end;
      Source := Rect(0, 0,TAChart1.Width, TAChart1.Height);
      Bitmap.Canvas.CopyRect(Dest, TaChart1.Canvas, Source);
      with self.currentWU do
      begin
        if not DirectoryExists(ExtractFilePath(application.exename) + 'png') then
          ForceDirectories(ExtractFilePath(application.exename) + 'png');
       WritePicture(Bitmap, ExtractFilePath(Application.ExeName) + format('png/%s(%d,%d,%d)_%s.png', [name, run, clone, gen, formatdatetime('yyyymmdd_hhnn', StartDate)]));
      end;
    finally
      Bitmap.Free;
    end;
  end;
end;


procedure WritePicture(ABitmap:TBitmap; AFile: string);
var
  IntfImg1 : TLazIntfImage;
begin
 try
   IntfImg1:=TLazIntfImage.Create(0,0);
   IntfImg1.LoadFromBitmap(ABitmap.Handle,ABitmap.MaskHandle);
   IntfImg1.SaveToFile(AFile);
 finally
   IntfImg1.Free;
 end;
end;  


Packages : Tagraph for Tachart1.

Configuration for Windows:
 Windows Xp Pro Sp2
 Lazarus Version #: 0.9.10 beta
 Free Pascal Compiler version 2.0.1  for i386

Configuration for Linux :
 Ubuntu "Breezy"
 Lazarus Version #: 0.9.10 beta
 Free Pascal Compiler version 2.0.1  for i386
 GTK+

Any idea  ?

What about my English?
I'm a French gui, 50 years old, and it is the first time I write here, and in English on a forum  :?