..i think this will be an example

package util.image.io;

import java.awt.*;
import java.awt.event.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.geom.GeneralPath;
import java.io.*;
file://import javax.swing.*;

public class jpeg
{
 public static boolean Write(BufferedImage img,OutputStream out,float qual)
 {
  boolean ret=false;
  if (out!=null)
  {
   JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
   JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);

   file://param.setQuality(0.5f, false);
   param.setQuality(qual, false);

   encoder.setJPEGEncodeParam(param);
   try
   {
    encoder.encode(img);
    ret=true;
   }
   catch (IOException ex)
   {
    System.out.println(ex.getLocalizedMessage());
   }
  }
  return ret;
 }

 public static BufferedImage Read(InputStream in)
 {
  BufferedImage ret=null;
  if (in!=null)
  {
   JPEGImageDecoder decoder =  JPEGCodec.createJPEGDecoder(in);
   /*JPEGEncodeParam param = decoder.getDefaultJPEGEncodeParam(img);
   param.setQuality(1.0f, false);
   encoder.setJPEGEncodeParam(param);*/
   try
   {
    ret=decoder.decodeAsBufferedImage();
   }
   catch (IOException ex)
   {
    System.out.println(ex.getLocalizedMessage());
   }
  }
  return ret;
 }
}


Michael :)
p.s.: hope, this will help a bit...


----- Original Message -----
From: Manish Bijay Kumar <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 25, 2000 9:09 AM
Subject: com.sun.image.codec.jpeg


> Hi All,
> Has any body used the com.sun.image.codec.jpeg API. It would be great if
> some can provide some good examples on  the above.
>
>
> Thanks,
> Manish
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to