Mon 14 Oct 23:06:38 CEST 2024

This commit is contained in:
sbosse 2024-10-14 23:08:26 +02:00
parent de81192b71
commit 7ab1ce5fad

45
kernel/bitmap.c Normal file
View File

@ -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);
}