質問編集履歴

1

this.を削除

2020/03/05 09:45

投稿

yamayamak
yamayamak

スコア131

test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  var ctx = canvas.getContext('2d')
20
20
 
21
- var imageData = ctx.createImageData(this.width, 1)
21
+ var imageData = ctx.createImageData(width, 1)
22
22
 
23
23
  var canvas_resize = document.getElementById('resize_canvas')
24
24
 
@@ -30,13 +30,13 @@
30
30
 
31
31
  var pixels = imageData.data
32
32
 
33
- for (var y = 0; y < (buf.length) / this.width; y += 1) {
33
+ for (var y = 0; y < (buf.length) / width; y += 1) {
34
34
 
35
35
  var base = 0
36
36
 
37
- for (var x = 0; x < this.width; x += 1) {
37
+ for (var x = 0; x < width; x += 1) {
38
38
 
39
- var c = x + y * this.width
39
+ var c = x + y * width
40
40
 
41
41
  pixels[base + 0] = (buf[c] & 0xf800) >> 8 | (buf[c] & 0xe000) >> 13
42
42
 
@@ -50,7 +50,7 @@
50
50
 
51
51
  }
52
52
 
53
- ctx.putImageData(this.imageData, 0, y)
53
+ ctx.putImageData(imageData, 0, y)
54
54
 
55
55
  }
56
56
 
@@ -58,9 +58,9 @@
58
58
 
59
59
  // 以下で「resize_canvas」にリサイズして別のCanvasに表示したいのですが、表示されません。
60
60
 
61
- ctx_resize.drawImage(canvas, 0, 0, (this.width * 2), (this.hight * 2))
61
+ ctx_resize.drawImage(canvas, 0, 0, (width * 2), (hight * 2))
62
62
 
63
- // こちらでもNG ctx_resize.drawImage(canvas, 0, 0, this.width, this.hight, 0, 0, (this.width * 2), (this.hight * 2))
63
+ // こちらでもNG ctx_resize.drawImage(canvas, 0, 0, width, hight, 0, 0, (width * 2), (hight * 2))
64
64
 
65
65
  ```
66
66