Hello I have a simple problem..
I need put two different bitmaps into one imageview. but One bitmaps must be on ImageView.ScaleType.FIT_XY
and second on ImageView.ScaleType.FIT_CENTER
I found some methods from internet but all put with same scaletype.
Thanks for advice.
i need in imageview have this.. (image no pageview..)
////////// for explain why I need.
@Override public Object instantiateItem(ViewGroup view, int position) {
ImageView img= new ImageView(view.getContext());
ImageLoader.getInstance().displayImage(listKone.get(pozicia).getCestaObrazok(), img);
//
ImageLoader.getInstance().displayImage(listKone.get(pozicia).getCestaObrazok(), img2);
BitmapDrawable drawable = (BitmapDrawable) img2.getDrawable();
Bitmap bitmap = null;
try {
bitmap = drawable.getBitmap();
} catch (NullPointerException e){
}
while ((drawable==null)||(bitmap==null)) {
ImageLoader.getInstance().displayImage(listKone.get(pozicia).getCestaObrazok(), img2); // Default options will be used
drawable = (BitmapDrawable) img2.getDrawable();
bitmap = drawable.getBitmap();
}
Bitmap blurred = blurRenderScript(act, bitmap, 25);
view.addView(img, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
return img;
}
return img; I need Bitmap blurred and Bitmap Bitmap in one Imageview. But bitmap Blured FIT_XY and bitmap bitmap center. I need get view like in image ↑
I find method which I edited..
public static Bitmap CombineImages(Bitmap background, Bitmap foreground) {
int width = (int) act.getResources().getDimension(R.dimen.imageH);
int height = (int) act.getResources().getDimension(R.dimen.imageH);
Bitmap cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
background = Bitmap.createScaledBitmap(background, width, height, true);
comboImage.drawBitmap(background, 0, 0, null);
float Fwidth = foreground.getWidth();
float Fheight = foreground.getHeight();
if (Fheight>Fheight){
Fwidth=(height/Fheight) * Fwidth;
Fheight=height;
foreground = Bitmap.createScaledBitmap(foreground,(int) Fwidth,(int) Fheight, true);
}
if (Fheight<=Fheight){
Fheight=(width/Fwidth)*Fheight;
Fwidth=width;
foreground = Bitmap.createScaledBitmap(foreground,(int) Fwidth,(int) Fheight, true);
}
float top = (height-Fheight)/2;
float left = (width-Fwidth)/2;
comboImage.drawBitmap(foreground, left, top, null);
return cs;
}
Have you better solution write. Ad iterim use this solution. But If in future will have more images will be Unneffective.