/examples/loadpicture.pas

http://github.com/graemeg/lazarus · Pascal · 67 lines · 35 code · 10 blank · 22 comment · 0 complexity · eb7a345fa3c6b548d3b5f67b777773ae MD5 · raw file

  1. {
  2. ***************************************************************************
  3. * *
  4. * This source is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This code is distributed in the hope that it will be useful, but *
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
  12. * General Public License for more details. *
  13. * *
  14. * A copy of the GNU General Public License is available on the World *
  15. * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
  16. * obtain it by writing to the Free Software Foundation, *
  17. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. * *
  19. ***************************************************************************
  20. }
  21. program LoadPicture;
  22. {$mode objfpc}{$H+}
  23. uses
  24. Interfaces,
  25. Classes, SysUtils, Forms, Controls, Graphics, ExtCtrls;
  26. type
  27. TLoadBitmapForm = class(TForm)
  28. Image1: TImage;
  29. public
  30. constructor Create(TheOwner: TComponent); override;
  31. end;
  32. { TLoadBitmapForm }
  33. constructor TLoadBitmapForm.Create(TheOwner: TComponent);
  34. var
  35. Filename: String;
  36. begin
  37. inherited CreateNew(TheOwner, 1);
  38. Filename:=SetDirSeparators('../images/splash_logo.xpm');
  39. Caption := 'Example: Loading picture from file';
  40. Width := 429;
  41. Height := 341;
  42. Position:= poScreenCenter;
  43. Image1:=TImage.Create(Self);
  44. with Image1 do begin
  45. Name:='Image1';
  46. Parent:=Self;
  47. Align:=alClient;
  48. Picture.LoadFromFile(Filename);
  49. end;
  50. end;
  51. var
  52. LoadBitmapForm: TLoadBitmapForm;
  53. begin
  54. Application.Initialize;
  55. Application.CreateForm(TLoadBitmapForm,LoadBitmapForm);
  56. Application.Run;
  57. end.