How to use ResolutionLayerComponentPositionIterator method in wpt

Best JavaScript code snippet using wpt

jpx.js

Source:jpx.js Github

copy

Full Screen

...630 }631 throw new Error('JPX Error: Out of packets');632 };633 }634 function ResolutionLayerComponentPositionIterator(context) {635 var siz = context.SIZ;636 var tileIndex = context.currentTile.index;637 var tile = context.tiles[tileIndex];638 var layersCount = tile.codingStyleDefaultParameters.layersCount;639 var componentsCount = siz.Csiz;640 var maxDecompositionLevelsCount = 0;641 for (var q = 0; q < componentsCount; q++) {642 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount,643 tile.components[q].codingStyleParameters.decompositionLevelsCount);644 }645 var r = 0, l = 0, i = 0, k = 0;646 this.nextPacket = function JpxImage_nextPacket() {647 // Section B.12.1.2 Resolution-layer-component-position648 for (; r <= maxDecompositionLevelsCount; r++) {649 for (; l < layersCount; l++) {650 for (; i < componentsCount; i++) {651 var component = tile.components[i];652 if (r > component.codingStyleParameters.decompositionLevelsCount) {653 continue;654 }655 var resolution = component.resolutions[r];656 var numprecincts = resolution.precinctParameters.numprecincts;657 for (; k < numprecincts;) {658 var packet = createPacket(resolution, k, l);659 k++;660 return packet;661 }662 k = 0;663 }664 i = 0;665 }666 l = 0;667 }668 throw new Error('JPX Error: Out of packets');669 };670 }671 function ResolutionPositionComponentLayerIterator(context) {672 var siz = context.SIZ;673 var tileIndex = context.currentTile.index;674 var tile = context.tiles[tileIndex];675 var layersCount = tile.codingStyleDefaultParameters.layersCount;676 var componentsCount = siz.Csiz;677 var l, r, c, p;678 var maxDecompositionLevelsCount = 0;679 for (c = 0; c < componentsCount; c++) {680 var component = tile.components[c];681 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount,682 component.codingStyleParameters.decompositionLevelsCount);683 }684 var maxNumPrecinctsInLevel = new Int32Array(685 maxDecompositionLevelsCount + 1);686 for (r = 0; r <= maxDecompositionLevelsCount; ++r) {687 var maxNumPrecincts = 0;688 for (c = 0; c < componentsCount; ++c) {689 var resolutions = tile.components[c].resolutions;690 if (r < resolutions.length) {691 maxNumPrecincts = Math.max(maxNumPrecincts,692 resolutions[r].precinctParameters.numprecincts);693 }694 }695 maxNumPrecinctsInLevel[r] = maxNumPrecincts;696 }697 l = 0;698 r = 0;699 c = 0;700 p = 0;701 this.nextPacket = function JpxImage_nextPacket() {702 // Section B.12.1.3 Resolution-position-component-layer703 for (; r <= maxDecompositionLevelsCount; r++) {704 for (; p < maxNumPrecinctsInLevel[r]; p++) {705 for (; c < componentsCount; c++) {706 var component = tile.components[c];707 if (r > component.codingStyleParameters.decompositionLevelsCount) {708 continue;709 }710 var resolution = component.resolutions[r];711 var numprecincts = resolution.precinctParameters.numprecincts;712 if (p >= numprecincts) {713 continue;714 }715 for (; l < layersCount;) {716 var packet = createPacket(resolution, p, l);717 l++;718 return packet;719 }720 l = 0;721 }722 c = 0;723 }724 p = 0;725 }726 throw new Error('JPX Error: Out of packets');727 };728 }729 function PositionComponentResolutionLayerIterator(context) {730 var siz = context.SIZ;731 var tileIndex = context.currentTile.index;732 var tile = context.tiles[tileIndex];733 var layersCount = tile.codingStyleDefaultParameters.layersCount;734 var componentsCount = siz.Csiz;735 var precinctsSizes = getPrecinctSizesInImageScale(tile);736 var precinctsIterationSizes = precinctsSizes;737 var l = 0, r = 0, c = 0, px = 0, py = 0;738 this.nextPacket = function JpxImage_nextPacket() {739 // Section B.12.1.4 Position-component-resolution-layer740 for (; py < precinctsIterationSizes.maxNumHigh; py++) {741 for (; px < precinctsIterationSizes.maxNumWide; px++) {742 for (; c < componentsCount; c++) {743 var component = tile.components[c];744 var decompositionLevelsCount =745 component.codingStyleParameters.decompositionLevelsCount;746 for (; r <= decompositionLevelsCount; r++) {747 var resolution = component.resolutions[r];748 var sizeInImageScale =749 precinctsSizes.components[c].resolutions[r];750 var k = getPrecinctIndexIfExist(751 px,752 py,753 sizeInImageScale,754 precinctsIterationSizes,755 resolution);756 if (k === null) {757 continue;758 }759 for (; l < layersCount;) {760 var packet = createPacket(resolution, k, l);761 l++;762 return packet;763 }764 l = 0;765 }766 r = 0;767 }768 c = 0;769 }770 px = 0;771 }772 throw new Error('JPX Error: Out of packets');773 };774 }775 function ComponentPositionResolutionLayerIterator(context) {776 var siz = context.SIZ;777 var tileIndex = context.currentTile.index;778 var tile = context.tiles[tileIndex];779 var layersCount = tile.codingStyleDefaultParameters.layersCount;780 var componentsCount = siz.Csiz;781 var precinctsSizes = getPrecinctSizesInImageScale(tile);782 var l = 0, r = 0, c = 0, px = 0, py = 0;783 this.nextPacket = function JpxImage_nextPacket() {784 // Section B.12.1.5 Component-position-resolution-layer785 for (; c < componentsCount; ++c) {786 var component = tile.components[c];787 var precinctsIterationSizes = precinctsSizes.components[c];788 var decompositionLevelsCount =789 component.codingStyleParameters.decompositionLevelsCount;790 for (; py < precinctsIterationSizes.maxNumHigh; py++) {791 for (; px < precinctsIterationSizes.maxNumWide; px++) {792 for (; r <= decompositionLevelsCount; r++) {793 var resolution = component.resolutions[r];794 var sizeInImageScale = precinctsIterationSizes.resolutions[r];795 var k = getPrecinctIndexIfExist(796 px,797 py,798 sizeInImageScale,799 precinctsIterationSizes,800 resolution);801 if (k === null) {802 continue;803 }804 for (; l < layersCount;) {805 var packet = createPacket(resolution, k, l);806 l++;807 return packet;808 }809 l = 0;810 }811 r = 0;812 }813 px = 0;814 }815 py = 0;816 }817 throw new Error('JPX Error: Out of packets');818 };819 }820 function getPrecinctIndexIfExist(821 pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {822 var posX = pxIndex * precinctIterationSizes.minWidth;823 var posY = pyIndex * precinctIterationSizes.minHeight;824 if (posX % sizeInImageScale.width !== 0 ||825 posY % sizeInImageScale.height !== 0) {826 return null;827 }828 var startPrecinctRowIndex =829 (posY / sizeInImageScale.width) *830 resolution.precinctParameters.numprecinctswide;831 return (posX / sizeInImageScale.height) + startPrecinctRowIndex;832 }833 function getPrecinctSizesInImageScale(tile) {834 var componentsCount = tile.components.length;835 var minWidth = Number.MAX_VALUE;836 var minHeight = Number.MAX_VALUE;837 var maxNumWide = 0;838 var maxNumHigh = 0;839 var sizePerComponent = new Array(componentsCount);840 for (var c = 0; c < componentsCount; c++) {841 var component = tile.components[c];842 var decompositionLevelsCount =843 component.codingStyleParameters.decompositionLevelsCount;844 var sizePerResolution = new Array(decompositionLevelsCount + 1);845 var minWidthCurrentComponent = Number.MAX_VALUE;846 var minHeightCurrentComponent = Number.MAX_VALUE;847 var maxNumWideCurrentComponent = 0;848 var maxNumHighCurrentComponent = 0;849 var scale = 1;850 for (var r = decompositionLevelsCount; r >= 0; --r) {851 var resolution = component.resolutions[r];852 var widthCurrentResolution =853 scale * resolution.precinctParameters.precinctWidth;854 var heightCurrentResolution =855 scale * resolution.precinctParameters.precinctHeight;856 minWidthCurrentComponent = Math.min(857 minWidthCurrentComponent,858 widthCurrentResolution);859 minHeightCurrentComponent = Math.min(860 minHeightCurrentComponent,861 heightCurrentResolution);862 maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent,863 resolution.precinctParameters.numprecinctswide);864 maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent,865 resolution.precinctParameters.numprecinctshigh);866 sizePerResolution[r] = {867 width: widthCurrentResolution,868 height: heightCurrentResolution869 };870 scale <<= 1;871 }872 minWidth = Math.min(minWidth, minWidthCurrentComponent);873 minHeight = Math.min(minHeight, minHeightCurrentComponent);874 maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);875 maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);876 sizePerComponent[c] = {877 resolutions: sizePerResolution,878 minWidth: minWidthCurrentComponent,879 minHeight: minHeightCurrentComponent,880 maxNumWide: maxNumWideCurrentComponent,881 maxNumHigh: maxNumHighCurrentComponent882 };883 }884 return {885 components: sizePerComponent,886 minWidth: minWidth,887 minHeight: minHeight,888 maxNumWide: maxNumWide,889 maxNumHigh: maxNumHigh890 };891 }892 function buildPackets(context) {893 var siz = context.SIZ;894 var tileIndex = context.currentTile.index;895 var tile = context.tiles[tileIndex];896 var componentsCount = siz.Csiz;897 // Creating resolutions and sub-bands for each component898 for (var c = 0; c < componentsCount; c++) {899 var component = tile.components[c];900 var decompositionLevelsCount =901 component.codingStyleParameters.decompositionLevelsCount;902 // Section B.5 Resolution levels and sub-bands903 var resolutions = [];904 var subbands = [];905 for (var r = 0; r <= decompositionLevelsCount; r++) {906 var blocksDimensions = getBlocksDimensions(context, component, r);907 var resolution = {};908 var scale = 1 << (decompositionLevelsCount - r);909 resolution.trx0 = Math.ceil(component.tcx0 / scale);910 resolution.try0 = Math.ceil(component.tcy0 / scale);911 resolution.trx1 = Math.ceil(component.tcx1 / scale);912 resolution.try1 = Math.ceil(component.tcy1 / scale);913 resolution.resLevel = r;914 buildPrecincts(context, resolution, blocksDimensions);915 resolutions.push(resolution);916 var subband;917 if (r === 0) {918 // one sub-band (LL) with last decomposition919 subband = {};920 subband.type = 'LL';921 subband.tbx0 = Math.ceil(component.tcx0 / scale);922 subband.tby0 = Math.ceil(component.tcy0 / scale);923 subband.tbx1 = Math.ceil(component.tcx1 / scale);924 subband.tby1 = Math.ceil(component.tcy1 / scale);925 subband.resolution = resolution;926 buildCodeblocks(context, subband, blocksDimensions);927 subbands.push(subband);928 resolution.subbands = [subband];929 } else {930 var bscale = 1 << (decompositionLevelsCount - r + 1);931 var resolutionSubbands = [];932 // three sub-bands (HL, LH and HH) with rest of decompositions933 subband = {};934 subband.type = 'HL';935 subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);936 subband.tby0 = Math.ceil(component.tcy0 / bscale);937 subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);938 subband.tby1 = Math.ceil(component.tcy1 / bscale);939 subband.resolution = resolution;940 buildCodeblocks(context, subband, blocksDimensions);941 subbands.push(subband);942 resolutionSubbands.push(subband);943 subband = {};944 subband.type = 'LH';945 subband.tbx0 = Math.ceil(component.tcx0 / bscale);946 subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);947 subband.tbx1 = Math.ceil(component.tcx1 / bscale);948 subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);949 subband.resolution = resolution;950 buildCodeblocks(context, subband, blocksDimensions);951 subbands.push(subband);952 resolutionSubbands.push(subband);953 subband = {};954 subband.type = 'HH';955 subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);956 subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);957 subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);958 subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);959 subband.resolution = resolution;960 buildCodeblocks(context, subband, blocksDimensions);961 subbands.push(subband);962 resolutionSubbands.push(subband);963 resolution.subbands = resolutionSubbands;964 }965 }966 component.resolutions = resolutions;967 component.subbands = subbands;968 }969 // Generate the packets sequence970 var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;971 switch (progressionOrder) {972 case 0:973 tile.packetsIterator =974 new LayerResolutionComponentPositionIterator(context);975 break;976 case 1:977 tile.packetsIterator =978 new ResolutionLayerComponentPositionIterator(context);979 break;980 case 2:981 tile.packetsIterator =982 new ResolutionPositionComponentLayerIterator(context);983 break;984 case 3:985 tile.packetsIterator =986 new PositionComponentResolutionLayerIterator(context);987 break;988 case 4:989 tile.packetsIterator =990 new ComponentPositionResolutionLayerIterator(context);991 break;992 default:...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var iterator = new ResolutionLayerComponentPositionIterator();2var x = iterator.getX();3var y = iterator.getY();4var z = iterator.getZ();5var t = iterator.getT();6var c = iterator.getC();7var p = iterator.getP();8var r = iterator.getR();9var s = iterator.getS();10var i = iterator.getI();11var iterator = new ResolutionLayerComponentPositionIterator();12while(iterator.hasNext()) {13 var x = iterator.getX();14 var y = iterator.getY();15 var z = iterator.getZ();16 var t = iterator.getT();17 var c = iterator.getC();18 var p = iterator.getP();19 var r = iterator.getR();20 var s = iterator.getS();21 var i = iterator.getI();22 iterator.next();23}24var iterator = new ResolutionLayerComponentPositionIterator();25while(iterator.hasNext()) {26 var x = iterator.getX();27 var y = iterator.getY();28 var z = iterator.getZ();29 var t = iterator.getT();30 var c = iterator.getC();31 var p = iterator.getP();32 var r = iterator.getR();33 var s = iterator.getS();34 var i = iterator.getI();35 iterator.next();36}37var iterator = new ResolutionLayerComponentPositionIterator();38while(iterator.hasNext()) {39 var x = iterator.getX();40 var y = iterator.getY();41 var z = iterator.getZ();42 var t = iterator.getT();43 var c = iterator.getC();44 var p = iterator.getP();45 var r = iterator.getR();46 var s = iterator.getS();47 var i = iterator.getI();48 iterator.next();49}50var iterator = new ResolutionLayerComponentPositionIterator();51while(iterator.hasNext()) {52 var x = iterator.getX();53 var y = iterator.getY();54 var z = iterator.getZ();55 var t = iterator.getT();56 var c = iterator.getC();57 var p = iterator.getP();58 var r = iterator.getR();59 var s = iterator.getS();60 var i = iterator.getI();61 iterator.next();62}63var iterator = new ResolutionLayerComponentPositionIterator();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var iterator = new wptoolkit.ResolutionLayerComponentPositionIterator();3var layer = iterator.getLayer();4var component = iterator.getComponent();5var position = iterator.getPosition();6iterator.next();7layer = iterator.getLayer();8component = iterator.getComponent();9position = iterator.getPosition();10iterator.next();11layer = iterator.getLayer();12component = iterator.getComponent();13position = iterator.getPosition();14var iterator = new wptoolkit.ResolutionLayerComponentPositionIterator();15 at Object.<anonymous> (C:\Users\user1\Desktop\test.js:4:14)16 at Module._compile (module.js:456:26)17 at Object.Module._extensions..js (module.js:474:10)18 at Module.load (module.js:356:32)19 at Function.Module._load (module.js:312:12)20 at Function.Module.runMain (module.js:497:10)21 at startup (node.js:119:16)

Full Screen

Using AI Code Generation

copy

Full Screen

1var test = new ResolutionLayerComponentPositionIterator();2var result = test.getComponents();3var test2 = new ResolutionLayerComponentPositionIterator();4var result2 = test2.getComponents();5var test3 = new ResolutionLayerComponentPositionIterator();6var result3 = test3.getComponents();7var test = new ResolutionLayerComponentPositionIterator();8var result = test.getComponents();9var test2 = new ResolutionLayerComponentPositionIterator();10var result2 = test2.getComponents();11var test3 = new ResolutionLayerComponentPositionIterator();12var result3 = test3.getComponents();13var test = new ResolutionLayerComponentPositionIterator();14var result = test.getComponents();15var test2 = new ResolutionLayerComponentPositionIterator();16var result2 = test2.getComponents();17var test3 = new ResolutionLayerComponentPositionIterator();18var result3 = test3.getComponents();19var test = new ResolutionLayerComponentPositionIterator();20var result = test.getComponents();21var test2 = new ResolutionLayerComponentPositionIterator();22var result2 = test2.getComponents();23var test3 = new ResolutionLayerComponentPositionIterator();24var result3 = test3.getComponents();25var test = new ResolutionLayerComponentPositionIterator();26var result = test.getComponents();27var test2 = new ResolutionLayerComponentPositionIterator();28var result2 = test2.getComponents();29var test3 = new ResolutionLayerComponentPositionIterator();30var result3 = test3.getComponents();31var test = new ResolutionLayerComponentPositionIterator();32var result = test.getComponents();33var test2 = new ResolutionLayerComponentPositionIterator();34var result2 = test2.getComponents();35var test3 = new ResolutionLayerComponentPositionIterator();36var result3 = test3.getComponents();37var test = new ResolutionLayerComponentPositionIterator();38var result = test.getComponents();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WPT();2var layer = wpt.getLayer(0);3var iterator = new ResolutionLayerComponentPositionIterator(layer);4var pos = iterator.next();5while (pos != null) {6 System.out.println(pos);7 pos = iterator.next();8}

Full Screen

Using AI Code Generation

copy

Full Screen

1var component = app.activeDocument.activeLayer;2var iterator = new ResolutionLayerComponentPositionIterator(component);3while (iterator.hasNext()) {4 var layer = iterator.next();5 var position = iterator.position;6 alert(layer.name + " " + position);7}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WPT();2var layer = wpt.getLayer(0);3var iterator = wpt.getResolutionLayerComponentPositionIterator(layer);4var positionArray = new Array();5while(iterator.hasNext()) {6 var position = iterator.next();7 positionArray.push(position);8}9var wpt = new WPT();10var layer = wpt.getLayer(0);11var positionArray = new Array();12for(var i = 0; i < layer.getComponentCount(); i++) {13 var position = layer.getComponentPosition(i);14 positionArray.push(position);15}16var wpt = new WPT();17var layer = wpt.getLayer(0);18var positionArray = new Array();19for(var i = 0; i < layer.getComponentCount(); i++) {20 var position = layer.getComponentPosition(i);21 positionArray.push(position);22}23var wpt = new WPT();24var layer = wpt.getLayer(0);25var iterator = wpt.getResolutionLayerComponentPositionIterator(layer);26var positionArray = new Array();27while(iterator.hasNext()) {28 var position = iterator.next();29 positionArray.push(position);30}31var wpt = new WPT();32var layer = wpt.getLayer(0);33var positionArray = new Array();34for(var i = 0; i < layer.getComponentCount(); i++) {35 var position = layer.getComponentPosition(i);36 positionArray.push(position);37}38var wpt = new WPT();39var layer = wpt.getLayer(0);40var positionArray = new Array();41for(var i = 0; i < layer.getComponentCount(); i

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var res = wptoolkit.getResolutionObject('resolution1');3var resIter = wptoolkit.getResolutionLayerComponentPositionIterator(res);4while (resIter.hasNext()) {5 var layerName = resIter.next();6 var compIter = wptoolkit.getResolutionLayerComponentIterator(res, layerName);7 while (compIter.hasNext()) {8 var compName = compIter.next();9 var posIter = wptoolkit.getResolutionLayerComponentPositionIterator(res, layerName, compName);10 while (posIter.hasNext()) {11 var posName = posIter.next();12 var value = wptoolkit.getResolutionLayerComponentPositionValue(res, layerName, compName, posName);13 console.log('layer: ' + layerName + ', component: ' + compName + ', position: ' + posName + ', value: ' + value);14 }15 }16}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WPTree } from './wptree.js';2import { ResolutionLayerComponentPositionIterator } from './resolutionlayercomponentpositioniterator.js';3var tree = new WPTree();4tree.setTreeToDefault();5var iterator = new ResolutionLayerComponentPositionIterator(tree);6var position = iterator.getPositionOfNextComponent();7while (position != null) {8 console.log(position);9 position = iterator.getPositionOfNextComponent();10}11tree.setTreeToDefault();12position = iterator.getPositionOfNextComponent();13while (position != null) {14 console.log(position);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful