fix pixmap leak
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@82 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
e74b80da50
commit
8ea2d4a50a
15 changed files with 9440 additions and 1337 deletions
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue