1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
13 #include <format_reader.h>
17 namespace FormatReader {
20 * \brief Reader for bmp files
22 class BitMap : public Reader {
24 static Register<BitMap> reg;
27 unsigned short type = 0u; /* Magic identifier */
28 unsigned int size = 0u; /* File size in bytes */
29 unsigned int reserved = 0u;
30 unsigned int offset = 0u; /* Offset to image data, bytes */
34 unsigned int size = 0u; /* Header size in bytes */
35 int width = 0, height = 0; /* Width and height of image */
36 unsigned short planes = 0u; /* Number of colour planes */
37 unsigned short bits = 0u; /* Bits per pixel */
38 unsigned int compression = 0u; /* Compression type */
39 unsigned int imagesize = 0u; /* Image size in bytes */
40 int xresolution = 0, yresolution = 0; /* Pixels per meter */
41 unsigned int ncolours = 0u; /* Number of colours */
42 unsigned int importantcolours = 0u; /* Important colours */
47 * \brief Constructor of BMP reader
48 * @param filename - path to input data
49 * @return BitMap reader object
51 explicit BitMap(const std::string &filename);
59 size_t size() const override {
60 return _width * _height * 3;
63 void Release() noexcept override {
67 std::shared_ptr<unsigned char> getData(size_t width, size_t height) override {
68 if ((width * height != 0) && (_width * _height != width * height)) {
69 std::cout << "[ WARNING ] Image won't be resized! Please use OpenCV.\n";
75 } // namespace FormatReader