mirror of
https://github.com/javl/image2cpp.git
synced 2026-07-28 04:05:35 +00:00
fixed the error when convert image into codes in vertical mode
This commit is contained in:
+8
-5
@@ -668,18 +668,22 @@
|
||||
var w = document.createElement("input");
|
||||
w.type = "number";
|
||||
w.name = "width";
|
||||
w.id = "screenWidth";
|
||||
w.min = 0;
|
||||
w.className = "size-input";
|
||||
w.value = img.width;
|
||||
w.oninput = function() { canvas.width = this.value; update(); };
|
||||
settings["screenWidth"] = img.width;
|
||||
w.oninput = function() { canvas.width = this.value; update(); updateInteger('screenWidth'); };
|
||||
|
||||
var h = document.createElement("input");
|
||||
h.type = "number";
|
||||
h.name = "height";
|
||||
h.id = "screenHeight";
|
||||
h.min = 0;
|
||||
h.className = "size-input";
|
||||
h.value = img.height;
|
||||
h.oninput = function() { canvas.height = this.value; update(); };
|
||||
settings["screenHeight"] = img.height;
|
||||
h.oninput = function() { canvas.height = this.value; update(); updateInteger('screenHeight'); };
|
||||
|
||||
var gil = document.createElement("span");
|
||||
gil.innerHTML = "glyph";
|
||||
@@ -796,7 +800,6 @@
|
||||
|
||||
// Output the image as a string for vertically drawing displays
|
||||
function imageToStringVertical(image){
|
||||
var page = 0;
|
||||
var ctx = image.ctx;
|
||||
var canvas = image.canvas;
|
||||
|
||||
@@ -807,12 +810,12 @@
|
||||
var output_index = 0;
|
||||
|
||||
for(var p=0; p < Math.ceil(settings["screenHeight"] / 8); p++){
|
||||
for(var x = 0; x <= settings["screenWidth"]; x++){
|
||||
for(var x = 0; x < settings["screenWidth"]; x++){
|
||||
var byteIndex = 7;
|
||||
var number = 0;
|
||||
|
||||
for (var y = 7; y >= 0; y--){
|
||||
var index = ((p*8)+y)*(settings["screenWidth"]*4)+x;
|
||||
var index = ((p*8)+y)*(settings["screenWidth"]*4)+x*4;
|
||||
var avg = (data[index] + data[index +1] + data[index +2]) / 3;
|
||||
if (avg > settings["threshold"]){
|
||||
number += Math.pow(2, byteIndex);
|
||||
|
||||
Reference in New Issue
Block a user