download images from internet [message #96199] |
Sun, 21 August 2005 18:29  |
Eclipse User |
|
|
|
Originally posted by: vicenrico.gmail.com
i´m doing a program that tries to download an image from an URL, but i
don´t know how do it...
does somebody knows how i can reach that?????????
i think that can be with Imagereader, or getimage or new Imageicon?????
I hear some about awt images controls over SWT....but i don´t know.
Thanks!!
|
|
|
|
Re: download images from internet [message #96713 is a reply to message #96244] |
Mon, 22 August 2005 18:33  |
Eclipse User |
|
|
|
Originally posted by: vicenrico.gmail.com
Jeroen escribió:
> In what way is your question related to eclipse?
>
> http://www.google.be/search?q=java+load+image+URL
>
>
Well, yesterday i found it!!!
Anyway, thanks for reply... I wanted to know how load image from an Url
without using AWT....only with SWT...
i was playing with IMAGEIO, but i discovered Imagedata and company...
if useful, i post the snippet, very little snippet...
------------------------------------------------------------ -------------------------------
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 filename to obtain name of the image an
extension...for saving the image 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]);
|
|
|
Powered by
FUDForum. Page generated in 0.08809 seconds