Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Image from an URL
Image from an URL [message #460066] Sun, 21 August 2005 21:47 Go to next message
Vicente is currently offline VicenteFriend
Messages: 7
Registered: July 2009
Junior Member
Hello All.

Does anybody knows how can i download an image from internet with
SWT(Image)?????

I´m doing a program that connects with a movie's page, and i want to
download the cover for the movie that user selects...
I´m searching in Google, but i don´t find...
I´m creating Url objetc, inputstream, but i don´t know to do that!!
If someone gives me a url with a snippet, or post here, will be apreciated.

Thansk, and excuse for my bad english...
Re: Image from an URL [message #460177 is a reply to message #460066] Mon, 22 August 2005 15:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

ImageDescriptor.createFromURL(url).createImage()

--
Thanks,
Rich Kulp
Re: Image from an URL [message #460179 is a reply to message #460066] Mon, 22 August 2005 15:06 Go to previous messageGo to next message
Jeff Myers is currently offline Jeff MyersFriend
Messages: 396
Registered: July 2009
Senior Member
Here's a simplified snippet:

try {
URL url = new URL("http://www.google.com/intl/en/images/logo.gif");
InputStream is = url.openStream();
Image image = new Image(Display.getCurrent(), is);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
is.close();
}

Hope this helps.
- Jeff


Vicente wrote:
> Hello All.
>
> Does anybody knows how can i download an image from internet with
> SWT(Image)?????
>
> I´m doing a program that connects with a movie's page, and i want to
> download the cover for the movie that user selects...
> I´m searching in Google, but i don´t find...
> I´m creating Url objetc, inputstream, but i don´t know to do that!!
> If someone gives me a url with a snippet, or post here, will be apreciated.
>
> Thansk, and excuse for my bad english...
Re: Image from an URL [message #460221 is a reply to message #460179] Mon, 22 August 2005 22:40 Go to previous message
Vicente is currently offline VicenteFriend
Messages: 7
Registered: July 2009
Junior Member
Jeff Myers escribió:
> Here's a simplified snippet:
>
> try {
> URL url = new URL("http://www.google.com/intl/en/images/logo.gif");
> InputStream is = url.openStream();
> Image image = new Image(Display.getCurrent(), is);
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> finally
> {
> is.close();
> }
>
> Hope this helps.
> - Jeff

Thanks... i will probe this little snippet..Yesterday i was probing a
snippet that i don´t know how, but functions...
------------------------------------------------------------ -----------
private void retrieveImage(String direccionImagen) {

ImageData[] imageDataArray,imageDataArray1;
URL url = null;
try {
url = new URL(direccionImagen);
} catch (MalformedURLException e) {

e.printStackTrace();
}
InputStream stream = null;
String urlfile=url.getFile();

NombreFichero nom=new NombreFichero(urlfile,'/');
// here i parse urlfile to obtain name and extension to save
// after...

try {
stream = url.openStream();
} catch (IOException e) {

e.printStackTrace();
}
ImageLoader loader = new ImageLoader();

imageDataArray = loader.load(stream);
String
pathCompleto=ProgramData.programImagesDir+System.getProperty ( "file.separator")+nom.nombreCompleto();
loader.save(pathCompleto,SWT.IMAGE_JPEG);


try {
stream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

int imageDataIndex = 0;
Image image = new Image(GUI.display, imageDataArray[imageDataIndex]);


------------------------------------------------------------ -------------------------------
Previous Topic:Problem with Image class??
Next Topic:bug in table / table viewer
Goto Forum:
  


Current Time: Wed Nov 26 09:05:03 GMT 2014

Powered by FUDForum. Page generated in 0.05573 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software