Hi,
Java types of RenderedImage and BufferedImage are supported for both
reading and writing for the media types of "image/*".
See the sparklines sample:
http://download.java.net/maven/2/com/sun/jersey/samples/sparklines/1.1.4.1/sparklines-1.1.4.1-project.zip
See below for the source of a resource method from the sparklines
sample that returns a BufferedImage.
Paul.
@Path("discrete")
@GET
public Response discrete(
@DefaultValue("2") @QueryParam("width") int width,
@DefaultValue("50") @QueryParam("upper") int upper,
@DefaultValue("red") @QueryParam("upper-color")
ColorParam upperColor,
@DefaultValue("gray") @QueryParam("lower-color")
ColorParam lowerColor
) {
BufferedImage image = new BufferedImage(
data.size() * width - 1, imageHeight,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setBackground(Color.WHITE);
g.clearRect(0, 0, image.getWidth(), image.getHeight());
int gap = 4;
float d = (limits.width() + 1) / (float)(imageHeight - gap);
for (int i = 0, x = 0, y = 0; i < data.size(); i++, x +=
width) {
int v = data.get(i);
g.setColor((v >= upper) ? upperColor : lowerColor);
y = imageHeight - (int)((v - limits.lower()) / d);
g.drawRect(x, y - gap, width - 2, gap);
}
return Response.ok(image).tag(tag).build();
}
On Dec 15, 2009, at 11:51 PM, cgswtsu78 wrote:
>
> Hello,
>
> I'm new to Jersey and restful web services in general. Is there a
> way to
> stream a BufferedImage to the browser using an HTTP GET request?
> Basically,
> I type in a URL http://localhost:8080/jersey/getImage and the browser
> displays the BufferedImage returned from the method mapped to the
> "getImage"
> path. A simple example would be quite helpful. Appreciate the help!
> --
> View this message in context: http://n2.nabble.com/Streaming-a-BufferedImage-tp4172696p4172696.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>