[android-developers] Re: Image not correctly viewed

2008-04-04 Thread Andrea Bernardi
Thanks for your answers, but the problem persists.
The code function but the given image "
http://vdt.meteo.alice.it/meteo/imgs/icone/small/previsioni/notte/sereno.png";
is viewed bad, not perfectly as in the browser, the pixel are more big. The
image given from xingye
"http://www.yexing.org/image.axd?picture=browse.png"
is viewed perfectly with my code.
Have you other suggestion?

Andrea

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Image not correctly viewed

2008-04-04 Thread Charlie Collins

I use a snippet that looks almost identical to yours and it seems to
work fine.  The images I pull are from a Yahoo API, and they vary, but
they all seem to work.  When you say "this don't function" what do you
mean, is there an error in the log, a stacktrace?

This is the snippet I use (which again looks pretty much like what you
have, but works for me):

  try {
URL url = new
URL(report.getCondition().getImageLink());
URLConnection conn = url.openConnection();
conn.connect();
BufferedInputStream bis = new
BufferedInputStream(conn.getInputStream());
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
conditionImage.setImageBitmap(bm);
} catch (IOException e) {
Log.e(Constants.LOGTAG, " " + CLASSTAG, e);
}

conditionImage is just an ImageView.


On Apr 4, 9:55 am, "Andrea Bernardi" <[EMAIL PROTECTED]> wrote:
> Hello at all, i'm developing on Android since the last month and I've
> encountered this problem in these days.
>
> If I download an image from Internet with this code isn't correctly viewed:
>
> package org.ti.weather;
>
> import java.io.BufferedInputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.net.URLConnection;
>
> import android.app.Activity;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.os.Bundle;
> import android.widget.ImageView;
>
> public class Weather extends Activity {
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle icicle) {
>         super.onCreate(icicle);
>         setContentView(R.layout.main);
>         ImageView img = (ImageView) findViewById(R.id.weatherimg);
>
>         // this don't function
>         try {
>             URL aURL = new 
> URL("http://vdt.meteo.alice.it/meteo/imgs/icone/small/previsioni/notte/ser...
> ");
>             URLConnection conn = aURL.openConnection();
>             conn.connect();
>             InputStream is = conn.getInputStream();
>             BufferedInputStream bis = new BufferedInputStream(is);
>             Bitmap bm = BitmapFactory.decodeStream(bis);
>             bis.close();
>             is.close();
>             img.setImageBitmap(bm);
>         } catch (IOException e) {
>             // Reset to 'Dunno' on any error
>             showAlert("Error", 0, "Can't download image", "Ok", false);
>         }
>
>     }
>
> }
>
> where the main.xml is the following:
>
> 
> http://schemas.android.com/apk/res/android";
>     android:orientation="vertical"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent"
>     >
>      android:id="@+id/weatherimg"
>     android:layout_width="wrap_content"
>     android:layout_height="wrap_content"
>     />
> 
>
> Instead, if I insert the same image in the directory res/drawable of the
> project and I use the following code the image is correctly viewed:
>
>     public void onCreate(Bundle icicle) {
>         super.onCreate(icicle);
>         setContentView(R.layout.main);
>         ImageView img = (ImageView) findViewById(R.id.weatherimg);
>
>         //this function
>         img.setImageDrawable(getResources().getDrawable(R.drawable.sereno));
>     }
>
> Have you some suggestion?
>
> Thanks
> Andrea
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Image not correctly viewed

2008-04-04 Thread xingye

//  ImageView iv =
(ImageView)convertView.findViewById(R.id.image);
//  iv.setImageResource(R.drawable.badge);
//  Uri uri = Uri.parse("http://www.yexing.org/image.axd?
picture=browse.png");

//  iv.setImageURI(uri);
//  Drawable drawable =
Drawable.createFromPath(uri.getPath());
//  try {
//  URL url = new 
URL("http://www.yexing.org/image.axd?
picture=browse.png");
//  InputStream is = url.openStream();
//  Drawable drawable = 
Drawable.createFromStream(is,
"none");
//  iv.setImageDrawable(drawable);
//  } catch(Exception e) {
//  Log.e(LOG_TAG, "load image error! \n" + 
e.toString());
//  }


On 4月4日, 下午9时55分, "Andrea Bernardi" <[EMAIL PROTECTED]> wrote:
> Hello at all, i'm developing on Android since the last month and I've
> encountered this problem in these days.
>
> If I download an image from Internet with this code isn't correctly viewed:
>
> package org.ti.weather;
>
> import java.io.BufferedInputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.net.URLConnection;
>
> import android.app.Activity;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.os.Bundle;
> import android.widget.ImageView;
>
> public class Weather extends Activity {
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle icicle) {
> super.onCreate(icicle);
> setContentView(R.layout.main);
> ImageView img = (ImageView) findViewById(R.id.weatherimg);
>
> // this don't function
> try {
> URL aURL = new 
> URL("http://vdt.meteo.alice.it/meteo/imgs/icone/small/previsioni/notte/ser...
> ");
> URLConnection conn = aURL.openConnection();
> conn.connect();
> InputStream is = conn.getInputStream();
> BufferedInputStream bis = new BufferedInputStream(is);
> Bitmap bm = BitmapFactory.decodeStream(bis);
> bis.close();
> is.close();
> img.setImageBitmap(bm);
> } catch (IOException e) {
> // Reset to 'Dunno' on any error
> showAlert("Error", 0, "Can't download image", "Ok", false);
> }
>
> }
>
> }
>
> where the main.xml is the following:
>
> 
> http://schemas.android.com/apk/res/android";
> android:orientation="vertical"
> android:layout_width="fill_parent"
> android:layout_height="fill_parent"
> >
>  android:id="@+id/weatherimg"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> />
> 
>
> Instead, if I insert the same image in the directory res/drawable of the
> project and I use the following code the image is correctly viewed:
>
> public void onCreate(Bundle icicle) {
> super.onCreate(icicle);
> setContentView(R.layout.main);
> ImageView img = (ImageView) findViewById(R.id.weatherimg);
>
> //this function
> img.setImageDrawable(getResources().getDrawable(R.drawable.sereno));
> }
>
> Have you some suggestion?
>
> Thanks
> Andrea
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---