From 32f1e7e4bdb7ec7e5c2c42cde6a11ce2a714137f Mon Sep 17 00:00:00 2001 From: hurricaneJoef <33767776+hurricaneJoef@users.noreply.github.com> Date: Fri, 10 Jul 2020 20:41:16 -0400 Subject: [PATCH] Update index.html added rgb888support --- index.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/index.html b/index.html index e3eeae3..9123bda 100644 --- a/index.html +++ b/index.html @@ -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 = "";