#ifndef IMAGE_H
#define IMAGE_H
#include <format.h>
#include <limits.h>
#include <stdio.h>
class Image {
public:
Image();
~Image();
Image(int w, int h, PixelFormat format);
Image(int w, int h, unsigned char *bits, PixelFormat format, int stride);
void fill(int col);
inline int width() { return w; }
inline int height() { return h; }
inline unsigned char *bits() { return data; }
inline int step() { return stride; }
inline PixelFormat format() { return f; }
inline int bytesPerPixel() { return FORMAT_BITS_PER_PIXEL(f) / 8; }
// is null
// copy - refcount
private:
void init(int w, int h, PixelFormat format);
int w, h, stride;
PixelFormat f;
unsigned char *data;
bool ownBits;
};
extern void blit(Image *dst, int dstX, int dstY, Image *src,
int srcX = 0, int srcY = 0, int w = INT_MAX, int h = INT_MAX);
#endif // IMAGE_H