From 8eb0a24f3471a5a555aff5ced54528fcf7da8c55 Mon Sep 17 00:00:00 2001 From: amrita.vishnoi Date: Fri, 8 Jul 2016 11:07:19 +0530 Subject: [PATCH] Approach1 in highlighting code for each term for single body region but code having issues --- 400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj | 3 ++- 400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 400-SOURCECODE/AIAHTML5.Web/app/workeroprocess/match-pixel-wp.js | 12 ------------ 400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js | 12 ++++++++++++ 400-SOURCECODE/AIAHTML5.Web/term-number-wp.js | 36 ++++++++++++++++++------------------ 5 files changed, 109 insertions(+), 39 deletions(-) delete mode 100644 400-SOURCECODE/AIAHTML5.Web/app/workeroprocess/match-pixel-wp.js create mode 100644 400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js diff --git a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj index daf99fb..ce5703b 100644 --- a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj +++ b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj @@ -73,7 +73,7 @@ - + @@ -42998,6 +42998,7 @@ + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 5975900..924d720 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -32,7 +32,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $rootScope.isHighLight = false; $rootScope.coloredImageCanvasList = []; $rootScope.coloredImageMRCanvasList = []; - + $rootScope.ColoredCanvasData= []; $rootScope.grayImageDataList = []; $rootScope.grayImageMRDataList = []; @@ -1073,6 +1073,17 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } ); } + else { + var colorImgData = context.getImageData(0, 0, w, h); + $scope.ColoredCanvasData.push( + { + "bodyRegionId": bodyRegionId, + "canvasId": FlipedImgCanvas.id, + "coloredImageData": colorImgData.data, + + } + ); + } } @@ -1339,6 +1350,17 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } ); } + else { + var colorImgData = context.getImageData(0, 0, w, h); + $scope.ColoredCanvasData.push( + { + "bodyRegionId": bodyRegionId, + "canvasId": imgCanvas.id, + "coloredImageData": colorImgData.data, + + } + ); + } }; document.getElementById('canvasDiv').appendChild(imgCanvas); @@ -1359,6 +1381,13 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.machedTermNoLocation = []; console.log(' TermList.length= ' + TermList.length) + + + var dataForthisBR = new jinqJs() + .from($scope.ColoredCanvasData) + .where('bodyRegionId == ' + 1) + .select(); + var coloredImageData = dataForthisBR.coloredImageData; var worker = new Worker('term-number-wp.js'); for (var i = 0; i < TermList.length; i++) { @@ -1375,9 +1404,39 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo }); } + + //var candata = e.value; + //var grayCanvasID = 'imageCanvas1' + //var grayCanvas = document.getElementById(grayCanvasID); + //var grayCanvasContext = grayCanvas.getContext("2d"); + //var imageData = grayCanvasContext.getImageData(0, 0 ,348,507); + + + // worker.postMessage({ candata: coloredImageData }); + worker.onmessage = function (e) { - console.log('callback time taken : ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); - $scope.fillMatchedTerm(e.data.value, e.data.BRId); + var candata = e.data.value; + var grayCanvasID = 'imageCanvas1' + var grayCanvas = document.getElementById(grayCanvasID); + var grayCanvasContext = grayCanvas.getContext("2d"); + + // var tempCanvas = document.createElement('canvas'); + // tempCanvas.id = 'tempCanvas'; + // $scope.tempCanvas = tempCanvas.id; + // tempCanvas.height = 507; + // tempCanvas.width = 348; + // tempCanvas.style.position = "absolute"; + // tempCanvas.style.left = 200 + 'px'; + // tempCanvas.style.top = 100 + 'px'; + + //// tempCanvas.style.backgroundColor = "transparent"; + // tempCanvas.style.visibility = 'visible'; + // document.getElementById('canvasDiv').appendChild(tempCanvas); + + // var tempCanvas1 = document.getElementById('tempCanvas'); + // var Context = tempCanvas1.getContext("2d"); + + grayCanvasContext.putImageData(e.data.value, 0, 0); }; @@ -1567,7 +1626,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var grayCanvas = document.getElementById(grayCanvasID); var grayCanvasContext = grayCanvas.getContext("2d"); - grayCanvasContext.putImageData(grayImageDataVar.toDataURL, 0, 0); + + debugger; + var garyDatalength = grayImageDataVar.length; + var pixelData = new Uint8ClampedArray(garyDatalength); + for (var i = 0; i < garyDatalength; i++) { + pixelData[i] = grayImageDataVar[i]; + } + var imgDta = grayCanvasContext.getImageData(0, 0, 348, 507); + imgDta.data.set + grayCanvasContext.putImageData(imgDta, 0, 0); //} // } @@ -1576,7 +1644,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } $scope.GetRGBColor = function (maskCanvasContext, actulalX, actualY, x, y) { - + debugger; var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1); pixelData.data[0] = pixelData.data[0] - 9; @@ -3297,7 +3365,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var coloredCanvasContext = imageCanvas.getContext("2d"); var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht); - var coloredImageDataVar = coloredImageData.data; + var coloredImageDataVar = coloredImageData; if (value.haveMirror == 'true') { @@ -3307,6 +3375,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1; $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar; + } @@ -3350,12 +3419,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var grayImageImageDataVar = grayImageData.data; if (value.haveMirror == 'true') { - $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData.data; + $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; } else { //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1; - $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData.data; + $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; } } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/workeroprocess/match-pixel-wp.js b/400-SOURCECODE/AIAHTML5.Web/app/workeroprocess/match-pixel-wp.js deleted file mode 100644 index 5f440d1..0000000 --- a/400-SOURCECODE/AIAHTML5.Web/app/workeroprocess/match-pixel-wp.js +++ /dev/null @@ -1,12 +0,0 @@ - -function getLocationsForMatchedTermsInWholeBody(msg) -{ - debugger; - - self.postMessage({ 'msg': 'called match-pixel-wp' }); - -} - -self.onmessage = function (e) { - getLocationsForMatchedTermsInWholeBody(e.data.value); -} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js b/400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js new file mode 100644 index 0000000..27d9e55 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js @@ -0,0 +1,12 @@ + +function getLocationsForMatchedTermsInWholeBody(msg) +{ + debugger; + + self.postMessage({ 'value': msg }); + +} + +self.onmessage = function (e) { + getLocationsForMatchedTermsInWholeBody(e.data.candata); +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js b/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js index 3d68123..386dc50 100644 --- a/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js +++ b/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js @@ -171,38 +171,38 @@ getLocationForMatchedTermsInWholeBody = function (termNo, maskCanvasData, colore - // var have = machedIcolorInBodyRegion.indexOf(bodyRegionId); + //// var have = machedIcolorInBodyRegion.indexOf(bodyRegionId); - //if (have == -1) { - // // machedIcolorInBodyRegion.push(bodyRegionId); - //} - //else { + // //if (have == -1) { + // // // machedIcolorInBodyRegion.push(bodyRegionId); + // //} + // //else { - //} + // //} - //previousGrayColoredData = i; - //if (coloredImageDataVar != null) { + // //previousGrayColoredData = i; + // //if (coloredImageDataVar != null) { - // var RED_coloredImage = coloredImageDataVar[i]; + // // var RED_coloredImage = coloredImageDataVar[i]; - // // grayImageDataVar[i] = RED_coloredImage; + // // // grayImageDataVar[i] = RED_coloredImage; - // var GREEN_coloredImage = coloredImageDataVar[i + 1]; - // /// grayImageDataVar[i + 1] = GREEN_coloredImage; + // // var GREEN_coloredImage = coloredImageDataVar[i + 1]; + // // /// grayImageDataVar[i + 1] = GREEN_coloredImage; - // var BLUE_coloredImage = coloredImageDataVar[i + 2]; - // //grayImageDataVar[i + 2] = BLUE_coloredImage; + // // var BLUE_coloredImage = coloredImageDataVar[i + 2]; + // // //grayImageDataVar[i + 2] = BLUE_coloredImage; - // var ALPHA_coloredImage = coloredImageDataVar[i + 3]; - // // grayImageDataVar[i + 3] = ALPHA_coloredImage; + // // var ALPHA_coloredImage = coloredImageDataVar[i + 3]; + // // // grayImageDataVar[i + 3] = ALPHA_coloredImage; - //} + // //} } @@ -210,7 +210,7 @@ getLocationForMatchedTermsInWholeBody = function (termNo, maskCanvasData, colore // grayCanvasContext.putImageData(grayImageData, 0, 0); } self.postMessage({ - 'BRId': bodyRegionId, + 'value': grayImageDataVar }); -- libgit2 0.21.4