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