Tool um rotierte Bildausschnitte aus Bildstapeln zu schneiden
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

scancropper2.pde 2.4KB

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