• 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

BufferedImage to ServletOutputStream: Black Box

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm writing a servlet that accepts the following params thru the URL:

1) a filename for an image sitting on my server, and
2) a pair of X and Y dimensions.

The servlet is supposed to scale the image appropriately and send the result to the response OutputStream. My strategy is: take the image file, load it into a BufferedImage, modify it appropriately, and send it from there to an OutputStream. Here's the code that is supposed to accomplish this:



...that makes sense, right? Currently, getImageFileName() returns the name of a JPEG which I know is valid, and alterImage() does nothing. But here's the thing: when I run this, the image produced is a big black box, and not the expected image at all, and the box has the same dimensions as the expected image.

What am I doing wrong?
 
Greg Donahue
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aha. You have to *display* the image first.



...right after the BufferedImage initialization. Kind of makes sense, and then it kind of doesn't, since you aren't really displaying the image anywhere...
 
reply
    Bookmark Topic Watch Topic
  • New Topic