Hourglass now displayed when saving images.

This commit is contained in:
Scott Duensing 2026-03-26 21:25:04 -05:00
parent bf610ba95b
commit 15019ef542

View file

@ -1954,7 +1954,9 @@ static void interactiveScreenshot(AppContextT *ctx) {
memcpy(scrBuf, ctx->display.backBuf, scrSize);
if (dvxFileDialog(ctx, "Save Screenshot", FD_SAVE, NULL, filters, 2, path, sizeof(path))) {
dvxSetBusy(ctx, true);
dvxSaveImage(ctx, scrBuf, scrW, scrH, scrPitch, path);
dvxSetBusy(ctx, false);
}
free(scrBuf);
@ -1987,7 +1989,9 @@ static void interactiveWindowScreenshot(AppContextT *ctx, WindowT *win) {
memcpy(capBuf, win->contentBuf, capSize);
if (dvxFileDialog(ctx, "Save Window Screenshot", FD_SAVE, NULL, filters, 2, path, sizeof(path))) {
dvxSetBusy(ctx, true);
dvxSaveImage(ctx, capBuf, capW, capH, capPitch, path);
dvxSetBusy(ctx, false);
}
free(capBuf);
@ -4434,16 +4438,20 @@ bool dvxSaveTheme(const AppContextT *ctx, const char *filename) {
// we only write to the LFB, never read.
int32_t dvxScreenshot(AppContextT *ctx, const char *path) {
dvxSetBusy(ctx, true);
DisplayT *d = &ctx->display;
uint8_t *rgb = bufferToRgb(d, d->backBuf, d->width, d->height, d->pitch);
if (!rgb) {
dvxSetBusy(ctx, false);
return -1;
}
int32_t result = stbi_write_png(path, d->width, d->height, RGB_CHANNELS, rgb, d->width * RGB_CHANNELS) ? 0 : -1;
free(rgb);
dvxSetBusy(ctx, false);
return result;
}
@ -4875,15 +4883,19 @@ int32_t dvxWindowScreenshot(AppContextT *ctx, WindowT *win, const char *path) {
return -1;
}
dvxSetBusy(ctx, true);
uint8_t *rgb = bufferToRgb(&ctx->display, win->contentBuf, win->contentW, win->contentH, win->contentPitch);
if (!rgb) {
dvxSetBusy(ctx, false);
return -1;
}
int32_t result = stbi_write_png(path, win->contentW, win->contentH, RGB_CHANNELS, rgb, win->contentW * RGB_CHANNELS) ? 0 : -1;
free(rgb);
dvxSetBusy(ctx, false);
return result;
}