update
This commit is contained in:
parent
45d0032cfe
commit
7997251781
4 changed files with 38 additions and 30 deletions
|
|
@ -294,6 +294,7 @@ static void window_tick(MwWidget handle, void* user, void* client) {
|
||||||
if(img != NULL) {
|
if(img != NULL) {
|
||||||
int iw, ih, ic;
|
int iw, ih, ic;
|
||||||
unsigned char* data = stbi_load_from_memory(img, sz, &iw, &ih, &ic, 4);
|
unsigned char* data = stbi_load_from_memory(img, sz, &iw, &ih, &ic, 4);
|
||||||
|
unsigned char* raw = MwPixmapGetRaw(pxalbum);
|
||||||
if(data != NULL) {
|
if(data != NULL) {
|
||||||
int y, x;
|
int y, x;
|
||||||
for(y = 0; y < ALBUMWIDTH; y++) {
|
for(y = 0; y < ALBUMWIDTH; y++) {
|
||||||
|
|
@ -301,19 +302,19 @@ static void window_tick(MwWidget handle, void* user, void* client) {
|
||||||
int ix = x * iw / ALBUMWIDTH;
|
int ix = x * iw / ALBUMWIDTH;
|
||||||
int iy = y * ih / ALBUMWIDTH;
|
int iy = y * ih / ALBUMWIDTH;
|
||||||
unsigned char* ipx = &data[(iy * iw + ix) * 4];
|
unsigned char* ipx = &data[(iy * iw + ix) * 4];
|
||||||
unsigned char* opx = &((MwLLCommonPixmap)pxalbum)->raw[(y * ALBUMWIDTH + x) * 4];
|
unsigned char* opx = &raw[(y * ALBUMWIDTH + x) * 4];
|
||||||
|
|
||||||
memcpy(opx, ipx, 4);
|
memcpy(opx, ipx, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
} else {
|
} else {
|
||||||
memset(((MwLLCommonPixmap)pxalbum)->raw, 0, ALBUMWIDTH * ALBUMWIDTH * 4);
|
memset(MwPixmapGetRaw(pxalbum), 0, ALBUMWIDTH * ALBUMWIDTH * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(img);
|
free(img);
|
||||||
} else {
|
} else {
|
||||||
memset(((MwLLCommonPixmap)pxalbum)->raw, 0, ALBUMWIDTH * ALBUMWIDTH * 4);
|
memset(MwPixmapGetRaw(pxalbum), 0, ALBUMWIDTH * ALBUMWIDTH * 4);
|
||||||
}
|
}
|
||||||
MwLLPixmapUpdate(pxalbum);
|
MwLLPixmapUpdate(pxalbum);
|
||||||
MwForceRender(album);
|
MwForceRender(album);
|
||||||
|
|
@ -368,7 +369,7 @@ static void window_tick(MwWidget handle, void* user, void* client) {
|
||||||
MwVaApply(timelabel,
|
MwVaApply(timelabel,
|
||||||
MwNtext, "",
|
MwNtext, "",
|
||||||
NULL);
|
NULL);
|
||||||
memset(((MwLLCommonPixmap)pxalbum)->raw, 0, ALBUMWIDTH * ALBUMWIDTH * 4);
|
memset(MwPixmapGetRaw(pxalbum), 0, ALBUMWIDTH * ALBUMWIDTH * 4);
|
||||||
MwLLPixmapUpdate(pxalbum);
|
MwLLPixmapUpdate(pxalbum);
|
||||||
MwForceRender(album);
|
MwForceRender(album);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ int main() {
|
||||||
MwOpenGLMakeCurrent(opengl);
|
MwOpenGLMakeCurrent(opengl);
|
||||||
|
|
||||||
col = MwParseColor(window, MwGetText(window, MwNbackground));
|
col = MwParseColor(window, MwGetText(window, MwNbackground));
|
||||||
MwGetColor(col, &r, &g, &b);
|
MwColorGet(col, &r, &g, &b);
|
||||||
MwLLFreeColor(col);
|
MwLLFreeColor(col);
|
||||||
|
|
||||||
glClearColor(r / 255.0, g / 255.0, b / 255.0, 1);
|
glClearColor(r / 255.0, g / 255.0, b / 255.0, 1);
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ int main() {
|
||||||
MwOpenGLMakeCurrent(opengl);
|
MwOpenGLMakeCurrent(opengl);
|
||||||
|
|
||||||
col = MwParseColor(window, MwGetText(window, MwNbackground));
|
col = MwParseColor(window, MwGetText(window, MwNbackground));
|
||||||
MwGetColor(col, &r, &g, &b);
|
MwColorGet(col, &r, &g, &b);
|
||||||
MwLLFreeColor(col);
|
MwLLFreeColor(col);
|
||||||
|
|
||||||
glClearColor(r / 255.0, g / 255.0, b / 255.0, 1);
|
glClearColor(r / 255.0, g / 255.0, b / 255.0, 1);
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,17 @@ static int oldw = 0, oldh = 0;
|
||||||
static unsigned char* buffer = NULL;
|
static unsigned char* buffer = NULL;
|
||||||
|
|
||||||
void image_init(void) {
|
void image_init(void) {
|
||||||
unsigned char* d = ((MwLLCommonPixmap)pxdata)->raw;
|
unsigned char* d = MwPixmapGetRaw(pxdata);
|
||||||
int w = ((MwLLCommonPixmap)pxdata)->width;
|
MwRect rc;
|
||||||
int h = ((MwLLCommonPixmap)pxdata)->height;
|
|
||||||
if(oldw != w || oldh != h) {
|
MwPixmapGetSize(pxdata, &rc);
|
||||||
|
|
||||||
|
if(oldw != rc.width || oldh != rc.height) {
|
||||||
int y, x;
|
int y, x;
|
||||||
if(buffer != NULL) free(buffer);
|
if(buffer != NULL) free(buffer);
|
||||||
for(y = 0; y < h; y++) {
|
for(y = 0; y < rc.height; y++) {
|
||||||
for(x = 0; x < w; x++) {
|
for(x = 0; x < rc.width; x++) {
|
||||||
unsigned char* px = &d[(y * w + x) * 4];
|
unsigned char* px = &d[(y * rc.width + x) * 4];
|
||||||
if(((y / 16) + (x / 16)) % 2) {
|
if(((y / 16) + (x / 16)) % 2) {
|
||||||
px[0] = px[1] = px[2] = 128;
|
px[0] = px[1] = px[2] = 128;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -25,13 +27,13 @@ void image_init(void) {
|
||||||
px[3] = 255;
|
px[3] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer = malloc(w * h * 4);
|
buffer = malloc(rc.width * rc.height * 4);
|
||||||
memcpy(buffer, d, w * h * 4);
|
memcpy(buffer, d, rc.width * rc.height * 4);
|
||||||
} else {
|
} else {
|
||||||
memcpy(d, buffer, w * h * 4);
|
memcpy(d, buffer, rc.width * rc.height * 4);
|
||||||
}
|
}
|
||||||
oldw = w;
|
oldw = rc.width;
|
||||||
oldh = h;
|
oldh = rc.height;
|
||||||
|
|
||||||
MwLLPixmapUpdate(pxdata);
|
MwLLPixmapUpdate(pxdata);
|
||||||
MwForceRender(image);
|
MwForceRender(image);
|
||||||
|
|
@ -61,10 +63,12 @@ void image_render(void) {
|
||||||
double sw, sh;
|
double sw, sh;
|
||||||
MwRect rc;
|
MwRect rc;
|
||||||
|
|
||||||
MwGetScreenSize(window, &rc);
|
MwPixmapGetSize(pxdata, &rc);
|
||||||
|
|
||||||
pw = ((MwLLCommonPixmap)pxdata)->width;
|
pw = rc.width;
|
||||||
ph = ((MwLLCommonPixmap)pxdata)->height;
|
ph = rc.height;
|
||||||
|
|
||||||
|
MwGetScreenSize(window, &rc);
|
||||||
|
|
||||||
dw = MwGetInteger(window, MwNwidth) - pw;
|
dw = MwGetInteger(window, MwNwidth) - pw;
|
||||||
dh = MwGetInteger(window, MwNheight) - ph;
|
dh = MwGetInteger(window, MwNheight) - ph;
|
||||||
|
|
@ -104,14 +108,17 @@ void image_render(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current < arrlen(images)) {
|
if(current < arrlen(images)) {
|
||||||
unsigned char* d = ((MwLLCommonPixmap)pxdata)->raw;
|
unsigned char* d = MwPixmapGetRaw(pxdata);
|
||||||
int y;
|
int y;
|
||||||
int x;
|
int x;
|
||||||
int w = ((MwLLCommonPixmap)pxdata)->width;
|
MwRect rc;
|
||||||
int h = ((MwLLCommonPixmap)pxdata)->height;
|
|
||||||
int ox = (w - images[current].width / images[current].scale) / 2 - images[current].x / images[current].scale;
|
|
||||||
int oy = (h - images[current].height / images[current].scale) / 2 - images[current].y / images[current].scale;
|
|
||||||
char str[128];
|
char str[128];
|
||||||
|
int ox, oy;
|
||||||
|
|
||||||
|
MwPixmapGetSize(pxdata, &rc);
|
||||||
|
|
||||||
|
ox = (rc.width - images[current].width / images[current].scale) / 2 - images[current].x / images[current].scale;
|
||||||
|
oy = (rc.height - images[current].height / images[current].scale) / 2 - images[current].y / images[current].scale;
|
||||||
|
|
||||||
sprintf(str, "mimview [%d of %d] %s", current + 1, arrlen(images), images[current].path);
|
sprintf(str, "mimview [%d of %d] %s", current + 1, arrlen(images), images[current].path);
|
||||||
|
|
||||||
|
|
@ -119,9 +126,9 @@ void image_render(void) {
|
||||||
MwNtitle, str,
|
MwNtitle, str,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
for(y = (oy < 0 ? 0 : 0); y < h + (oy < 0 ? -oy : -oy * 2); y++) {
|
for(y = (oy < 0 ? 0 : 0); y < rc.height + (oy < 0 ? -oy : -oy * 2); y++) {
|
||||||
for(x = (ox < 0 ? 0 : 0); x < w + (ox < 0 ? -ox : -ox * 2); x++) {
|
for(x = (ox < 0 ? 0 : 0); x < rc.width + (ox < 0 ? -ox : -ox * 2); x++) {
|
||||||
if(0 <= (y + oy) && (y + oy) < h && 0 <= (x + ox) && (x + ox) < w) {
|
if(0 <= (y + oy) && (y + oy) < rc.height && 0 <= (x + ox) && (x + ox) < rc.width) {
|
||||||
int ix = x * images[current].scale;
|
int ix = x * images[current].scale;
|
||||||
int iy = y * images[current].scale;
|
int iy = y * images[current].scale;
|
||||||
unsigned char* opx;
|
unsigned char* opx;
|
||||||
|
|
@ -129,7 +136,7 @@ void image_render(void) {
|
||||||
|
|
||||||
if(0 <= iy && iy < images[current].height && 0 <= ix && ix < images[current].width) {
|
if(0 <= iy && iy < images[current].height && 0 <= ix && ix < images[current].width) {
|
||||||
int i;
|
int i;
|
||||||
opx = &d[((y + oy) * w + x + ox) * 4];
|
opx = &d[((y + oy) * rc.width + x + ox) * 4];
|
||||||
ipx = &images[current].data[(iy * images[current].width + ix) * 4];
|
ipx = &images[current].data[(iy * images[current].width + ix) * 4];
|
||||||
|
|
||||||
for(i = 0; i < 3; i++) {
|
for(i = 0; i < 3; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue