From 7ab1ce5fadfe7c0233cf3ad52b894c29bab0424f Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 14 Oct 2024 23:08:26 +0200 Subject: [PATCH] Mon 14 Oct 23:06:38 CEST 2024 --- kernel/bitmap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 kernel/bitmap.c diff --git a/kernel/bitmap.c b/kernel/bitmap.c new file mode 100644 index 0000000..1845d14 --- /dev/null +++ b/kernel/bitmap.c @@ -0,0 +1,45 @@ +/* +Copyright (C) 2016-2019 The University of Notre Dame +This software is distributed under the GNU General Public License. +See the file LICENSE for details. +*/ + +#include "bitmap.h" +#include "kernelcore.h" +#include "kmalloc.h" + +static struct bitmap root_bitmap; + +struct bitmap *bitmap_create_root() +{ + root_bitmap.width = video_xres; + root_bitmap.height = video_yres; + root_bitmap.format = BITMAP_FORMAT_RGB; + root_bitmap.data = video_buffer; + return &root_bitmap; +} + +struct bitmap *bitmap_create(int width, int height, int format) +{ + struct bitmap *b = kmalloc(sizeof(*b)); + if(!b) + return 0; + + b->data = kmalloc(width * height * 3); + if(!b->data) { + kfree(b); + return 0; + } + + b->width = width; + b->height = height; + b->format = format; + + return b; +} + +void bitmap_delete(struct bitmap *b) +{ + kfree(b->data); + kfree(b); +}