Re: Image manipulation in applications

From: perry (perry_at_cplusplus.org)
Date: 05/24/04


Date: Mon, 24 May 2004 10:26:41 -0400

what kind of app are you working on or is this some sort of extended
assignement ?

news.skynet.be wrote:
> sorry I put this in the wrong place
>
> I managed to do this with ImageIO, example taken from:
>
> http://www.geocities.com/marcoschmidt.geo/java-save-screenshot.html
>
> watch out for the javascript errors, but good site with loads of image and
> java stuff...
>
> This was the code I used.
>
> // temp output file bit
> public void outputFile() throws Exception{
> //start of the output stuff
>
> FileOutputStream fo = new FileOutputStream("myImg.jpg");//name of image
>
> BufferedOutputStream bo = new BufferedOutputStream(fo);//set to buffered
> stream
>
> //destination here is the name of the raster reference. referencing a
> bufferedImage
> ImageIO.write(destination, "jpeg", bo);//write the file out using ImageIO
> to the HD
>
> bo.close();
> //end of the output stuff
> }
> // EOF temp outupt file bit
>
> hope this helps
>
> cheers
> Martin
>
> From: "Murray" <parps@SPAMoffSPAMMER.optusSP4Mnet.com.au>
> Subject: Re: Saving a BufferedImage as a JPEG
> Date: 07 May 2004 16:49
>
>
> "Michael Johnston" <michael.a.johnston@saic.com> wrote in message
> news:72341cfc.0405070606.1ba2ff72@posting.google.com...
>
>>I am saving a BufferedImage as a JPEG file under Windows XP.
>>I am using the JAI JPEGImageEncoder class.
>>The JPEG is saved as CMYK but I need RGB.
>>I cannot figure out how to get RGB. Any help?
>
>
> Where is the BufferedImage coming from? If you're creating the object
> yourself, try using INT_RGB imageType instead of the default ARGB.
>
> image = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
>
> It might also be worth trying this:
>
> JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
> JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(image);
> encoder.encode(img, param);
>
>
>
>
>



Relevant Pages

  • Re: confused about image colorspaces
    ... says "setRGB(int x, int y, int rgb) Sets a pixel in this BufferedImage ... how to code an "int rgb", so I assumed that was just an INDEX in the LUT ... Sets a pixel in this BufferedImage to the specified RGB value. ...
    (comp.lang.java.programmer)
  • Re: Save an Image to a file
    ... -The applet to create a jpg in memory from either a BufferedImage, ... Write the BufferedImage to your server with the ImageIO.writein JPEG format. ... If you send your server an array of bytes that is an image of a JPEG file then you can just write the bytes to a file and you're done. ...
    (comp.lang.java.programmer)
  • Re: Saving a BufferedImage as a JPEG
    ... > I am saving a BufferedImage as a JPEG file under Windows XP. ... > I am using the JAI JPEGImageEncoder class. ... Where is the BufferedImage coming from? ... JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam; ...
    (comp.lang.java)
  • Re: SampleModel, Raster, Color
    ... BufferedImage bi = new BufferedImage(stdX, stdY, ... // assemble rgb data from the components ... What you are saying is that there is no need to create a WritableRaster and DataBuffer, ...
    (comp.lang.java.gui)
  • image to jpg
    ... Saving a BufferedImage as a JPEG ... > The JPEG is saved as CMYK but I need RGB. ... JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam; ...
    (comp.lang.java)