]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CImageLoaderBMP.h
Merging r5975 through r6036 from trunk to ogl-es branch.
[irrlicht.git] / source / Irrlicht / CImageLoaderBMP.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_IMAGE_LOADER_BMP_H_INCLUDED__\r
6 #define __C_IMAGE_LOADER_BMP_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 \r
10 #include "IImageLoader.h"\r
11 \r
12 \r
13 namespace irr\r
14 {\r
15 namespace video\r
16 {\r
17 \r
18 #if defined(_IRR_COMPILE_WITH_BMP_LOADER_) || defined(_IRR_COMPILE_WITH_BMP_WRITER_)\r
19 \r
20 \r
21 // byte-align structures\r
22 #include "irrpack.h"\r
23 \r
24         struct SBMPHeader\r
25         {\r
26                 u16     Id;                                     //      BM - Windows 3.1x, 95, NT, 98, 2000, ME, XP\r
27                                                                                         //      BA - OS/2 Bitmap Array\r
28                                                                                         //      CI - OS/2 Color Icon\r
29                                                                                         //      CP - OS/2 Color Pointer\r
30                                                                                         //      IC - OS/2 Icon\r
31                                                                                         //      PT - OS/2 Pointer\r
32                 u32     FileSize;\r
33                 u32     Reserved;\r
34                 u32     BitmapDataOffset;\r
35                 u32     BitmapHeaderSize;       // should be 28h for windows bitmaps or\r
36                                                                                         // 0Ch for OS/2 1.x or F0h for OS/2 2.x\r
37                 u32 Width;\r
38                 u32 Height;\r
39                 u16 Planes;\r
40                 u16 BPP;                                        // 1: Monochrome bitmap\r
41                                                                                         // 4: 16 color bitmap\r
42                                                                                         // 8: 256 color bitmap\r
43                                                                                         // 16: 16bit (high color) bitmap\r
44                                                                                         // 24: 24bit (true color) bitmap\r
45                                                                                         // 32: 32bit (true color) bitmap\r
46 \r
47                 u32  Compression;                       // 0: none (Also identified by BI_RGB)\r
48                                                                                         // 1: RLE 8-bit / pixel (Also identified by BI_RLE4)\r
49                                                                                         // 2: RLE 4-bit / pixel (Also identified by BI_RLE8)\r
50                                                                                         // 3: Bitfields  (Also identified by BI_BITFIELDS)\r
51 \r
52                 u32  BitmapDataSize;            // Size of the bitmap data in bytes. This number must be rounded to the next 4 byte boundary.\r
53                 u32  PixelPerMeterX;\r
54                 u32  PixelPerMeterY;\r
55                 u32  Colors;\r
56                 u32  ImportantColors;\r
57         } PACK_STRUCT;\r
58 \r
59 // Default alignment\r
60 #include "irrunpack.h"\r
61 \r
62 #endif // defined with loader or writer\r
63 \r
64 #ifdef _IRR_COMPILE_WITH_BMP_LOADER_\r
65 \r
66 /*!\r
67         Surface Loader for Windows bitmaps\r
68 */\r
69 class CImageLoaderBMP : public IImageLoader\r
70 {\r
71 public:\r
72 \r
73         //! constructor\r
74         CImageLoaderBMP();\r
75 \r
76         //! returns true if the file maybe is able to be loaded by this class\r
77         //! based on the file extension (e.g. ".tga")\r
78         virtual bool isALoadableFileExtension(const io::path& filename) const _IRR_OVERRIDE_;\r
79 \r
80         //! returns true if the file maybe is able to be loaded by this class\r
81         virtual bool isALoadableFileFormat(io::IReadFile* file) const _IRR_OVERRIDE_;\r
82 \r
83         //! creates a surface from the file\r
84         virtual IImage* loadImage(io::IReadFile* file) const _IRR_OVERRIDE_;\r
85 \r
86 private:\r
87 \r
88         void decompress8BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch) const;\r
89 \r
90         void decompress4BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch) const;\r
91 };\r
92 \r
93 \r
94 #endif // compiled with loader\r
95 \r
96 } // end namespace video\r
97 } // end namespace irr\r
98 \r
99 #endif\r
100 \r