PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/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}
21program LoadPicture;
22
23{$mode objfpc}{$H+}
24
25uses
26  Interfaces,
27  Classes, SysUtils, Forms, Controls, Graphics, ExtCtrls;
28  
29type
30  TLoadBitmapForm = class(TForm)
31    Image1: TImage;
32  public
33    constructor Create(TheOwner: TComponent); override;
34  end;
35
36{ TLoadBitmapForm }
37
38constructor TLoadBitmapForm.Create(TheOwner: TComponent);
39var
40  Filename: String;
41begin
42  inherited CreateNew(TheOwner, 1);
43  
44  Filename:=SetDirSeparators('../images/splash_logo.xpm');
45
46  Caption := 'Example: Loading picture from file';
47  Width := 429;
48  Height := 341;
49  Position:= poScreenCenter;
50
51  Image1:=TImage.Create(Self);
52  with Image1 do begin
53    Name:='Image1';
54    Parent:=Self;
55    Align:=alClient;
56    Picture.LoadFromFile(Filename);
57  end;
58end;
59
60var
61  LoadBitmapForm: TLoadBitmapForm;
62begin
63  Application.Initialize;
64  Application.CreateForm(TLoadBitmapForm,LoadBitmapForm);
65  Application.Run;
66end.
67