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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.reset();
  51. }
  52. if (key == CODED) {
  53. if (keyCode == RIGHT) {
  54. imageNo++;
  55. if (imageNo > imageAmount) imageNo = imageAmount;
  56. else setImage(imageNo);
  57. println(imageNo);
  58. } else if (keyCode == LEFT) {
  59. imageNo--;
  60. if (imageNo < 0) imageNo = 0;
  61. else setImage(imageNo);
  62. println(imageNo);
  63. }
  64. }
  65. redraw();
  66. }
  67. void mousePressed() {
  68. if(mouseButton == LEFT){
  69. bounder.leftclick();
  70. }
  71. if(mouseButton == RIGHT){
  72. bounder.rightclick();
  73. }
  74. }
  75. void setImage(int i) {
  76. images[i] = loadImage(imagePaths[i]);
  77. imageThumb = images[i].get();
  78. imageThumb.resize(images[i].width/7, images[i].height/7);
  79. imageLoaded = true;
  80. redraw();
  81. }
  82. boolean firstDrop = true;
  83. void dropEvent(DropEvent theDropEvent) {
  84. if (theDropEvent.isFile()) {
  85. File myFile = theDropEvent.file();
  86. if (myFile.isDirectory()) {
  87. File[] droppedFiles = myFile.listFiles();
  88. println(droppedFiles);
  89. folderURI = droppedFiles[0].getParent();
  90. println(folderURI);
  91. for (int i = covers.size(); i-- != 0; covers.remove(i));
  92. ArrayList<String> imgs = new ArrayList<String>();
  93. imageNo = 0;
  94. imageAmount = 0;
  95. for (int i = 0; i < droppedFiles.length; i++) {
  96. String fn = droppedFiles[i].toString().toLowerCase();
  97. if (fn.endsWith(".jpg") || fn.endsWith(".jpeg") || fn.endsWith(".bmp") || fn.endsWith(".png") || fn.endsWith(".gif"))
  98. imgs.add(droppedFiles[i].toString());
  99. }
  100. imageAmount = imgs.size();
  101. imagePaths = new String[imageAmount];
  102. imagePaths = imgs.toArray(imagePaths);
  103. imagePaths = sort(imagePaths);
  104. images = new PImage[imageAmount];
  105. if (imageNo++ <= imageAmount) imageNo++; //open on page 2
  106. setImage(imageNo);
  107. if (firstDrop) {
  108. surface.setSize(displayWidth, displayHeight);
  109. firstDrop = false;
  110. }
  111. }
  112. }
  113. }