Skip to content

Commit

Permalink
Deploying to gh-pages from @ c3fdd4b 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Nov 14, 2023
1 parent 2ecd0ce commit e1dc142
Show file tree
Hide file tree
Showing 149 changed files with 7,962 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
32 changes: 32 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>example</title>
<base href="/Razor-Barcode-Library/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png" />
<link href="example.styles.css" rel="stylesheet" />
</head>

<body>
<div id="app">
<svg class="loading-progress">
<circle r="40%" cx="50%" cy="50%" />
<circle r="40%" cx="50%" cy="50%" />
</svg>
<div class="loading-progress-text"></div>
</div>

<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
</body>

</html>
Binary file added _content/Razor.Barcode.Library/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 186 additions & 0 deletions _content/Razor.Barcode.Library/barcodeJsInterop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
export function init(license) {
return new Promise((resolve, reject) => {
let script = document.createElement('script');
script.type = 'text/javascript';
script.src = '_content/RazorBarcodeLibrary/dbr.js';
script.onload = async () => {
resolve();
};
script.onerror = () => {
reject();
};
document.head.appendChild(script);
});
}

export function getVersion() {
if (!Dynamsoft) return "";
return Dynamsoft.DBR.BarcodeReader.version;
}

export function setLicense(license) {
if (!Dynamsoft) return;
Dynamsoft.DBR.BarcodeScanner.license = license;
}

export async function loadWasm() {
if (!Dynamsoft) return;
try {
await Dynamsoft.DBR.BarcodeReader.loadWasm();
}
catch (ex) {
console.error(ex);
}
}

export async function createBarcodeReader() {
if (!Dynamsoft) return;

try {
let reader = await Dynamsoft.DBR.BarcodeReader.createInstance();
reader.ifSaveOriginalImageInACanvas = true;
return reader;
}
catch (ex) {
console.error(ex);
}
return null;
}

export async function createBarcodeScanner() {
if (!Dynamsoft) return;

try {
let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
return scanner;
}
catch (ex) {
console.error(ex);
}
return null;
}

export function drawCanvas(canvasId, sourceWidth, sourceHeight, results) {
var canvas = document.getElementById(canvasId);
if (!canvas) return;
canvas.width = sourceWidth;
canvas.height = sourceHeight;
var context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);


for (var i = 0; i < results.length; ++i) {
let result = results[i];
context.beginPath();
context.strokeStyle = 'red';
context.lineWidth = 5;
context.moveTo(result.x1, result.y1);
context.lineTo(result.x2, result.y2);
context.lineTo(result.x3, result.y3);
context.lineTo(result.x4, result.y4);
context.lineTo(result.x1, result.y1);
context.stroke();

let x = [result.x1, result.x2, result.x3, result.x4];
let y = [result.y1, result.y2, result.y3, result.y4];
x.sort(function (a, b) {
return a - b;
});
y.sort(function (a, b) {
return a - b;
});
let left = x[0];
let top = y[0];

context.font = '18px Verdana';
context.fillStyle = '#ff0000';
context.fillText(result.text, left, top);
}
}

export function clearCanvas(canvasId) {
var canvas = document.getElementById(canvasId);
if (!canvas) return;
var context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
}

export function decodeBase64Image(base64) {
return new Promise((resolve, reject) => {
var canvas = document.createElement("canvas");
var image = new Image();
image.src = base64;
image.onload = () => {
canvas.width = image.width;
canvas.height = image.height;
let context = canvas.getContext('2d');
context.drawImage(image, 0, 0, canvas.width, canvas.height);
resolve(canvas);
};
image.onerror = (error) => {
reject(error);
};
});
}

export function getSourceWidth(reader) {
let canvas = reader.getOriginalImageInACanvas();
return canvas.width;
}

export function getSourceHeight(reader) {
let canvas = reader.getOriginalImageInACanvas();
return canvas.height;
}

export async function setVideoElement(scanner, videoId) {
if (!Dynamsoft) return;

try {
await scanner.setUIElement(document.getElementById(videoId));
}
catch (ex) {
console.error(ex);
}
}

export async function openCamera(scanner, cameraInfo) {
if (!Dynamsoft) return;

try {
await scanner.setCurrentCamera(cameraInfo);
scanner.onFrameRead = results => {
console.log(results);
};
scanner.onUnduplicatedRead = (txt, result) => { };
scanner.onPlayed = function () {

}
await scanner.show();
}
catch (ex) {
console.error(ex);
}
}

export async function closeCamera(scanner) {
if (!Dynamsoft) return;

try {
await scanner.close();
}
catch (ex) {
console.error(ex);
}
}

export async function getCameras(scanner) {
if (!Dynamsoft) return;

try {
return await scanner.getAllCameras();
}
catch (ex) {
console.error(ex);
}
}
11 changes: 11 additions & 0 deletions _content/Razor.Barcode.Library/dbr-9.6.31.browser.worker.js

Large diffs are not rendered by default.

Binary file not shown.
Loading

0 comments on commit e1dc142

Please sign in to comment.