📄 bitmap.h
字号:
#ifndef BITMAP_H
#define BITMAP_H
#include <string>
#include <fstream>
#include <vector>
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
#pragma pack(1) //byte align structures
struct BMPFileHeader
{
uint16 identifier;
uint32 fileSize;
uint32 reserved;
uint32 dataOffset;
uint32 headerSize;
};
struct BMPInfoHeader
{
uint32 width;
uint32 height;
uint16 planes;
uint16 bitsPerPixel;
uint32 compression;
uint32 bitmapDataSize;
uint32 hresolution;
uint32 vresolution;
uint32 colors;
uint32 importantColors;
};
struct Pixel
{
char red;
char green;
char blue;
};
typedef std::vector < Pixel > BitmapRow;
typedef std::vector < BitmapRow > BitmapRows;
struct Bitmap
{
BMPFileHeader fileHeader;
BMPInfoHeader infoHeader;
BitmapRows rows;
};
typedef std::vector < Bitmap > BitmapVector;
class BitmapConverter
{
public:
int load(const std::string & dibPath);
int save(const std::string & path, int colorDepth);
private:
BitmapVector bitmaps_;
void display_headers(const Bitmap & bitmap);
int output_bitmap(std::ofstream & f_out, Bitmap & bitmap, int colorDepth);
int convertColor(int color, int orig, int conv);
int bytesPerPixel_;
};
#endif /*
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -