1
即時通訊試圖找出如何挑選出最新的文件夾加載到PImage。我無法想出一個辦法。使用PImage獲得最新的文件夾(處理)
我有兩個小品,一個是創建一組圖片,並在加載它們之一。這是加載它們之一。
一個新文件夾我的草圖中每次創建數據文件夾其他草圖運行。我需要挑出最近創建的文件夾並將其加載到我的PImage中。它看起來像http://imgur.com/a/u1jF0
因此,下一個文件夾的名稱將被稱爲test_segments2,然後測試segments3 ...等等。
CODE:
final int len = 25;
final float thresh = 170;
boolean newDesign = false;
PImage pic;
ArrayList<PImage> imgContainer;
int n = 1;
void setup() {
size(800, 800, P2D);
colorMode(RGB, 255);
background(250, 250, 250);
rectMode(CENTER);
// imageMode(CENTER);
pic = loadImage("hand.jpg");
pic.resize(width, height);
color c1 = color(200, 25, 25);
color c2 = color(25, 255, 200);
imgContainer = new ArrayList<PImage>();
PImage pimg1 = loadImage("THIS IS WHERE I NEED THE PATH OF MOST RECENT FOLDER CREATED TO GO");
pimg1.resize(50, 50);
noLoop();
noStroke();
}
void draw() {
if (newDesign == false) {
return;
}
pic.loadPixels();
for (int y = 0; y < height; y += 40) {
for (int x = 0; x < width; x += 40) {
int index = y * width + x;
color pixelValue = pic.pixels[index];
color rgb = pixelValue;
int r = (rgb >> 16) & 0xFF; // Faster way of getting red(argb)
int g = (rgb >> 8) & 0xFF; // Faster way of getting green(argb)
int b = rgb & 0xFF;
// How far is the current color from white
float dista = dist(r, g, b, 255, 255, 255);
// 50 is a threshold value allowing close to white being
// identified as white
// This value needs to be adjusted based on your actual
// background color
// Next block is processed only if the pixel not white
if (dista > 30) {
float pixelBrightness = brightness(pixelValue);
float imgPicked = constrain(pixelBrightness/thresh, 0, n - 1);
image(imgContainer.get((int) imgPicked), x, y);
}
}
}
}
void mouseReleased() {
newDesign=!newDesign;
redraw();
}
好酷。列出的所有文件類型中哪一個最好?我看到filedatasoure,filefilter,filenamefilter ...? – guyintightpants
@guyintightpants我只是從'File'類開始。 –
哦,我現在看到它。我看到lastModified ....我如何獲得有關文件的元數據? – guyintightpants