Make screenshot function return an Image (#820)

* 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:
Joe Osborn 2023-04-14 00:26:04 -07:00 committed by GitHub
parent d840540d21
commit 66dab8f39a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 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

@ -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;
};
/**