We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Printer Output
Pages: 1 2 
Printer Output (Read 8971 times)
Re: Printer Output
Reply #15 - Mar 23rd, 2009, 6:57pm
 
I think there something wrong with the bufferimage. it buffers the image with wrong coller aspects. But can't find it. yet Smiley
Re: Printer Output
Reply #16 - Mar 23rd, 2009, 10:49pm
 
Can someone find mistakes in this?
If I save or print an image trough this, it turend out brown/black.

byte[] bufferImage(PImage srcimg){
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 BufferedImage img = new BufferedImage(srcimg.width, srcimg.height,2);
 img = (BufferedImage)createImage(srcimg.width,srcimg.height);
 for(int i = 0; i < srcimg.width; i++)
   for(int j = 0; j < srcimg.height; j++)
     img.setRGB(i,j,srcimg.pixels[j*srcimg.width+i]);
 try{
   JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
   JPEGEncodeParam encpar = encoder.getDefaultJPEGEncodeParam(img);
   encpar.setQuality(1,false);
   encoder.setJPEGEncodeParam(encpar);
   encoder.encode(img);
 }
 catch(FileNotFoundException e){
   System.out.println(e);
 }
 catch(IOException ioe){
   System.out.println(ioe);
 }
 return out.toByteArray();
}
Re: Printer Output
Reply #17 - Mar 29th, 2009, 9:51am
 
Ok, the code works fine for windows. But not for mac.
I olso tried some other possibilities for the docflavor. But without succes.
There must be something wrong with the mac encoder, render??

anyone who can help?

grtz angelo
Re: Printer Output
Reply #18 - Mar 29th, 2009, 10:38am
 
A possible problem is transparency. It must be deactivated for Jpeg images. Try creating the BufferedImage with imageType set to BufferedImage.TYPE_INT_RGB. And not this 2 which comes from who know where! Smiley
Re: Printer Output
Reply #19 - Mar 29th, 2009, 12:20pm
 
they came from the processing.org/hacks  Wink
Ok I will try to buffer it your way

edit:
Still turns out the same very black thing.
If I save that bufferedimage it's "black".
If I do saveFrame it's ok.
So is it possible to print from the save .jpg in my sketch folder.
using DocFlavor.INPUT_STREAM,JPEG instead of the DocFlavor.BYTE_ARRAY,JPEG?

sry I do not know anything about java.
Re: Printer Output
Reply #20 - May 17th, 2009, 5:06am
 
does anyone has an idea why it only works when using windows?
i tried it on mac and i get the described black undefined color mix. when using windows it works perfectly well.....
Re: Printer Output
Reply #21 - May 18th, 2009, 8:36am
 
wrote today some similar code and used the savejpg hack. i'm not having particular problems with the output (tried it on win and mac); the only thing i could suggest, in order to better control your printer, is to play a little with PrintRequestAttributeSet: give a look here and here to figure out how it works
Re: Printer Output
Reply #22 - May 19th, 2009, 10:23am
 
oh thanks for those two links, they might help me....
so would you mind to post your code here?
maybe there some slight changes to the code already posted...
it's definitely strange that it only seems to be working on windows. so your post gives me a little hope to use it on mac as well Wink
Pages: 1 2