Update index.html

added rgb888support
This commit is contained in:
hurricaneJoef
2020-07-10 20:41:16 -04:00
committed by GitHub
parent 1e3d190465
commit 32f1e7e4bd
+29
View File
@@ -480,7 +480,36 @@
}
return output_string;
},
// Output the image as a string for rgb888 displays (horizontally)
horizontal888: function (data, canvasWidth, canvasHeight){
var output_string = "";
var output_index = 0;
// format is RGBA, so move 4 steps per pixel
for(var index = 0; index < data.length; index += 4){
// Get the RGB values
var r = data[index];
var g = data[index + 1];
var b = data[index + 2];
// calculate the 565 color value
var rgb = (r << 16) | (g << 8) | (b);
// Split up the color value in two bytes
var firstByte = (rgb >> 8) & 0xff;
var secondByte = rgb & 0xff;
var byteSet = rgb.toString(16);
while(byteSet.length < 8){ byteSet = "0" + byteSet; }
output_string += "0x" + byteSet + ", ";
// add newlines every 16 bytes
output_index++;
if(output_index >= canvasWidth){
output_string += "\n";
output_index = 0;
}
}
return output_string;
},
// Output the alpha mask as a string for horizontally drawing displays
horizontalAlpha: function (data, canvasWidth, canvasHeight){
var output_string = "";