OSDN Git Service

rm vem
authorayaka <gyzdisk@gmail.com>
Thu, 5 Nov 2015 02:46:21 +0000 (11:46 +0900)
committerayaka <gyzdisk@gmail.com>
Thu, 5 Nov 2015 02:46:21 +0000 (11:46 +0900)
1  2 
test/server/vem/feicontrol.rb
test/view/img.js
test/view/mock/img.js

@@@ -84,9 -83,25 +83,25 @@@ class FEIControl < VE
    end
  
    def acquisition
-     stream = ChunkyPNG::Datastream.from_file('./vem/sample.png')
-     array =  ChunkyPNG::Chunk::ImageData.combine_chunks(stream.data_chunks).unpack('C*')
-     "#{array}"
 -    # 画像ファイルをひらく
++   # 画像ファイルをひらく
+     File.open("img", "r") do |file|
+       $img_array = JSON.load(file)
+     end
+     # 画像配列の長さ取得
+     img_length = $img_array.length
+     # リサイズ用の配列生成
+     array128 = Array.new(128).map{ Array.new(128) }
+     # 元画像をリサイズ
+     for x in 0..127 do
+       for y in 0..127 do
+         array128[y][x] = $img_array[y*16][x*16]
+       end
+     end
+     "#{array128}"
    end 
  
    def getCondition
@@@ -12,9 -11,9 +12,9 @@@ function draw(data)
    }
  
    imgData = ctx.createImageData(128, 128);
 -  emData = data;
 +  emData = JSON.parse(data);
  
--  // 各ピクセルの色情報設定
++// 各ピクセルの色情報設定
    for (var i=0;i<128;i++){
      for (var j=0;j<128;j++){
        var n = j*4+i*128*4;
@@@ -3,8 -3,7 +3,7 @@@ var i = 0
  
  
  function startAcq(){
-   console.log("start");
--  $("button").text("stop");
++ $("button").text("stop");
    ws = new WebSocket("ws://localhost:3000");
  
    // メッセージ受信時の処理
@@@ -14,8 -13,7 +13,7 @@@
      }else{
        ws.send("acq");
        draw(JSON.parse(event.data));
-       console.log(event.data);
--      console.log(i);
++     console.log(i);
        i = i + 1;
      }
    };
@@@ -23,8 -21,8 +21,8 @@@
  }
  
  function stopAcq(){
 -  $("button").text("start");
++ $("button").text("start");
    console.log("stop");
-   $("button").text("start");
    ws.close(1000, "close");
  }
  
@@@ -60,3 -58,5 +58,4 @@@ function draw(data)
    // CanvasのコンテキストにImageDataを設定
    ctx.putImageData(imgData, 0, 0);
  }
 -