Skip to content

Commit b128943

Browse files
authored
Merge pull request #145 from zero01101/fix-addon-black-screen
Generally fix black when outpainting using some firefox addons
2 parents 15395d8 + 1d976fd commit b128943

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
src="js/ui/tool/generic.js?v=2bcd36d"
355355
type="text/javascript"></script>
356356

357-
<script src="js/ui/tool/dream.js?v=0e12874" type="text/javascript"></script>
357+
<script src="js/ui/tool/dream.js?v=a68bed9" type="text/javascript"></script>
358358
<script
359359
src="js/ui/tool/maskbrush.js?v=1e8a893"
360360
type="text/javascript"></script>

js/ui/tool/dream.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -835,16 +835,21 @@ const dream_generate_callback = async (bb, resolution, state) => {
835835
bbCanvas.height = bb.h;
836836
const bbCtx = bbCanvas.getContext("2d");
837837

838-
const reqCanvas = document.createElement("canvas");
839-
reqCanvas.width = request.width;
840-
reqCanvas.height = request.height;
841-
const reqCtx = reqCanvas.getContext("2d");
838+
const maskCanvas = document.createElement("canvas");
839+
maskCanvas.width = request.width;
840+
maskCanvas.height = request.height;
841+
const maskCtx = maskCanvas.getContext("2d");
842+
843+
const initCanvas = document.createElement("canvas");
844+
initCanvas.width = request.width;
845+
initCanvas.height = request.height;
846+
const initCtx = initCanvas.getContext("2d");
842847

843848
bbCtx.fillStyle = "#000F";
844849

845850
// Get init image
846-
reqCtx.fillRect(0, 0, request.width, request.height);
847-
reqCtx.drawImage(
851+
initCtx.fillRect(0, 0, request.width, request.height);
852+
initCtx.drawImage(
848853
visibleCanvas,
849854
0,
850855
0,
@@ -855,7 +860,7 @@ const dream_generate_callback = async (bb, resolution, state) => {
855860
request.width,
856861
request.height
857862
);
858-
request.init_images = [reqCanvas.toDataURL()];
863+
request.init_images = [initCanvas.toDataURL()];
859864

860865
// Get mask image
861866
bbCtx.fillStyle = "#000F";
@@ -909,8 +914,8 @@ const dream_generate_callback = async (bb, resolution, state) => {
909914
bbCtx.fillStyle = "#FFFF";
910915
bbCtx.fillRect(0, 0, bb.w, bb.h);
911916

912-
reqCtx.clearRect(0, 0, reqCanvas.width, reqCanvas.height);
913-
reqCtx.drawImage(
917+
maskCtx.clearRect(0, 0, maskCanvas.width, maskCanvas.height);
918+
maskCtx.drawImage(
914919
bbCanvas,
915920
0,
916921
0,
@@ -921,7 +926,7 @@ const dream_generate_callback = async (bb, resolution, state) => {
921926
request.width,
922927
request.height
923928
);
924-
request.mask = reqCanvas.toDataURL();
929+
request.mask = maskCanvas.toDataURL();
925930

926931
// Dream
927932
_generate("img2img", request, bb, {

0 commit comments

Comments
 (0)