mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 09:00:54 +00:00
fix pixmap leak
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@82 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
16
src/draw.c
16
src/draw.c
@@ -1,6 +1,8 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
#include <stb_image.h>
|
||||
|
||||
static int hex(const char* txt, int len) {
|
||||
int i;
|
||||
int r = 0;
|
||||
@@ -145,3 +147,17 @@ void MwDrawText(MwWidget handle, MwPoint* point, const char* text, MwLLColor col
|
||||
sx += fw * sc;
|
||||
}
|
||||
}
|
||||
|
||||
MwLLPixmap MwLoadImage(MwWidget handle, const char* path) {
|
||||
int width, height, ch;
|
||||
unsigned char* rgb = stbi_load(path, &width, &height, &ch, 3);
|
||||
MwLLPixmap px;
|
||||
|
||||
if(rgb == NULL) return NULL;
|
||||
|
||||
px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
|
||||
|
||||
free(rgb);
|
||||
|
||||
return px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user