我需要为从网络上检索的图形实现缩放功能。这些图来自php web-server,以便如何实现这些图的缩放功能。任何人都可以帮我解决这个问题。这是我从网上重新查找图表的java类代码。
localPalladium1YButton.setOnClickListener( new View.OnClickListener() {
public void onClick(View view)
{
localPalladium1DButton.setBackgroundResource(R.drawable.onedicon);
localPalladium5DButton.setBackgroundResource(R.drawable.fived);
localPalladium1MButton.setBackgroundResource(R.drawable.whitem);
localPalladium1YButton.setBackgroundResource(R.drawable.yover);
android.view.View.OnClickListener getImgListener = null;
localPalladium1YButton.setOnClickListener(getImgListener);
Bitmap palladiumBitmap3=fetchImage( PalladiumImageUrl4.trim() );
localPalladiumImageView.setImageBitmap( palladiumBitmap3 );
mSoundManager.playSound(1);
}
});
..................................
..................................
..................................
Bitmap bmImg;
void downloadFile(String fileUrl){
URL myFileUrl =null;
try {
myFileUrl= new URL(fileUrl);
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
String url1 = "my url";
URL url = new URL(url1);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
BitmapFactory.Options bf = new BitmapFactory.Options();
Bitmap bm = BitmapFactory.decodeStream(bis);
ImageView localGoldImageView = null;
localGoldImageView.setImageBitmap(bm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Bitmap fetchImage( String urlstr )
{
try
{
URL url;
url = new URL( urlstr );
HttpURLConnection c = ( HttpURLConnection ) url.openConnection();
c.setDoInput( true );
c.connect();
InputStream is = c.getInputStream();
Bitmap img;
img = BitmapFactory.decodeStream( is );
return img;
}
catch ( MalformedURLException e )
{
Log.d( "RemoteImageHandler", "fetchImage passed invalid URL: " + urlstr );
e.printStackTrace();
}
catch ( IOException e )
{
Log.d( "RemoteImageHandler", "fetchImage IO exception: " + e );
e.printStackTrace();
}
return null;
}
谢谢,
穆拉利。