Loading...
Logo
Processing Forum

printing machine

in Programming Questions  •  3 years ago  
hi everybody,

i'm pretty new to processing and i wonder wether processing is the right thing for my project or not.

i need a program that randomly loads a picture (from about 2000 images) and sends it to an actual printer and never loads that picture again.

but printing is not that easy in processing?

what do you think?

and if processing is right, where should i start?

(i dont want any complete code from you, but i need a starting point...)

thank you,
mpod
.

Replies(5)

Re: printing machine

3 years ago
thank you for that article, but i think i'll rather
do a workaround.

i now save the frame to a folder. another program watches that folder and prints whatever new is in there.

now i have to figure out how to solve this:

i have two ideas for this:

1. i have 100 images and want to randomly load one of them (when a key is pressed).
but no image should load more than 20 times.

2. i have 2000 images and want to randomly load one of them (when a key is pressed),
but every image should just load once.

which option is more easy?
2000 images are not as easy to handle as 100 images, so i'd prefer to do the first idea.

how should i do that? any ideas?

Re: printing machine

3 years ago
I can think of the thought process for both methods but somebody here might be able to provide better code:

1. Make an int array of100 values where each value can be a number between 0 and 19 so that you can store how many times each image has been loaded and refer back to this.

2. Similarly, make a boolean array of 2000 values where the value is either true or false to say whether the image has been loaded.


If you're not familiar with the code for these I can draw up something really simple but I think I might miss an even easier way of doing it.

Re: printing machine

3 years ago
if you could draw up something? that would be awesome...

my code so far is (it's not that much...)

Copy code
  1. PImage img;

  2. void setup() {
  3. size (500,800);
  4. noLoop();
  5. }

  6. void draw() {
  7. }

  8. void keypressed() {
  9. img = loadImage("10.jpg");
  10. image(img,0,0);
  11. stroke(0);
  12. fill(150);
  13. rect(50,50,75,100);
  14. saveframe("outputpic.jpg")
  15. noLoop();
  16. }

instead of the rectangle, i want to draw a text that says "x/20", where x is the number of the already printed images.

you know what i mean? but i could use the the array fot that, i think...

Re: printing machine

3 years ago
alright

i tried to come up with something:
but with 10 images and max 5 prints... (for testing)

Copy code
  1. void keyPressed() {
  2. in i = int (random(10));
  3. if (images[i] < 5) {
  4. img = loadImag(i + ".jpg")
  5. image(img,0,0)
  6. x = Integer.toString(images[i]+1);
  7. fill(0);
  8. images[i] = images [i] + 1
  9. text(x+"/5",100,100);
  10. saveFrame("outputjpg.jpg");
  11. noLoop;
  12. }
  13. }

it works fine, but if if() returns false, nothing happens... how does it look for another picture, thats not already has been printed 5 times?

and is there a way to save whats in the array? so when the program crashes, i can restart it and the array was where it was?

thank you.