• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image Manipulation in JSP without saving to disk

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to...

upload an image...

save the original (B&W) image stream in a javabean..

display a manipulated image (white turned into transparent, black changed to another color)

and save the original to disk once a selection has been made

I will post more details on how I've started going about this later...

Any suggestions..
 
J Wright
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I have...

an upload file that sends image data to place.jsp

place.jsp stores the image data to a java bean (in the form of a MemoryCacheImageInputStream with set and get methods) and displays image.jsp

image.jsp retrieves the MemoryCacheImageInputStream and creates a BufferedImage from it, then creates a filter, takes the BufferedImage and filter and creates an ImageProducer from it

The ImageProducer is then converted back to a BufferedImage and written to the output stream

here is most of thumb.jsp...


response.setContentType("image/jpeg");
OutputStream osResponse = response.getOutputStream();

// Retrieves jpg inputstream from the bean set in place.jsp
MemoryCacheImageInputStream isJpgOld = myBean.getMCIIS();
if(isJpgOld != null)
{
isJpgOld.reset();
BufferedImage biOriginal = ImageIO.read(isJpgOld);
ImageFilter filter = new myRGBImageFilter();

ImageProducer ip = new FilteredImageSource(biOriginal.getSource(), filter);

BufferedImage biNew = toBufferedImage(Toolkit.getDefaultToolkit().createImage(ip));
try{
ImageIO.write(biNew,"jpg",osResponse);
}
catch (IOException e)
{

}

}

This seems to work but I have a few problems...

the major problem is ...

I need to be able to access the original image again after the user chooses the manipulation they like...
Right now I'm calling myBean.getMCIIS().mark() right after I set the MCIIS (MemoryCacheImageInputStream)
but it doesn't work because I have created a file called thumb3.jsp with the same code as thumb.jsp and had place.jsp
display that as well but only one of the manipulated images shows up..
so using mark() and reset() are not doing what I need them to do
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic