targacmn.pp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {*****************************************************************************}
  2. {
  3. This file is part of the Free Pascal's "Free Components Library".
  4. Copyright (c) 2003 by Michael Van Canneyt of the Free Pascal development team
  5. TARGA common definitions.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. }
  12. {*****************************************************************************}
  13. {$mode objfpc}
  14. {$h+}
  15. unit targacmn;
  16. interface
  17. Const
  18. KeyIdentification = 'ID';
  19. Type
  20. TWordRec = Packed Record
  21. Lo,Hi : byte;
  22. end;
  23. TTargaHeader = packed record
  24. IDLen : Byte;
  25. MapType : Byte;
  26. ImgType : Byte;
  27. MapStart : TWordRec;
  28. MapLength : TWordRec;
  29. MapEntrySize : Byte;
  30. OriginX : TWordrec;
  31. OriginY : TWordRec;
  32. Width : TWordRec;
  33. Height : TWordRec;
  34. PixelSize : Byte;
  35. Flags : Byte;
  36. end;
  37. TBGREntry = packed record
  38. Blue, Green, Red : Byte;
  39. end;
  40. TBGRAEntry = packed record
  41. Blue, Green, Red, Alpha : Byte;
  42. end;
  43. Function ToWord(AWord : TWordRec) : Word;
  44. Function FromWord(AWord : Word) : TWordRec;
  45. implementation
  46. Function ToWord(AWord : TWordRec) : Word;
  47. begin
  48. Result:=(AWord.Lo) or (AWord.Hi shl 8);
  49. end;
  50. Function FromWord(AWord : Word) : TWordRec;
  51. begin
  52. Result.Lo:=AWord and $FF;
  53. Result.Hi:=(AWord shr 8) and $FF;
  54. end;
  55. end.