bmpcomn.pp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {*****************************************************************************}
  2. {
  3. $Id$
  4. This file is part of the Free Pascal's "Free Components Library".
  5. Copyright (c) 2003 by Mazen NEIFER of the Free Pascal development team
  6. BMP reader/writer common code.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. }
  13. {*****************************************************************************}
  14. {$mode objfpc}{$h+}
  15. unit BMPcomn;
  16. interface
  17. const
  18. {BMP magic word is always 19778 : 'BM'}
  19. BMmagic=19778;
  20. type
  21. TBitMapFileHeader = packed record
  22. {00+02 :File type}
  23. bfType:word;
  24. {02+04 :File size in bytes}
  25. bfSize:longint;
  26. {06+04 : Reserved}
  27. bfReserved:longint;
  28. {10+04 : Offset of image data : size if the file hieder + the info header}
  29. bfOffset:longint;
  30. end;
  31. PBitMapFileHeader = ^TBitMapFileHeader;
  32. TBitMapInfoHeader = packed record
  33. {14+04 : Size of the bitmap info header : sould be 40=$28}
  34. Size:longint;
  35. {18+04 : Image width in pixels}
  36. Width:longint;
  37. {22+04 : Image height in pixels}
  38. Height:longint;
  39. {26+02 : Number of image planes : should be 1 always}
  40. Planes:word;
  41. {28+02 : Color resolution : Number of bits per pixel (1,4,8,24)}
  42. BitCount:word;
  43. {30+04 : Compression Type}
  44. Compression:longint;
  45. {34+04 : Size of compressed image : should be 0 if no compression}
  46. SizeImage:longint;
  47. {38+04 : Horizontal resolution in pixel/meter}
  48. XPelsPerMeter:Longint;
  49. {42+04 : Vertical resolution in pixel/meter}
  50. YPelsPerMeter:Longint;
  51. {46+04 : Number of coros used}
  52. ClrUsed:longint;
  53. {50+04 : Number of imprtant colors used : usefull for displaying on VGA256}
  54. ClrImportant:longint;
  55. end;
  56. PBitMapInfoHeader = ^TBitMapInfoHeader;
  57. TColorRGB=packed record
  58. B,G,R:Byte;
  59. end;
  60. PColorRGB = ^TColorRGB;
  61. TColorRGBA=packed record
  62. case Boolean of
  63. False:(B,G,R,A:Byte);
  64. True:(RGB:TColorRGB);
  65. end;
  66. PColorRGBA = ^TColorRGBA;
  67. {54+?? : Color map : Lenght of color map is 4 bytes + the rest until the beginning of image data fixed in BFH.bfOffset}
  68. TColorMap=TColorRGBA;
  69. implementation
  70. end.
  71. {
  72. $Log$
  73. Revision 1.4 2004-02-20 22:42:44 michael
  74. + More modular reading of BMP for easier overriding in descendents
  75. Revision 1.3 2004/02/15 20:59:06 michael
  76. + Patch from Colin Western
  77. Revision 1.2 2003/09/09 11:22:30 mazen
  78. + adding comment for type defintion in the fpdoc style
  79. * fixing copyright section in the file header
  80. }