@ceeblue/web-utils 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web-utils.js CHANGED
@@ -1965,16 +1965,17 @@ function decodeTimestamp(context, lineWidth, blocksPerRow = 32, tolerance = 0.2)
1965
1965
  let i = blockSize / 2;
1966
1966
  const data = context.getImageData(0, Math.round(i), lineWidth, 1).data;
1967
1967
  const pixels = new Uint32Array(data.buffer);
1968
- const blackThreshold = 0xffffff * tolerance;
1969
- const whiteThreshold = 0xffffff * (1 - tolerance);
1968
+ const blackThreshold = 0xff * tolerance;
1969
+ const whiteThreshold = 0xff * (1 - tolerance);
1970
1970
  while (i < pixels.length) {
1971
1971
  const pixel = pixels[Math.round(i)] & 0xffffff;
1972
- pixels[Math.round(i)] = pixel;
1973
- if (pixel < blackThreshold) {
1972
+ // Extract luminance from RGB
1973
+ const Y = 0.299 * ((pixel >> 16) & 0xff) + 0.587 * ((pixel >> 8) & 0xff) + 0.114 * (pixel & 0xff);
1974
+ if (Y < blackThreshold) {
1974
1975
  // Black
1975
1976
  binaryTime += '1';
1976
1977
  }
1977
- else if (pixel > whiteThreshold) {
1978
+ else if (Y > whiteThreshold) {
1978
1979
  // White
1979
1980
  binaryTime += '0';
1980
1981
  }
@@ -2024,4 +2025,4 @@ function encodeTimestamp(context, lineWidth, blocksPerRow = 32, now = new Date()
2024
2025
  * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
2025
2026
  * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
2026
2027
  */
2027
- const VERSION = '2.6.0';export{BinaryReader,BinaryWriter,BitReader,ByteRate,Connect,EpochTime,EventEmitter,FixMap,Log,LogType,Loggable,NetAddress,Numbers,Queue,SDP,Util,VERSION,WebSocketReliable,log};//# sourceMappingURL=web-utils.js.map
2028
+ const VERSION = '2.6.1';export{BinaryReader,BinaryWriter,BitReader,ByteRate,Connect,EpochTime,EventEmitter,FixMap,Log,LogType,Loggable,NetAddress,Numbers,Queue,SDP,Util,VERSION,WebSocketReliable,log};//# sourceMappingURL=web-utils.js.map