PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/components/images/laztga.pas

http://github.com/graemeg/lazarus
Pascal | 89 lines | 49 code | 20 blank | 20 comment | 0 complexity | 9ba1125ef6268052e46eeb284eb15533 MD5 | raw file
 1{ Copyright (C) 2003 Mattias Gaertner
 2
 3  This library is free software; you can redistribute it and/or modify it
 4  under the terms of the GNU Library General Public License as published by
 5  the Free Software Foundation; either version 2 of the License, or (at your
 6  option) any later version.
 7
 8  This program is distributed in the hope that it will be useful, but WITHOUT
 9  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
11  for more details.
12
13  You should have received a copy of the GNU Library General Public License
14  along with this library; if not, write to the Free Software Foundation,
15  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16}
17unit LazTGA;
18
19{$mode objfpc}{$H+}
20
21interface
22
23uses
24  SysUtils, Classes, FPImage, IntfGraphics, Graphics,
25  FPReadTGA, FPWriteTGA,
26  ClipBrd;
27
28type
29
30  { TSharedTGAImage }
31
32  TSharedTGAImage = class(TSharedCustomBitmap)
33  end;
34
35  { TTGAImage }
36
37  TTGAImage = class(TFPImageBitmap)
38  protected
39    class function GetReaderClass: TFPCustomImageReaderClass; override;
40    class function GetWriterClass: TFPCustomImageWriterClass; override;
41    class function GetSharedImageClass: TSharedRasterImageClass; override;
42  public
43    class function GetFileExtensions: string; override;
44  end;
45
46const
47  DefaultTGAMimeType = 'image/tga';
48
49procedure Register;
50procedure UnRegister;
51
52implementation
53
54{ TTGAImage }
55
56class function TTGAImage.GetReaderClass: TFPCustomImageReaderClass;
57begin
58  Result:=TFPReaderTarga;
59end;
60
61class function TTGAImage.GetWriterClass: TFPCustomImageWriterClass;
62begin
63  Result:=TFPWriterTarga;
64end;
65
66class function TTGAImage.GetSharedImageClass: TSharedRasterImageClass;
67begin
68  Result:=TSharedTGAImage;
69end;
70
71class function TTGAImage.GetFileExtensions: string;
72begin
73  Result:='tga';
74end;
75
76procedure Register;
77begin
78  TPicture.RegisterFileFormat('tga', 'TGA Image File', TTGAImage);
79  TPicture.RegisterClipboardFormat(RegisterClipboardFormat(DefaultTGAMimeType),
80    TTGAImage);
81end;
82
83procedure UnRegister;
84begin
85  TPicture.UnregisterGraphicClass(TTGAImage);
86end;
87
88end.
89