Make screenshot facility return an Image

Returning an image rather than always opennig a new window slightly
expands the utility of embedding v86---we may want to take a
screenshot and use just its data without asking the user to download it.
This commit is contained in:
Joseph C. Osborn 2023-03-14 12:10:28 -07:00
parent d2f85b46d0
commit 41f82364ab
3 changed files with 10 additions and 9 deletions

View file

@ -1932,7 +1932,12 @@
$("take_screenshot").onclick = function()
{
emulator.screen_make_screenshot();
const image = emulator.screen_make_screenshot();
try {
const w = window.open("");
w.document.write(image.outerHTML);
}
catch(e) {}
$("take_screenshot").blur();
};

View file

@ -16,7 +16,7 @@ function ScreenAdapter(screen_container, bus)
text_screen = screen_container.getElementsByTagName("div")[0],
cursor_element = document.createElement("div");
var
/** @type {number} */
cursor_row,
@ -220,12 +220,7 @@ function ScreenAdapter(screen_container, bus)
image.src = canvas.toDataURL("image/png");
}
try {
const w = window.open("");
w.document.write(image.outerHTML);
}
catch(e) {}
return image;
};
this.put_char = function(row, col, chr, bg_color, fg_color)

View file

@ -963,8 +963,9 @@ V86Starter.prototype.screen_make_screenshot = function()
{
if(this.screen_adapter)
{
this.screen_adapter.make_screenshot();
return this.screen_adapter.make_screenshot();
}
return null;
};
/**