mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-03 08:00:50 +00:00
add icons
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@255 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
46
src/draw.c
46
src/draw.c
@@ -9,6 +9,8 @@
|
||||
#include <jerror.h>
|
||||
#endif
|
||||
|
||||
#include "external/stb_ds.h"
|
||||
|
||||
#define FontWidth 7
|
||||
#define FontHeight 14
|
||||
#define FontScale 1
|
||||
@@ -550,15 +552,57 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) {
|
||||
|
||||
if(rgb == NULL) return NULL;
|
||||
|
||||
px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
|
||||
px = MwLoadRaw(handle, rgb, width, height);
|
||||
|
||||
free(rgb);
|
||||
|
||||
return px;
|
||||
}
|
||||
|
||||
MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height) {
|
||||
MwLLPixmap px;
|
||||
|
||||
px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
|
||||
|
||||
return px;
|
||||
}
|
||||
|
||||
void MwGetColor(MwLLColor color, int* red, int* green, int* blue) {
|
||||
*red = color->red;
|
||||
*green = color->green;
|
||||
*blue = color->blue;
|
||||
}
|
||||
|
||||
typedef struct color {
|
||||
char* key;
|
||||
char* value;
|
||||
} color_t;
|
||||
|
||||
MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
|
||||
int col, row, colors, cpp;
|
||||
unsigned char* rgb;
|
||||
MwLLPixmap px;
|
||||
char k[512];
|
||||
color_t* c = NULL;
|
||||
int i;
|
||||
|
||||
sh_new_strdup(c);
|
||||
|
||||
sscanf(data[0], "%d %d %d %d", &col, &row, &colors, &cpp);
|
||||
|
||||
for(i = 0; i < colors; i++) {
|
||||
memcpy(k, data[i + 1], cpp);
|
||||
k[cpp] = 0;
|
||||
printf("%s\n", k);
|
||||
}
|
||||
|
||||
rgb = malloc(row * col * 4);
|
||||
|
||||
px = MwLoadRaw(handle, rgb, col, row);
|
||||
|
||||
free(rgb);
|
||||
|
||||
shfree(c);
|
||||
|
||||
return px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user