mirror of
https://github.com/javl/image2cpp.git
synced 2026-07-27 19:56:07 +00:00
Batch processing simplifier -- Update naming to include filename. Add pointer array for iterating. Add rotate180 option. Output for Arduino by default.
This commit is contained in:
+38
-10
@@ -245,6 +245,12 @@
|
||||
<input id="invertColors" type="checkbox" onchange="updateBoolean('invertColors')" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-row">
|
||||
<div class="table-cell"><label for="invertColors">Rotate image 180</label></div>
|
||||
<div class="table-cell">
|
||||
<input id="rotate180" type="checkbox" onchange="updateBoolean('rotate180')" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-row">
|
||||
<div class="table-cell"><label>Brightness / alpha threshold: </label></div>
|
||||
<div class="table-cell">
|
||||
@@ -333,9 +339,9 @@
|
||||
</div>
|
||||
<div id="arduino-identifier" class="table nested-table">
|
||||
<div class="table-row">
|
||||
<div class="table-cell"><label>Identifier:</label></div>
|
||||
<div class="table-cell"><label>Identifier/Prefix:</label></div>
|
||||
<div class="table-cell">
|
||||
<input id="identifier" class="text-input" type="text" name="identifier" onchange="" value="myBitmap"/>
|
||||
<input id="identifier" class="text-input" type="text" name="identifier" onchange="" value="epd_bitmap_"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -372,7 +378,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
var ConversionFunctions = {
|
||||
// Output the image as a string for horizontally drawing displays
|
||||
horizontal1bit: function (data, canvasWidth, canvasHeight){
|
||||
@@ -619,6 +625,7 @@
|
||||
threshold: 128,
|
||||
outputFormat: "plain",
|
||||
invertColors: false,
|
||||
rotate180: false,
|
||||
conversionFunction: ConversionFunctions.horizontal1bit
|
||||
};
|
||||
|
||||
@@ -752,6 +759,15 @@
|
||||
}
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0); // start with identity matrix transform (no rotation).
|
||||
if(settings["rotate180"]){
|
||||
// Matrix transformation
|
||||
ctx.translate(canvas.width/2.0, canvas.height/2.0);
|
||||
ctx.rotate(Math.PI);
|
||||
ctx.translate(-canvas.width/2.0, -canvas.height/2.0);
|
||||
}
|
||||
|
||||
|
||||
// Offset used for centering the image when requested
|
||||
var offset_x = 0;
|
||||
var offset_y = 0;
|
||||
@@ -1002,7 +1018,9 @@
|
||||
switch(settings["outputFormat"]) {
|
||||
|
||||
case "arduino": {
|
||||
|
||||
let varQuickArray = [];
|
||||
let bytesUsed = 0;
|
||||
// --
|
||||
images.each(function(image) {
|
||||
code = imageToString(image);
|
||||
|
||||
@@ -1012,15 +1030,21 @@
|
||||
code = "\t" + code.split("\n").join("\n\t") + "\n";
|
||||
var variableCount = images.length() > 1 ? count++ : "";
|
||||
var comment = "// '" + image.glyph + "', "+image.canvas.width+"x"+image.canvas.height+"px\n";
|
||||
bytesUsed += code.split("\n").length * 16; // 16 bytes per line.
|
||||
console.log(image);
|
||||
|
||||
code = comment + "const " + getType() + " " +
|
||||
getIdentifier() +
|
||||
variableCount +
|
||||
" [] PROGMEM = {" +
|
||||
"\n" + code + "};\n";
|
||||
|
||||
let varname = getIdentifier() + image.glyph.replace(/[^a-zA-Z0-9]/g,"_");
|
||||
varQuickArray.push(varname);
|
||||
code = comment + "const " + getType() + " " + varname + " [] PROGMEM = {\n" + code + "};\n";
|
||||
output_string += code;
|
||||
});
|
||||
// --
|
||||
varQuickArray.sort();
|
||||
// --
|
||||
output_string += "\n// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = "+bytesUsed+")\n"
|
||||
output_string += "const int " + (getIdentifier()+"allArray_LEN") + " = " + varQuickArray.length + ";\n"
|
||||
output_string += "const " + getType() + "* " + (getIdentifier()+"allArray") + "["+varQuickArray.length+"] = {\n\t"+varQuickArray.join(",\n\t")+"\n};\n";
|
||||
// --
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1279,6 +1303,10 @@
|
||||
return "unsigned char";
|
||||
}
|
||||
}
|
||||
// --
|
||||
|
||||
document.getElementById("outputFormat").value = "arduino";
|
||||
document.getElementById("outputFormat").onchange();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user