|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
JAI save a .jpg file -- failed to be previewed.Hi, All:
Sorry for my stupid question. I'm trying to save an .jpg file using JAI. My code is as follows: BufferedImage bImage = doRender(width, height); RenderedImage fImage = JAI.[b]create[/b]("format", bImage, DataBuffer.TYPE_BYTE); JAI.create("filestore", fImage, filename + ".jpg", "jpeg", null); However, Eclipse notified that the 2nd line is deprecated and there is a cross line on "create" in the 2nd line. What's more, even if the 2nd line is deprecated, I'm still able to save an image in .jpg format. However, what has been saved can not be previewed by many softwares, including "Windows Picture and Fax Viewer", "Image Magic Display", "Windows Paint", etc. I can only preview the image by using "QuickTime Picture Viewer". That's not actually what I expected and I think the saved image should be able to be previewed by all the popular softwares. So, can you please help to give me your code when you tried to save .jpg files? Thanks in advance. Best Regards JIA Pei [Message sent by forum member 'jiapei100' (jiapei100)] http://forums.java.net/jive/thread.jspa?messageID=361086 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
RE: JAI save a .jpg file -- failed to be previewed.How about using ImageIO.write(fImage, "jpeg", new File(filename+".jpg"))
For the format operation, you should first create a parameterblock, add the source image and the TYPE_BYTE to the parameter block and then call the JAI.create() with that? There should be examples of this on the web. Good luck. > -----Original Message----- > From: jai-interest@... [mailto:jai- > interest@...] > Sent: Tuesday, August 18, 2009 11:32 PM > To: interest@... > Subject: [JAI] JAI save a .jpg file -- failed to be previewed. > > Hi, All: > Sorry for my stupid question. I'm trying to save an .jpg file using > JAI. My code is as follows: > > > BufferedImage bImage = doRender(width, height); > > RenderedImage fImage = JAI.[b]create[/b]("format", bImage, > DataBuffer.TYPE_BYTE); > > JAI.create("filestore", fImage, filename + ".jpg", "jpeg", null); > > > However, Eclipse notified that the 2nd line is deprecated and there is > a cross line on "create" in the 2nd line. > > What's more, even if the 2nd line is deprecated, I'm still able to save > an image in .jpg format. However, what has been saved can not be > previewed by many softwares, including "Windows Picture and Fax > Viewer", "Image Magic Display", "Windows Paint", etc. I can only > preview the image by using "QuickTime Picture Viewer". That's not > actually what I expected and I think the saved image should be able to > be previewed by all the popular softwares. > > So, can you please help to give me your code when you tried to save > .jpg files? Thanks in advance. > > Best Regards > JIA Pei > [Message sent by forum member 'jiapei100' (jiapei100)] > > http://forums.java.net/jive/thread.jspa?messageID=361086 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: interest-unsubscribe@... > For additional commands, e-mail: interest-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: JAI save a .jpg file -- failed to be previewed.Jia Pei,
Nigel wroteL > How about using ImageIO.write(fImage, "jpeg", new File(filename+".jpg")) > > For the format operation, you should first create a parameterblock, add the source image and the TYPE_BYTE to the parameter block and then call the JAI.create() with that? > > There should be examples of this on the web. > Please see code in http://www.lac.inpe.br/~rafael.santos/JIPCookbook/6040-howto-compressimages.jsp#howtohowcanireduceanimagefilesizewithoutlosingquality and http://www.lac.inpe.br/~rafael.santos/JIPCookbook/1300-create-rgb.jsp#imageanddatamanipulationcreatingrgbimages Some of the examples are for PNG images, but the basic idea is the same. hope it helps Rafael --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: RE: JAI save a .jpg file -- failed to be previewed.Hi, Nidel, Mike :
Thank you for your reply. Yes, ImageIO does work for me. However, 1) can you explain why JAI.create("filestore", fImage, filename + ".jpg", "jpeg", null); doesn't work for me ( can't be previewed by some softwares) but ImageIO.write(fImage, "jpeg", new File(filename+".jpg")); can ??? Do you know what happens exactly inside JAI / ImageIO ? 2) Still, the 2nd line is deprecated. Can you suggest me a way out? RenderedImage fImage = JAI.create("format", bImage, DataBuffer.TYPE_BYTE); Thanks again. Best Regards JIA [Message sent by forum member 'jiapei100' (jiapei100)] http://forums.java.net/jive/thread.jspa?messageID=361132 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
RE: RE: JAI save a .jpg file -- failed to be previewed.2) As I said, you should create a parameter block object.
The versions of JAI.create() that accept the parameters directly are deprecated. See the documentation here. http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/JAI.html 1) No, I don't know why this JPEG seems incorrect. Can you open it in any software at all? What is the problem when you open it? The JAI codec readers and writers are effectively deprecated and should not be used. > -----Original Message----- > From: jai-interest@... [mailto:jai- > interest@...] > Sent: Wednesday, August 19, 2009 6:26 AM > To: interest@... > Subject: Re: RE: [JAI] JAI save a .jpg file -- failed to be previewed. > > Hi, Nidel, Mike : > > Thank you for your reply. Yes, ImageIO does work for me. However, > > 1) can you explain why > JAI.create("filestore", fImage, filename + ".jpg", "jpeg", null); > doesn't work for me ( can't be previewed by some softwares) > but > ImageIO.write(fImage, "jpeg", new File(filename+".jpg")); > can ??? Do you know what happens exactly inside JAI / ImageIO ? > > 2) Still, the 2nd line is deprecated. Can you suggest me a way out? > RenderedImage fImage = JAI.create("format", bImage, > DataBuffer.TYPE_BYTE); > > Thanks again. > > Best Regards > JIA > [Message sent by forum member 'jiapei100' (jiapei100)] > > http://forums.java.net/jive/thread.jspa?messageID=361132 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: interest-unsubscribe@... > For additional commands, e-mail: interest-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: RE: RE: JAI save a .jpg file -- failed to be previewed.Hi, Mike.
Thank you for your reply. Rather than using the deprecated RenderedImage fImage = JAI.create("format", bImage, DataBuffer.TYPE_BYTE); Now, I use ParameterBlock params = new ParameterBlock(); params.addSource(bImage); RenderedOp fImage = JAI.create("format", params); Now, problem seems to be solved. However, it's strange that when I tried to save the image, some times, it only saves the Canvas background, without foreground. Some times, it works OK.... Anyway, thank you very much for your help. Rgds JIA [Message sent by forum member 'jiapei100' (jiapei100)] http://forums.java.net/jive/thread.jspa?messageID=361146 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
RE: RE: RE: JAI save a .jpg file -- failed to be previewed.Do you have the same problem saving the image if you use
ImageIO? > -----Original Message----- > From: jai-interest@... [mailto:jai- > interest@...] > Sent: Wednesday, August 19, 2009 8:10 AM > To: interest@... > Subject: Re: RE: RE: [JAI] JAI save a .jpg file -- failed to be > previewed. > > Hi, Mike. > Thank you for your reply. > > Rather than using the deprecated > RenderedImage fImage = JAI.create("format", bImage, > DataBuffer.TYPE_BYTE); > > Now, I use > ParameterBlock params = new ParameterBlock(); > params.addSource(bImage); > RenderedOp fImage = JAI.create("format", params); > > Now, problem seems to be solved. However, it's strange that when I > tried to save the image, some times, it only saves the Canvas > background, without foreground. Some times, it works OK.... > > Anyway, thank you very much for your help. > > Rgds > JIA > [Message sent by forum member 'jiapei100' (jiapei100)] > > http://forums.java.net/jive/thread.jspa?messageID=361146 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: interest-unsubscribe@... > For additional commands, e-mail: interest-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
| Free embeddable forum powered by Nabble | Forum Help |