targacmn.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. Function ToWord(AWord : TWordRec) : Word;
  41. Function FromWord(AWord : Word) : TWordRec;
  42. implementation
  43. Function ToWord(AWord : TWordRec) : Word;
  44. begin
  45. Result:=(AWord.Lo) or (AWord.Hi shl 8);
  46. end;
  47. Function FromWord(AWord : Word) : TWordRec;
  48. begin
  49. Result.Lo:=AWord and $FF;
  50. Result.Hi:=(AWord shr 8) and $FF;
  51. end;
  52. end.