Getting back into writing Pascal Code, and I'm trying the following code, all it does is loads a JPG, rotates it and then displays it.
Procedure DisplayPiece(X,Y,PieceNum,Rotation: Integer);
Var
jpg : TJPEGImage;
bmp : TBitMap;
bmp2 : TBitmap;
rect : TRect;
TileFileName : string;
Begin
Try
TileFileName := GetCurrentDir + '/Tiles/' + inttostr(PieceNum) + '.JPG';
jpg :=TJPEGImage.Create;
jpg.LoadFromFile(TileFileName);
bmp :=TBitmap.Create;
bmp.assign(jpg);
bmp2 := Tbitmap.Create;
bmp2 := (Rotate(bmp,rotation));
rect := Main.Drawgrid1.CellRect((X),(Y));
Main.Drawgrid1.Canvas.StretchDraw(rect,bmp2);
Board_Array [X,Y] := Piece_array[PieceNum];
Finally
End;
bmp.Free;
bmp2.Free;
end;
I've included the 2 .Free commands to manage memory usage, but when it hits the 2nd one my program errors.
I'm using Ubuntu & Windows XP and Lazarus 0.9.26.2(on Ubuntu) & 0.9.28.2(On XP), FreePascal 2.2.4 on both.
Any ideas ?