// The MIT License (MIT)
//
// Copyright (C) 2026 Scott Duensing
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

// bmpDraw.h -- Shared 24-bit BMP canvas + drawing primitives for host tools
//
// All drawing functions clip to the canvas bounds.  Pixel data is stored
// in BGR order, 3 bytes per pixel, stride = w * 3 (no row padding in memory;
// padding is added only during bmpWrite).

#ifndef BMPDRAW_H
#define BMPDRAW_H

#include <stdbool.h>
#include <stdint.h>


typedef struct {
    uint8_t *pixels;   // caller-owned or malloc'd; BGR, 3 bytes per pixel
    int32_t  w;
    int32_t  h;
} BmpCanvasT;


void bmpClear(BmpCanvasT *c, uint8_t r, uint8_t g, uint8_t b);
void bmpFillCircle(BmpCanvasT *c, int32_t cx, int32_t cy, int32_t radius, uint8_t r, uint8_t g, uint8_t b);
void bmpFillRect(BmpCanvasT *c, int32_t x0, int32_t y0, int32_t w, int32_t h, uint8_t r, uint8_t g, uint8_t b);
void bmpFree(BmpCanvasT *c);
void bmpHLine(BmpCanvasT *c, int32_t x0, int32_t y, int32_t w, uint8_t r, uint8_t g, uint8_t b);
bool bmpInit(BmpCanvasT *c, int32_t w, int32_t h);
void bmpPixel(BmpCanvasT *c, int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b);
void bmpRect(BmpCanvasT *c, int32_t x0, int32_t y0, int32_t w, int32_t h, uint8_t r, uint8_t g, uint8_t b);
void bmpVLine(BmpCanvasT *c, int32_t x, int32_t y0, int32_t h, uint8_t r, uint8_t g, uint8_t b);
bool bmpWrite(const BmpCanvasT *c, const char *path);

#endif
