<commit_before>#pragma once

// In order to get valid data from the BMP file, need to pack to nearest 2-byte
// boundary, not 4
#pragma pack(2)

#ifndef SIPL_IO_BMPIO_H
#define SIPL_IO_BMPIO_H

#include "matrix/Matrix.hpp"
#include "io/IOBase.hpp"

namespace sipl
{

// A simple BMP reader/writer. It only handles 8-bit grayscale so far
class BmpIO : public IOBase
{
public:
    // Obtained from:
    // http://stackoverflow.com/a/11744950
    // These are windows #defines
    using LONG = int32_t;
    using WORD = uint16_t;
    using DWORD = uint32_t;

    struct BITMAPFILEHEADER {
        WORD bfType;
        DWORD bfSize;
        WORD bfReserved1;
        WORD bfReserved2;
        DWORD bfOffBits;
    };

    struct BITMAPINFOHEADER {
        DWORD biSize;
        LONG biWidth;
        LONG biHeight;
        WORD biPlanes;
        WORD biBitCount;
        DWORD biCompression;
        DWORD biSizeImage;
        LONG biXPelsPerMeter;
        LONG biYPelsPerMeter;
        DWORD biClrUsed;
        DWORD biClrImportant;
    };

    // Reading
    static MatrixX<uint8_t> read(const char* filename);

    static MatrixX<uint8_t> read(const std::string& filename);

    // Writing
    static void write(const MatrixX<uint8_t>& mat, const char* filename);

    static void write(const MatrixX<uint8_t>& mat, const std::string& filename);
};
}

#endif<commit_msg>Fix VS warning about #pragma pack (need to unpack, but make sure unpack is inside the #ifndef .. #endif<commit_after>#pragma once

#ifndef SIPL_IO_BMPIO_H
#define SIPL_IO_BMPIO_H

// In order to get valid data from the BMP file, need to pack to nearest 2-byte
// boundary, not 4
#pragma pack(push, 2)

#include "matrix/Matrix.hpp"
#include "io/IOBase.hpp"

namespace sipl
{

// A simple BMP reader/writer. It only handles 8-bit grayscale so far
class BmpIO : public IOBase
{
public:
    // Obtained from:
    // http://stackoverflow.com/a/11744950
    // These are windows #defines
    using LONG = int32_t;
    using WORD = uint16_t;
    using DWORD = uint32_t;

    struct BITMAPFILEHEADER {
        WORD bfType;
        DWORD bfSize;
        WORD bfReserved1;
        WORD bfReserved2;
        DWORD bfOffBits;
    };

    struct BITMAPINFOHEADER {
        DWORD biSize;
        LONG biWidth;
        LONG biHeight;
        WORD biPlanes;
        WORD biBitCount;
        DWORD biCompression;
        DWORD biSizeImage;
        LONG biXPelsPerMeter;
        LONG biYPelsPerMeter;
        DWORD biClrUsed;
        DWORD biClrImportant;
    };

    // Reading
    static MatrixX<uint8_t> read(const char* filename);

    static MatrixX<uint8_t> read(const std::string& filename);

    // Writing
    static void write(const MatrixX<uint8_t>& mat, const char* filename);

    static void write(const MatrixX<uint8_t>& mat, const std::string& filename);
};
}

// Set alignment back to normal
#pragma pack(pop)

#endif
{'fraction_non_alphanumeric': 0.0856152512998267, 'fraction_numerical': 0.016637781629116118, 'mean_word_length': 2.6210790464240903, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4185851', 'n_tokens_mistral': 1017, 'n_tokens_neox': 948, 'n_words': 284}