generateRGB method
Implementation
image_lib.Image generateRGB(String result, int width, int height) {
List<int> binaryList = Dependencies().binaryToDecimal(result);
int properLength = binaryList.length;
if (properLength != width * height * 3) {
throw Exception("Error: Invalid info length for Address image");
} else {
image_lib.Image image = image_lib.Image(width, height);
//Portion which is slightly different from java code
int a = 255, q = 0, r = 0, g = 0, b = 0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = binaryList[q];
g = binaryList[q + 1];
b = binaryList[q + 2];
q = q + 3;
image.setPixelRgba(j, i, r, g, b, a);
}
}
return image;
}
}