#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
typedef unsigned char uint8;
typedef char int8;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned int uint32;
typedef int int32;
struct bmp_filehead
{
uint16 bmtype;
uint32 bmSize;
uint32 bmReserved;
uint32 bmOffBits;
}head1;
struct bmphead
{
uint32 bmpOffBits;
uint32 bmp_wide;
uint32 bmp_high;
uint16 bmplans;
uint16 bitcount;
uint32 bmpyasuo;
uint32 imagesize;
uint32 biXPelsPerMeter;
uint32 biYPelsPerMeter;
uint32 biClrUsed;
uint32 biClrImportant;
}head2;
struct BGR_data
{
uint8 B_data;
uint8 G_data;
uint8 R_data;
}clr_data[1024*768];
bool bmp565_write(unsigned char *image, uint32 width, uint32 height, const char *filename)
{
unsigned char buffer[1024*1024] = {
0};
uint32 file_size;
uint32 data_size;
unsigned int widthAlignBytes;
FILE *fp;
unsigned char header[66] = {
'B', 'M',
0, 0, 0, 0,
0, 0, 0, 0,
sizeof(header), 0, 0, 0,