Создайте свой собственный DataSource класс и возьмите свой входной поток из ByteArrayInputStream, оборачивая байты изображения.
Что-то вроде:
public class ImageDataSource implements DataSource {
private Image image = null;
private String imageName = "";
public ImageDataSource( Image image, String imageName ) {
this.image = image;
this.imageName = imageName;
}//cons
public InputStream getInputStream() {
return new ByteArrayInputStream( image.getBytes() );
}//met
public OutputStream getOutputStream() {
throw new IOException();
}//met
public String getName() {
return imageName;
}//met
public String getMimeType() {
return "image/png";
}//met
private byte [] getImgBytes(Image image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ImageIO.write(getBufferedImage(image), "png", baos);
} catch (IOException ex) {
//handle it here.... not implemented yet...
}
return baos.toByteArray();
}//met
}//class
Более или менее, я не получил IDE:)