Add files via upload

master
Alan 2020-11-13 11:59:37 +00:00 zatwierdzone przez GitHub
rodzic 7f33324cd3
commit 8f6a55c758
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 26 dodań i 23 usunięć

Wyświetl plik

@ -6,7 +6,9 @@
// ---------------------------------------------------------- // ----------------------------------------------------------
// image file (csv) // Settings
// image file to read (raw RGB)
String fileName = "q.rgb"; String fileName = "q.rgb";
// Image resolution // Image resolution
@ -14,41 +16,43 @@
int resY = 480; int resY = 480;
byte[] rgbFile; // ----------------------------------------------------------
int xPos = 0;
int yPos = 0; // Misc variables
byte[] rgbFile; // store for the file contents
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------
void setup() { void setup() {
// open csv file // open the RGB file
rgbFile = loadBytes(fileName); rgbFile = loadBytes(fileName);
print(fileName + " file size = "); print(fileName + " file size = ");
println(rgbFile.length); println(rgbFile.length);
size(640,480); size(640,480); // screen size
background(0); background(0); // background colour of screen (0 = black)
noLoop(); noLoop(); // do not keep redrawing the screen
stroke(255);
} // setup } // setup
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------
void draw() { void draw() {
int xPos;
int yPos;
// work through the RGB file plotting each pixel on the screen
for(int i = 0; i < (rgbFile.length - 2); i+=3) { for(int i = 0; i < (rgbFile.length - 2); i+=3) {
// increment image position // Calculate x and y location in image
xPos = xPos + 1; xPos = (i / 3) % resX;
if (xPos == resX) { yPos = floor( (i / 3) / resX);
xPos = 0;
yPos = yPos + 1;
}
stroke(rgbFile[i+2] & 0xff,rgbFile[i+1] & 0xff,rgbFile[i+0] & 0xff); stroke(rgbFile[i+2] & 0xff,rgbFile[i+1] & 0xff,rgbFile[i+0] & 0xff);
point(resX-xPos,yPos); point(resX-xPos,yPos);
} }
@ -58,6 +62,5 @@ void draw() {
} // draw } // draw
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------
// end