Skip to content

Commit 7b31429

Browse files
authored
Merge pull request #1183 from galacean/dev
Merge origin/dev into origin/main
2 parents 2110fd4 + 32d76a4 commit 7b31429

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

web-packages/test/case/src/common/test-player.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,14 @@ export class TestPlayer {
9696
async readImageBuffer () {
9797
await sleep(sleepTime);
9898
const ctx = this.canvas.getContext(this.renderFramework) as WebGL2RenderingContext;
99-
const pixels = new Uint8Array(this.width * this.height * 4);
99+
100+
//使用实际的drawingBuffer读取,而不是使用画布尺寸
101+
const originalWidth = ctx.drawingBufferWidth;
102+
const originalHeight = ctx.drawingBufferHeight ;
103+
const pixels = new Uint8Array(originalWidth * originalHeight * 4);
100104

101105
ctx.flush();
102-
ctx.readPixels(0, 0, this.width, this.height, ctx.RGBA, ctx.UNSIGNED_BYTE, pixels);
106+
ctx.readPixels(0, 0, originalWidth, originalHeight, ctx.RGBA, ctx.UNSIGNED_BYTE, pixels);
103107

104108
return pixels;
105109
}

0 commit comments

Comments
 (0)