/****************************************************************************
 * This file is part of the project AqHome.
 * AqHome (c) by 2023 Martin Preuss, all rights reserved.
 *
 * The license for this file can be found in the file COPYING which you
 * should have received along with this file.
 ****************************************************************************/

#ifndef AQHOME_TOOL_READBMP_H
#define AQHOME_TOOL_READBMP_H


#include <gwenhywfar/db.h>
#include <gwenhywfar/endpoint.h>

#include <aqhome/data/value.h>
#include <aqhome/data/device.h>

#include <aqhome/events2/eventloop.h>
#include <aqhome/events2/object.h>
#include <aqhome/ipc2/message.h>



typedef struct BMP_FILEHEADER BMP_FILEHEADER;
struct BMP_FILEHEADER {
  uint16_t fileType;
  uint32_t fileSize;
  uint32_t offsPixels;
};


typedef struct BMP_IMAGEHEADER BMP_IMAGEHEADER;
struct BMP_IMAGEHEADER {
  int32_t imgWidth;
  int32_t imgHeight;
  uint16_t imgPlanes; /* 1 */
  uint16_t bitsPerPixel;
  uint32_t compression;
  uint32_t imgSize;
  uint32_t imgXPixelsPerMeter;
  uint32_t imgYPixelsPerMeter;
  uint32_t colorMapUsedEntries;
  uint32_t colorMapImportantColors;
};



typedef struct BMP_FILE BMP_FILE;
struct BMP_FILE {
  char *filename;
  BMP_FILEHEADER *fileHeader;
  BMP_IMAGEHEADER *imageHeader;

  GWEN_BUFFER *buffer;
};


int AQH_Tool_DumpBmpFile(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv);


BMP_FILE *BMP_File_new(const char *fname);
void BMP_File_free(BMP_FILE *bf);
BMP_FILE *BMP_File_fromFile(const char *fname);



#endif

