From 87066261297b2720ae844bc1eb46b280e38336aa Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Mon, 24 Nov 2025 20:16:33 +0900 Subject: [PATCH] album pic works --- mauplay/main.c | 6 +++--- mauplay/mauplay.h | 3 +++ mauplay/stb_image.c | 2 ++ mauplay/ui.c | 27 +++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 mauplay/stb_image.c diff --git a/mauplay/main.c b/mauplay/main.c index 7830050..6ec9496 100644 --- a/mauplay/main.c +++ b/mauplay/main.c @@ -219,10 +219,10 @@ int main() { MwNleftPadding, 16, NULL); - pxalbumdata = malloc(128 * 128 * 4); - memset(pxalbumdata, 0, 128 * 128 * 4); + pxalbumdata = malloc(ALBUMWIDTH * ALBUMWIDTH * 4); + memset(pxalbumdata, 0, ALBUMWIDTH * ALBUMWIDTH * 4); - pxalbum = MwLoadRaw(window, pxalbumdata, 128, 128); + pxalbum = MwLoadRaw(window, pxalbumdata, ALBUMWIDTH, ALBUMWIDTH); pxskipback = MwLoadXPM(window, skipback_xpm); pxplay = MwLoadXPM(window, play_xpm); pxpause = MwLoadXPM(window, pause_xpm); diff --git a/mauplay/mauplay.h b/mauplay/mauplay.h index 137391b..8ad2b5d 100644 --- a/mauplay/mauplay.h +++ b/mauplay/mauplay.h @@ -17,6 +17,8 @@ #include #include +#define ALBUMWIDTH 128 + typedef struct numkv { char* key; int value; @@ -40,6 +42,7 @@ extern MwWidget album, info; extern MwWidget bskipback, bplay, bpause, bstop, bskipfwd, brepeat, bshuffle; extern MwWidget eltime, seekbar, rmtime; extern MwWidget tree, list; +extern unsigned char* pxalbumdata; extern MwLLPixmap pxalbum; /* db.c */ diff --git a/mauplay/stb_image.c b/mauplay/stb_image.c new file mode 100644 index 0000000..9177288 --- /dev/null +++ b/mauplay/stb_image.c @@ -0,0 +1,2 @@ +#define STB_IMAGE_IMPLEMENTATION +#include diff --git a/mauplay/ui.c b/mauplay/ui.c index 1c23e62..138b226 100644 --- a/mauplay/ui.c +++ b/mauplay/ui.c @@ -1,6 +1,7 @@ #include "mauplay.h" #include +#include static void* play_queue; static void* all_music; @@ -204,6 +205,32 @@ static void window_tick(MwWidget handle, void* user, void* client) { if(queue_last != queue_seek && queue_seek != -1) { int ind; char* buf; + size_t sz; + unsigned char* img; + + img = id3_findimage(queue[queue_seek].path, &sz); + if(img != NULL){ + int iw, ih, ic; + unsigned char* data = stbi_load_from_memory(img, sz, &iw, &ih, &ic, 4); + if(data != NULL){ + int y, x; + for(y = 0; y < ALBUMWIDTH; y++){ + for(x = 0; x < ALBUMWIDTH; x++){ + int ix = x * iw / ALBUMWIDTH; + int iy = y * ih / ALBUMWIDTH; + unsigned char* ipx = &data[(iy * iw + ix) * 4]; + unsigned char* opx = &((MwLLCommonPixmap)pxalbum)->raw[(y * ALBUMWIDTH + x) * 4]; + + memcpy(opx, ipx, 4); + } + } + free(data); + } + + MwLLPixmapUpdate(pxalbum); + MwForceRender(album); + free(img); + } if(ui_last == play_queue) { pthread_mutex_unlock(&audio_mutex);