#pragma once #include #include #include #include #include #include #include "pixelarray.h" const char PADDING_ZEROES[3] = {0, 0, 0}; #pragma pack(push, 1) struct BitmapFileHeader { char signature[2] = {'B', 'M'}; uint32_t fileSize = 0; uint16_t reserved1 = 0; uint16_t reserved2 = 0; uint32_t imageDataOffset = 54; }; #pragma pack(pop) #pragma pack(push, 1) struct BITMAPINFOHEADER { uint32_t HeaderSize = 40; uint32_t BitmapWidth = 0; uint32_t BitmapHeight = 0; uint16_t ColorPlanes = 1; uint16_t BitsPerPixel = 24; uint32_t CompressionMethod = 0; uint32_t ImageSize = 0; int32_t HorizontalPixelPerMetre = 0; int32_t VerticalPixelPerMetre = 0; uint32_t NumberOfColors = 0; uint32_t NumberOfImportantColors = 0; }; #pragma pack(pop) class BMPImage { BitmapFileHeader fileHeader; BITMAPINFOHEADER infoHeader; std::shared_ptr pixelArray; public: BMPImage(const BitmapFileHeader &fileHeader, const BITMAPINFOHEADER &infoHeader, std::shared_ptr pixelArray); explicit BMPImage(std::shared_ptr pixelArray); [[nodiscard]] const uint32_t &width() const; [[nodiscard]] const uint32_t &height() const; [[nodiscard]] std::shared_ptr pixels() const; [[nodiscard]] std::shared_ptr pixels_copy(); [[nodiscard]] BitmapFileHeader fileHeader_copy(); [[nodiscard]] BITMAPINFOHEADER infoHeader_copy(); void save(const std::string &); std::shared_ptr appendRight(const std::shared_ptr&); std::shared_ptr overlay(const std::shared_ptr&, uint32_t, uint32_t); std::shared_ptr applyFilter(const std::function&)>& filter); }; std::shared_ptr readBMPImage(const std::string &filename); std::shared_ptr grayscale(const std::shared_ptr&); // TODO: Сделать const BMPImage std::shared_ptr invertColors(const std::shared_ptr&); // TODO: Сделать const BMPImage std::shared_ptr upscale2x(const std::shared_ptr&); std::shared_ptr downscale2x(const std::shared_ptr&); std::shared_ptr upscale1_5x(const std::shared_ptr&); std::shared_ptr upscale1_5x_ver2(const std::shared_ptr&); // TODO: BAD std::shared_ptr upscale2x_ver2(const std::shared_ptr&); // TODO: BAD std::shared_ptr textImg(const std::u16string &, Font *font, uint8_t scale = 1, Pixel background_color = Pixel{0, 0, 0}, Pixel font_color = Pixel{255, 255, 255});