On 10 December 2010 15:45, Brandon Thomas <csu...@at...> wrote:
> Hey everyone,
>
> I'm new here and am starting to really work with java and gtk.
>
> Anyways I'm trying to get my application to quasi do the following
>
> retrieve an image from the web
> pack it into the container
>
> I'm having a hell of a hard time though. The one thing I haven't done is
> for the filename, just used the URL of the image. Will that work?
>
> Any reference or resources to this would be greatly appreciated!
>
Hi Brandon
Assuming you're using PixBuf, this works:
import java.net.URL;
import javax.imageio.ImageIO;
import org.gnome.gdk.Pixbuf;
URL u = new URL(myUrl);
BufferedImage i = ImageIO.read(u);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(i, "PNG", bos);
Pixbuf pb = new Pixbuf(bos.toByteArray());
I use it as a simple way to pull images from Web Mapping Services into PDF maps.
Best
Will Temperley
|