Tool um rotierte Bildausschnitte aus Bildstapeln zu schneiden
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scancropper2.pde 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import drop.*;
  2. SDrop drop;
  3. Bounder bounder;
  4. int imageNo = 0;
  5. int imageAmount;
  6. ArrayList<Cover> covers = new ArrayList<Cover>();
  7. String[] imagePaths;
  8. PImage[] images;
  9. PImage imageThumb;
  10. boolean imageLoaded;
  11. String folderURI;
  12. PShape COVER;
  13. void setup() {
  14. size(240, 100);
  15. frameRate(30);
  16. noSmooth();
  17. COVER = createShape();
  18. drop = new SDrop(this);
  19. surface.setResizable(true);
  20. bounder = new Bounder();
  21. noLoop();
  22. }
  23. void draw() {
  24. background(255);
  25. fill(0);
  26. text("Drop image folder here", 52, 53, 20);
  27. if (imageLoaded) {
  28. if (images[imageNo] != null) {
  29. image(imageThumb, 0, 0, width, height);
  30. }
  31. }
  32. for (int i = 0; i < covers.size(); i++) {
  33. Cover c = covers.get(i);
  34. shape(c.coverRect);
  35. }
  36. bounder.update();
  37. bounder.display();
  38. }
  39. void keyPressed() {
  40. if (key == ENTER) {
  41. if (bounder.state >= 3) {
  42. println("Compiling images");
  43. bounder.compile(true);
  44. println("Compiling finished, reset bounder");
  45. //bounder.state = 0;
  46. }
  47. }
  48. if (key == ' ') {
  49. if (bounder.state == 3) bounder.compile(false);
  50. bounder.state = 0;
  51. println("Bounder reset");
  52. }
  53. if (key == CODED) {
  54. if (keyCode == RIGHT) {
  55. imageNo++;
  56. if (imageNo > imageAmount) imageNo = imageAmount;
  57. else setImage(imageNo);
  58. println(imageNo);
  59. } else if (keyCode == LEFT) {
  60. imageNo--;
  61. if (imageNo < 0) imageNo = 0;
  62. else setImage(imageNo);
  63. println(imageNo);
  64. }
  65. }
  66. redraw();
  67. }
  68. void mousePressed() {
  69. bounder.click();
  70. }
  71. void setImage(int i) {
  72. images[i] = loadImage(imagePaths[i]);
  73. imageThumb = images[i].get();
  74. imageThumb.resize(images[i].width/7, images[i].height/7);
  75. imageLoaded = true;
  76. redraw();
  77. }
  78. void dropEvent(DropEvent theDropEvent) {
  79. if (theDropEvent.isFile()) {
  80. File myFile = theDropEvent.file();
  81. if (myFile.isDirectory()) {
  82. File[] droppedFiles = myFile.listFiles();
  83. println(droppedFiles);
  84. folderURI = droppedFiles[0].getParent();
  85. println(folderURI);
  86. for (int i = covers.size(); i-- != 0; covers.remove(i));
  87. ArrayList<String> imgs = new ArrayList<String>();
  88. imageAmount = 0;
  89. for (int i = 0; i < droppedFiles.length; i++) {
  90. String fn = droppedFiles[i].toString().toLowerCase();
  91. if (fn.endsWith(".jpg") || fn.endsWith(".jpeg") || fn.endsWith(".bmp") || fn.endsWith(".png") || fn.endsWith(".gif"))
  92. imgs.add(droppedFiles[i].toString());
  93. }
  94. imageAmount = imgs.size();
  95. imagePaths = new String[imageAmount];
  96. imagePaths = imgs.toArray(imagePaths);
  97. imagePaths = sort(imagePaths);
  98. images = new PImage[imageAmount];
  99. if (imageNo++ <= imageAmount) imageNo++; //open on page 2
  100. setImage(imageNo);
  101. surface.setSize(displayWidth, displayHeight);
  102. }
  103. }
  104. }