I'm trying to write a simple slide show program. I would like it to display pictures that are different sizes, then scale then , so there width fills the screen. I can change the size of the image view, and in the debugger it was getting set to the new width, but it does not scale the bitmap, is thier a way to do this?????
Code:
ImageView picImage = (ImageView) findViewById(0);// R.id.viewpic);
try {
String FileName = "canon20.png";
AssetManager assetManager = getAssets();
InputStream inputStream;
inputStream = assetManager.open(FileName);
Bitmap icon = BitmapFactory.decodeStream(inputStream);
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
int bw = icon.getWidth();
float t = (float) screenWidth / (float) bw;
picImage.setImageBitmap(icon);
picImage.getLayoutParams().width = screenWidth;
picImage.getLayoutParams().height = (int) (icon.getHeight() * t);
} catch (IOException e) {
}