kopia lustrzana https://github.com/alanesq/esp32cam-demo
Add files via upload
rodzic
7f33324cd3
commit
8f6a55c758
|
@ -6,7 +6,9 @@
|
|||
// ----------------------------------------------------------
|
||||
|
||||
|
||||
// image file (csv)
|
||||
// Settings
|
||||
|
||||
// image file to read (raw RGB)
|
||||
String fileName = "q.rgb";
|
||||
|
||||
// Image resolution
|
||||
|
@ -14,50 +16,51 @@
|
|||
int resY = 480;
|
||||
|
||||
|
||||
byte[] rgbFile;
|
||||
int xPos = 0;
|
||||
int yPos = 0;
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// Misc variables
|
||||
|
||||
byte[] rgbFile; // store for the file contents
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------
|
||||
|
||||
|
||||
void setup() {
|
||||
|
||||
// open csv file
|
||||
// open the RGB file
|
||||
rgbFile = loadBytes(fileName);
|
||||
print(fileName + " file size = ");
|
||||
println(rgbFile.length);
|
||||
|
||||
size(640,480);
|
||||
background(0);
|
||||
noLoop();
|
||||
stroke(255);
|
||||
size(640,480); // screen size
|
||||
background(0); // background colour of screen (0 = black)
|
||||
noLoop(); // do not keep redrawing the screen
|
||||
|
||||
} // setup
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------
|
||||
|
||||
|
||||
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) {
|
||||
// increment image position
|
||||
xPos = xPos + 1;
|
||||
if (xPos == resX) {
|
||||
xPos = 0;
|
||||
yPos = yPos + 1;
|
||||
}
|
||||
stroke(rgbFile[i+2] & 0xff,rgbFile[i+1] & 0xff,rgbFile[i+0] & 0xff);
|
||||
point(resX-xPos,yPos);
|
||||
// Calculate x and y location in image
|
||||
xPos = (i / 3) % resX;
|
||||
yPos = floor( (i / 3) / resX);
|
||||
stroke(rgbFile[i+2] & 0xff,rgbFile[i+1] & 0xff,rgbFile[i+0] & 0xff);
|
||||
point(resX-xPos,yPos);
|
||||
}
|
||||
|
||||
|
||||
println("Finished");
|
||||
|
||||
} // draw
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// end
|
||||
|
|
Ładowanie…
Reference in New Issue