Skip to content

Commit c26fd19

Browse files
author
Affolter Matias
committed
Modified the import of image
1 parent 3a7b988 commit c26fd19

File tree

6 files changed

+221
-238
lines changed

6 files changed

+221
-238
lines changed

‎client/chunk_26.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎client/chunk_3.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎service-worker.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
2-
var REQUIRED_CACHE = "unless-update-cache-v543-required";
3-
var USEFUL_CACHE = "unless-update-cache-v543-useful";
4-
var STATIC_CACHE = "unless-update-cache-v543-static";
2+
var REQUIRED_CACHE = "unless-update-cache-v544-required";
3+
var USEFUL_CACHE = "unless-update-cache-v544-useful";
4+
var STATIC_CACHE = "unless-update-cache-v544-static";
55
var MAIN_CHILD_CHUNK_REGEX = /chunk_(main_[a-z0-9]+)\.min\.js$/i;
66
var CHILD_CHUNK_REGEX = /chunk_([0-9]+)\.min\.js$/i;
77

‎src/js/pages/Pixel.js‎

Lines changed: 194 additions & 211 deletions
Large diffs are not rendered by default.

‎src/js/utils/img_manipulation.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ window.base64_to_bitmap_process_function = new AsyncFunction(`var t = async func
106106

107107
const base64_to_bitmap = (base64, callback_function = () => {}, pool = null) => {
108108

109-
110-
111109
if(pool !== null) {
112110

113111
pool.exec(window.base64_to_bitmap_process_function, [
@@ -130,6 +128,11 @@ const base64_to_bitmap = (base64, callback_function = () => {}, pool = null) =>
130128

131129
};
132130

131+
const file_to_bitmap = (file_or_blob, callback_function) => {
132+
133+
createImageBitmap(file_or_blob).then(callback_function);
134+
}
135+
133136
const bitmap_to_imagedata = (bitmap, resize_to = 1920*1080, callback_function = () => {}) => {
134137

135138
let scale = 1;
@@ -226,4 +229,4 @@ const imagedata_to_base64 = (imagedata, type= "image/png", callback_function = (
226229

227230
};
228231

229-
module.exports = { file_to_base64, base64_to_bitmap, bitmap_to_imagedata, imagedata_to_base64, base64_sanitize }
232+
module.exports = { file_to_base64, base64_to_bitmap, bitmap_to_imagedata, imagedata_to_base64, base64_sanitize, file_to_bitmap }

‎src/js/utils/QuantiMat.js‎ renamed to ‎src/js/utils/quantimat/QuantiMat.js‎

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -818,28 +818,28 @@ var QuantiMatGlobal = function(
818818
var image_data_uint32 = new Uint32Array(image_data.data.slice(0, image_data.data.length).reverse().buffer).reverse()
819819
var color_index = 0;
820820
var _pxl_colors = new Uint32Array(image_data_uint32.length);
821-
var _pxls = new Uint32Array(image_data_uint32.length);
821+
var pxls = new Uint32Array(image_data_uint32.length);
822822
var index_of = 0;
823823

824824
for(var i = 0; (i|0) < (image_data_uint32.length|0); i = (i+1|0)>>>0) {
825825

826-
index_of = _pxl_colors.indexOf(image_data_uint32[i]);
826+
index_of = _pxl_colors.indexOf((image_data_uint32[i]|0)>>>0);
827827
if(index_of === -1) {
828-
_pxl_colors[color_index] = image_data_uint32[i] | 0;
829-
index_of = color_index | 0;
830-
color_index = color_index + 1 | 0;
828+
_pxl_colors[color_index|0] = (image_data_uint32[i]|0)>>>0;
829+
index_of = (color_index | 0) >>> 0;
830+
color_index = (color_index + 1 | 0) >>> 0;
831831
}
832832

833-
_pxls[i] = index_of | 0;
833+
pxls[i|0] = (index_of | 0) >>> 0;
834834
}
835835

836-
_pxl_colors = _pxl_colors.slice(0, color_index);
836+
var pxl_colors = _pxl_colors.slice(0, color_index);
837837
var now = Date.now();
838-
//console.log(_pxl_colors.length)
838+
console.log(pxl_colors.length)
839839

840840
var result = QuantiMat({
841-
pxls: _pxls,
842-
pxl_colors: _pxl_colors,
841+
pxls: pxls,
842+
pxl_colors: pxl_colors,
843843
bucket_threshold: bucket_threshold,
844844
threshold_steps: threshold_steps,
845845
color_number_bonus: color_number_bonus,
@@ -850,16 +850,13 @@ var QuantiMatGlobal = function(
850850
var res_pxls = result[0];
851851
var res_pxl_colors = result[1];
852852

853-
//console.log(res_pxl_colors.length);
854-
//console.log("We removed and processed "+(_pxl_colors.length-res_pxl_colors.length)+" colors within " + (now - Date.now()) + " ms");
855-
_pxls = new Uint32Array(result[0].length);
856-
857-
for(var i = 0; (i|0) < (_pxls.length|0); i = (i+1|0)>>>0) {
858-
859-
_pxls[i] = res_pxl_colors[res_pxls[i]] | 0;
853+
console.log(res_pxl_colors.length);
854+
console.log("We removed and processed "+(_pxl_colors.length-res_pxl_colors.length)+" colors within " + (Date.now() - now) + " ms");
855+
pxls = new Uint32Array(result[0].length);
856+
for(var i = 0; (i|0) < (pxls.length|0); i = (i+1|0)>>>0) {
857+
pxls[i|0] = (res_pxl_colors[res_pxls[i|0]|0] | 0) >>> 0;
860858
}
861-
862-
image_data.data.set(new Uint8ClampedArray(_pxls.reverse().buffer).reverse());
859+
image_data.data.set(new Uint8ClampedArray(pxls.reverse().buffer).reverse());
863860

864861
resolve(image_data);
865862
});

0 commit comments

Comments
 (0)