// HTML5 Stereo Viewer Ver0.02
// http://www.stereomaker.net/html5/viewer5/index.htm
var jet = new Image();
var picindex1 = 0;
var stype = 0;
var nFull = 0;
var nSwap = 0;
var sshow = 0;
var nzoom = 100;
var nImgwidth ;
var nImgheight ;
var nWinwidth ;
var nWinheight;
var nCanwidth ;
var nCanwidth50 ;
var nCanheight;
var nInterval=3;
jet.src=pics[picindex1];
var canvas1 = document.getElementById("canvas1");
var ctx1 = canvas1.getContext("2d");
var nFS = 0;
var nFull = 0;
button0.innerHTML="" + (picindex1+1) + "/" + pics.length;
document.addEventListener("keydown", KeyEvent);
document.addEventListener('fullscreenchange', changeFullScreenHandler);
document.addEventListener('mozfullscreenchange', changeFullScreenHandler);
document.addEventListener('webkitfullscreenchange', changeFullScreenHandler);
document.addEventListener("mousewheel", function(e){
wheel_delta = e.detail ? e.detail / -3 : e.wheelDelta / 120;
nzoom=nzoom+wheel_delta*10;
if(nzoom>200) nzoom=200;
if(nzoom<10) nzoom=10;
draw();
});
document.addEventListener("click", function(e){
// picindex1 = (picindex1 + 1)%pics.length;
// load();
});
jet.onload = function(){
draw();
}
button1.onclick=function(){ //Previous
picindex1 = (picindex1 - 1);
if(picindex1<0) picindex1=pics.length-1;
load();
}
button2.onclick=function(){ //Next
picindex1 = (picindex1 + 1)%pics.length;
load();
}
button3.onclick=function(){ //SlideShow ON/OFF
sshow=(sshow+1)%2;
if(sshow==0) button3.innerHTML="Off_SS";
else button3.innerHTML="On(" + nInterval + "S)";
tstart();
}
button4.onclick=function(){ //Swap L-R
nSwap=(nSwap+1)%2;
if(nSwap==0) button4.innerHTML="L-R";
else button4.innerHTML="R-L";
draw();
}
button5.onclick=function(){ //Zoom(-)
nzoom=nzoom-10;
if(nzoom<10) nzoom=10;
draw();
}
button6.onclick=function(){ //Zoom(Fit)
nzoom=100;
draw();
}
button7.onclick=function(){ //Zoom(+)
nzoom=nzoom+10;
if(nzoom>200) nzoom=200;
draw();
}
button8.onclick=function(){ //Full Screen ON/OFF
toggleFullScreen();
}
button20.onclick=function(){ //SBS Parallel-eyed
stype=0;
draw();
}
button21.onclick=function(){ //SBS Cross-eyed
stype=1;
draw();
}
button22.onclick=function(){ //Dubois Anaglyph
stype=2;
draw();
}
button23.onclick=function(){ //Color Anaglyph
stype=3;
draw();
}
button24.onclick=function(){ //Red-Cyan Anaglyph
stype=4;
draw();
}
button25.onclick=function(){ //Interlace
stype=5;
draw();
}
button26.onclick=function(){ //Vertical Interlace
stype=6;
draw();
}
button27.onclick=function(){ //Single Image
stype=7;
draw();
}
button28.onclick=function(){ //SBS50
stype=8;
draw();
}
function KeyEvent(e){
var Keynum;
if(window.event) Keynum = e.keyCode; // IE
else if(e.which) Keynum = e.which;
if(Keynum==13) { //Enter : Full screen ON/OFF
toggleFullScreen();
}
else if(Keynum==32 || Keynum==39) { //Space or Right arrow : Next image
picindex1 = (picindex1 + 1)%pics.length;
load();
}
else if(Keynum==37) { //Left arrow : Previous image
picindex1 = (picindex1 - 1);
if(picindex1<0) picindex1=pics.length-1;
load();
}
else if(Keynum==65) { //A : SlideShow ON/OFF
sshow=(sshow+1)%2;
if(sshow==0) button3.innerHTML="Off_SS";
else button3.innerHTML="On(" + nInterval + "S)";
tstart();
}
else if(Keynum==88) { //X : Swap L-R
nSwap=(nSwap+1)%2;
if(nSwap==0) button4.innerHTML="L-R";
else button4.innerHTML="R-L";
draw();
}
else if(Keynum==70) { //F : Zoom(Fit)
nzoom=100;
draw();
}
else if(Keynum>48 && Keynum<58) { //Num : SlideShow Interval
nInterval=Keynum-48;
if(sshow==1) button3.innerHTML="On(" + nInterval + "S)";
}
else if(Keynum>96 && Keynum<106) { //Num : SlideShow Interval
nInterval=Keynum-96;
if(sshow==1) button3.innerHTML="On(" + nInterval + "S)";
}
button0.innerHTML="" + Keynum;
}
function changeFullScreenHandler(event) {
if ((document.fullScreenElement && document.fullScreenElement !== null) ||(!document.mozFullScreen && !document.webkitIsFullScreen)) {
nFull=0;
button8.innerHTML="Full";
}
else {
nFull=1;
button8.innerHTML="Close";
}
draw();
}
function toggleFullScreen(){
nFull=(nFull+1)%2;
if(nFull==1){
fullscreenon();
}
else{
fullscreenoff();
}
}
function fullscreenon(){
nFS=0;
var docElm = document.getElementById("contents");
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
nFS = 1;
}
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
nFS = 2;
}
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
nFS = 3;
}
}
function fullscreenoff(){
if (document.cancelFullScreen) {
document.cancelFullScreen();
}
if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
function tstart(){
if(sshow==1){
setTimeout(tstart, nInterval*1000);
picindex1 = (picindex1 + 1)%pics.length;
load();
}
}
function getBrowserWidth(){
if ( window.innerWidth ) { return window.innerWidth; }
else if ( document.documentElement && document.documentElement.clientWidth != 0 ) { return document.documentElement.clientWidth; }
else if ( document.body ) { return document.body.clientWidth; }
return 0;
}
function getBrowserHeight(){
if ( window.innerHeight ) { return window.innerHeight; }
else if ( document.documentElement && document.documentElement.clientHeight != 0 ) { return document.documentElement.clientHeight; }
else if ( document.body ) { return document.body.clientHeight; }
return 0;
}
function load(){
button0.innerHTML="loading ...";
setTimeout(load2,1);
}
function load2(){
jet.src=pics[picindex1];
jet.onload = function(){
draw();
}
}
function draw(){
button0.innerHTML="in progress...";
setTimeout(draw2,1);
}
function draw2(){
var time1;
var time2;
var startT = new Date();
time1 = startT.getTime();
nImgwidth=jet.width/2;
nImgheight=jet.height;
nWinwidth = getBrowserWidth();
if(nFull==0) {nWinheight = getBrowserHeight()-canvas1.offsetTop-10;}
else {nWinheight = getBrowserHeight()-50;}
nCanwidth = nWinwidth;
nCanheight = nWinheight;
if(stype<2) nCanheight=nCanheight*2;
if(nCanwidth/nCanheight>nImgwidth/nImgheight){
nCanwidth=nCanheight*nImgwidth/nImgheight;
}
else{
nCanheight=nCanwidth*nImgheight/nImgwidth;
}
if(stype<2) nCanheight=nCanheight/2;
if(stype==8 && nCanwidth < nWinwidth) nCanwidth = nWinwidth;
nCanwidth=Math.floor(nCanwidth*nzoom/100);
nCanheight=Math.floor(nCanheight*nzoom/100);
canvas1.width=nCanwidth;
canvas1.height=nCanheight;
ctx1.clearRect(0, 0, nCanwidth, nCanheight);
if(stype<2){ // 0:SBS Parallel-eyed 1:SBS Cross-eyed
if((stype==0 && nSwap==0) || (stype==1 && nSwap==1)){
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth/2,nCanheight);
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,nCanwidth/2,0,nCanwidth/2,nCanheight);
}
else{
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,nCanwidth/2,0,nCanwidth/2,nCanheight);
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth/2,nCanheight);
}
}
else if(stype==8){ //SBS 50%
nCanwidth50=(nCanheight*nImgwidth)/(nImgheight*2);
if(nSwap==0){
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,nCanwidth/2+((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
}
else{
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,nCanwidth/2+((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
}
}
//==========================================
else if(stype==2){ //Dubois Anaglyph
var r = 0;
var g = 0;
var b = 0;
var rl = 0;
var gl = 0;
var bl = 0;
var rr = 0;
var gr = 0;
var br = 0;
console.log("avant ; nCanwidth = "+ nCanwidth);
console.log("avant ;canvas largeur = "+ canvas1.width);
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
imagedata = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
for (y = 0; y < nCanheight ; y++) {
for (x = 0; x < nCanwidth; x++) {
rl=imagedatal.data[4*y*nCanwidth+x*4+0];
gl=imagedatal.data[4*y*nCanwidth+x*4+1];
bl=imagedatal.data[4*y*nCanwidth+x*4+2];
rr=imagedatar.data[4*y*nCanwidth+x*4+0];
gr=imagedatar.data[4*y*nCanwidth+x*4+1];
br=imagedatar.data[4*y*nCanwidth+x*4+2];
r=Math.floor(0.456100*rl + 0.500484*gl + 0.176381 * bl - 0.0434706*rr - 0.0879388*gr - 0.00155529*br);
g=Math.floor(-0.0400822*rl - 0.0378246*gl - 0.0157589*bl + 0.378476*rr + 0.73364*gr - 0.0184503*br);
b=Math.floor(-0.0152161*rl - 0.0205971*gl - 0.00546856*bl - 0.0721527*rr - 0.112961*gr + 1.2264*br);
imagedata.data[4*y*nCanwidth+x*4+0] = r;
imagedata.data[4*y*nCanwidth+x*4+1] = g;
imagedata.data[4*y*nCanwidth+x*4+2] = b;
}
}
ctx1.putImageData(imagedata,0,0);
}
else if(stype==3){ //Color Anaglyph
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
for (y = 0; y < nCanheight ; y++) {
for (x = 0; x < nCanwidth; x++) {
imagedatar.data[4*y*nCanwidth+x*4] = imagedatal.data[4*y*nCanwidth+x*4];
}
};
ctx1.putImageData(imagedatar,0,0);
}
else if(stype==4){ //Red-Cyan Anaglyph
var r = 0;
var g = 0;
var b = 0;
var rl = 0;
var gl = 0;
var bl = 0;
var rr = 0;
var gr = 0;
var br = 0;
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
imagedata = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
for (y = 0; y < nCanheight ; y++) {
for (x = 0; x < nCanwidth; x++) {
rl=imagedatal.data[4*y*nCanwidth+x*4+0];
gl=imagedatal.data[4*y*nCanwidth+x*4+1];
bl=imagedatal.data[4*y*nCanwidth+x*4+2];
rr=imagedatar.data[4*y*nCanwidth+x*4+0];
gr=imagedatar.data[4*y*nCanwidth+x*4+1];
br=imagedatar.data[4*y*nCanwidth+x*4+2];
r=Math.floor(0.29900*rl + 0.58700*gl + 0.11400*bl);
g=Math.floor(0.29900*rr + 0.58700*gr + 0.11400*br);
b=g
imagedata.data[4*y*nCanwidth+x*4+0] = r;
imagedata.data[4*y*nCanwidth+x*4+1] = g;
imagedata.data[4*y*nCanwidth+x*4+2] = b;
}
}
ctx1.putImageData(imagedata,0,0);
}
else if(stype==5){ //Interlace
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
for (y = 0; y < nCanheight ; y=y+2) {
for (x = 0; x < nCanwidth; x++) {
imagedatar.data[4*y*nCanwidth+x*4] = imagedatal.data[4*y*nCanwidth+x*4];
imagedatar.data[4*y*nCanwidth+x*4+1] = imagedatal.data[4*y*nCanwidth+x*4+1];
imagedatar.data[4*y*nCanwidth+x*4+2] = imagedatal.data[4*y*nCanwidth+x*4+2];
}
};
ctx1.putImageData(imagedatar,0,0);
}
else if(stype==6){ //Vertical Interlace
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
for (x = 0; x < nCanwidth; x=x+2) {
for (y = 0; y < nCanheight; y++) {
imagedatar.data[4*y*nCanwidth+x*4] = imagedatal.data[4*y*nCanwidth+x*4];
imagedatar.data[4*y*nCanwidth+x*4+1] = imagedatal.data[4*y*nCanwidth+x*4+1];
imagedatar.data[4*y*nCanwidth+x*4+2] = imagedatal.data[4*y*nCanwidth+x*4+2];
}
};
ctx1.putImageData(imagedatar,0,0);
}
else if(stype==7){ //Single Image
if(nSwap==0){
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight);
}
else{
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight);
}
}
var endT = new Date();
time2 = endT.getTime();
var dtime = time2 - time1;
// button30.innerHTML="" + dtime + "mS";
button0.innerHTML="" + (picindex1+1) + "/" + pics.length;
}
//==========================================
/*
function draw2(){
nImgwidth=jet.width/2;
nImgheight=jet.height;
nWinwidth = getBrowserWidth();
if(nFull==0) {nWinheight = getBrowserHeight()-canvas1.offsetTop-40;}
else {nWinheight = getBrowserHeight()-40;}
nCanwidth = nWinwidth;
nCanheight = nWinheight;
if(stype<2) nCanheight=nCanheight*2;
if(nCanwidth/nCanheight>nImgwidth/nImgheight){
nCanwidth=nCanheight*nImgwidth/nImgheight;
}
else{
nCanheight=nCanwidth*nImgheight/nImgwidth;
}
if(stype<2) nCanheight=nCanheight/2;
if(stype==8 && nCanwidth < nWinwidth) nCanwidth = nWinwidth;
nCanwidth=Math.floor(nCanwidth*nzoom/100);
nCanheight=Math.floor(nCanheight*nzoom/100);
canvas1.width=nCanwidth;
canvas1.height=nCanheight;
ctx1.clearRect(0, 0, nCanwidth, nCanheight);
if(stype<2){ // 0:SBS Parallel-eyed 1:SBS Cross-eyed
if((stype==0 && nSwap==0) || (stype==1 && nSwap==1)){
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth/2,nCanheight);
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,nCanwidth/2,0,nCanwidth/2,nCanheight);
}
else{
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,nCanwidth/2,0,nCanwidth/2,nCanheight);
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth/2,nCanheight);
}
}
else if(stype==8){ //SBS 50%
nCanwidth50=(nCanheight*nImgwidth)/(nImgheight*2);
if(nSwap==0){
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,nCanwidth/2+((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
}
else{
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,nCanwidth/2+((nCanwidth/2)-nCanwidth50)/2,0,nCanwidth50,nCanheight);
}
}
else if(stype==2){ //Dubois Anaglyph
var r = 0;
var g = 0;
var b = 0;
var rl = 0;
var gl = 0;
var bl = 0;
var rr = 0;
var gr = 0;
var br = 0;
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
imagedata = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
for (y = 0; y < nCanheight ; y++) {
for (x = 0; x < nCanwidth; x++) {
rl=imagedatal.data[4*y*nCanwidth+x*4+0];
gl=imagedatal.data[4*y*nCanwidth+x*4+1];
bl=imagedatal.data[4*y*nCanwidth+x*4+2];
rr=imagedatar.data[4*y*nCanwidth+x*4+0];
gr=imagedatar.data[4*y*nCanwidth+x*4+1];
br=imagedatar.data[4*y*nCanwidth+x*4+2];
r=Math.floor(0.456100*rl + 0.500484*gl + 0.176381 * bl - 0.0434706*rr - 0.0879388*gr - 0.00155529*br);
g=Math.floor(-0.0400822*rl - 0.0378246*gl - 0.0157589*bl + 0.378476*rr + 0.73364*gr - 0.0184503*br);
b=Math.floor(-0.0152161*rl - 0.0205971*gl - 0.00546856*bl - 0.0721527*rr - 0.112961*gr + 1.2264*br);
imagedata.data[4*y*nCanwidth+x*4+0] = r;
imagedata.data[4*y*nCanwidth+x*4+1] = g;
imagedata.data[4*y*nCanwidth+x*4+2] = b;
}
}
ctx1.putImageData(imagedata,0,0);
}
else if(stype==3){ //Color Anaglyph
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
for (y = 0; y < nCanheight ; y++) {
for (x = 0; x < nCanwidth; x++) {
imagedatar.data[4*y*nCanwidth+x*4] = imagedatal.data[4*y*nCanwidth+x*4];
}
};
ctx1.putImageData(imagedatar,0,0);
}
else if(stype==4){ //Red-Cyan Anaglyph
var r = 0;
var g = 0;
var b = 0;
var rl = 0;
var gl = 0;
var bl = 0;
var rr = 0;
var gr = 0;
var br = 0;
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
imagedata = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
for (y = 0; y < nCanheight ; y++) {
for (x = 0; x < nCanwidth; x++) {
rl=imagedatal.data[4*y*nCanwidth+x*4+0];
gl=imagedatal.data[4*y*nCanwidth+x*4+1];
bl=imagedatal.data[4*y*nCanwidth+x*4+2];
rr=imagedatar.data[4*y*nCanwidth+x*4+0];
gr=imagedatar.data[4*y*nCanwidth+x*4+1];
br=imagedatar.data[4*y*nCanwidth+x*4+2];
r=Math.floor(0.29900*rl + 0.58700*gl + 0.11400*bl);
g=Math.floor(0.29900*rr + 0.58700*gr + 0.11400*br);
b=g
imagedata.data[4*y*nCanwidth+x*4+0] = r;
imagedata.data[4*y*nCanwidth+x*4+1] = g;
imagedata.data[4*y*nCanwidth+x*4+2] = b;
}
}
ctx1.putImageData(imagedata,0,0);
}
else if(stype==5){ //Interlace
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
for (y = 0; y < nCanheight ; y=y+2) {
for (x = 0; x < nCanwidth; x++) {
imagedatar.data[4*y*nCanwidth+x*4] = imagedatal.data[4*y*nCanwidth+x*4];
imagedatar.data[4*y*nCanwidth+x*4+1] = imagedatal.data[4*y*nCanwidth+x*4+1];
imagedatar.data[4*y*nCanwidth+x*4+2] = imagedatal.data[4*y*nCanwidth+x*4+2];
}
};
ctx1.putImageData(imagedatar,0,0);
}
else if(stype==6){ //Vertical Interlace
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw left image
if(nSwap==0) imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
else imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get left image
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight); //draw right image
if(nSwap==0) imagedatar = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
else imagedatal = ctx1.getImageData(0,0,nCanwidth,nCanheight); //Get right image
for (x = 0; x < nCanwidth; x=x+2) {
for (y = 0; y < nCanheight; y++) {
imagedatar.data[4*y*nCanwidth+x*4] = imagedatal.data[4*y*nCanwidth+x*4];
imagedatar.data[4*y*nCanwidth+x*4+1] = imagedatal.data[4*y*nCanwidth+x*4+1];
imagedatar.data[4*y*nCanwidth+x*4+2] = imagedatal.data[4*y*nCanwidth+x*4+2];
}
};
ctx1.putImageData(imagedatar,0,0);
}
else if(stype==7){ //Single Image
if(nSwap==0){
ctx1.drawImage(jet,0,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight);
}
else{
ctx1.drawImage(jet,nImgwidth,0,nImgwidth,nImgheight,0,0,nCanwidth,nCanheight);
}
}
button0.innerHTML="" + (picindex1+1) + "/" + pics.length;
}
*/