Browse Source

can now drag and drop folders regardless of their content, only containing images will be added to program

master
Victor Giers 1 year ago
parent
commit
6d2f8b5170
2 changed files with 36 additions and 5 deletions
  1. 5
    2
      bounder.pde
  2. 31
    3
      scancropper2.pde

+ 5
- 2
bounder.pde View File

@@ -19,6 +19,8 @@ class Bounder {
}
if (state == 3) {
h = -p2.dist(new PVector(mouseX, mouseY));
}
}
void update() {
@@ -58,7 +60,7 @@ class Bounder {
}
}

void compile() {
void compile(boolean Execute) {
PVector ptopmid = new PVector((p1.x + p2.x)/2, (p1.y + p2.y)/2);
PVector pbotmid = new PVector((p3.x + p4.x)/2, (p3.y + p4.y)/2);

@@ -100,7 +102,8 @@ class Bounder {
//String[] runConvert = { "/bin/bash", "-c", "cd " + folderURI + " && mkdir " + folderName + " && " + cmdleft + " && " + cmdright + " && " + cmdpdf };
String[] runConvert = { "/bin/bash", "-c", "cd " + folderURI + " && mkdir " + folderName + " && " + cmdleft + " && " + cmdright };
exec(runConvert);

if(Execute) exec(runConvert);

//println(leftLeftTopX + "," + leftLeftTopY + " " + leftRightTopX + "," + leftRightTopY + " " + leftRightBotX + "," + leftRightBotY + " " + leftLeftBotX + "," + leftLeftBotY);
//println(rightLeftTopX + "," + rightLeftTopY + " " + rightRightTopX + "," + rightRightTopY + " " + rightRightBotX + "," + rightRightBotY + " " + rightLeftBotX + "," + rightLeftBotY);

+ 31
- 3
scancropper2.pde View File

@@ -4,7 +4,7 @@ SDrop drop;
Bounder bounder;
int imageNo = 0;
int imageAmount;
String[] imageList;
String[] imagePaths;
PImage[] images;
boolean imageLoaded;
String folderURI;
@@ -36,12 +36,13 @@ void keyPressed() {
if (key == ENTER) {
if (bounder.state >= 3) {
println("Compiling images");
bounder.compile();
bounder.compile(true);
println("Compiling finished, reset bounder");
//bounder.state = 0;
}
}
if (key == ' ') {
if(bounder.state == 3) bounder.compile(false);
bounder.state = 0;
println("Bounder reset");
}
@@ -67,9 +68,10 @@ void mousePressed() {

void setImage(int i) {
imageLoaded = false; //seperate threat not present ladida
images[i] = loadImage(imageList[imageNo]);
images[i] = loadImage(imagePaths[imageNo]);
imageLoaded = true;
}

void dropEvent(DropEvent theDropEvent) {

if (theDropEvent.isFile()) {
@@ -79,6 +81,28 @@ void dropEvent(DropEvent theDropEvent) {
println(droppedFiles);
folderURI = droppedFiles[0].getParent();
println(folderURI);
ArrayList<String> imgs = new ArrayList<String>();
imageAmount = 0;
for (int i = 0; i < droppedFiles.length; i++) {
String fn = droppedFiles[i].toString().toLowerCase();
if(fn.endsWith(".jpg") || fn.endsWith(".jpeg") || fn.endsWith(".bmp") || fn.endsWith(".png") || fn.endsWith(".gif"))
imgs.add(droppedFiles[i].toString());
}
imageAmount = imgs.size();
imagePaths = new String[imageAmount];
imagePaths = imgs.toArray(imagePaths);
imagePaths = sort(imagePaths);
/*
for (int i = 0; i < imageAmount; i++) {
imagePaths[i] = droppedFiles[i].toString();
}
*/
images = new PImage[imageAmount];
setImage(imageNo);
/*
imageAmount = droppedFiles.length-1; // assuming all files in folder are images
images = new PImage[imageAmount];
imageList = new String[imageAmount];
@@ -87,6 +111,10 @@ void dropEvent(DropEvent theDropEvent) {
}
imageList = sort(imageList);
setImage(imageNo);
*/
/*for (int i = 0; i < imageAmount; i++) {
images[i] = loadImage(droppedFiles[i].toString());
println("hi");

Loading…
Cancel
Save