在另一个Android覆盖位图 [英] Overlay Bitmap over another Android

查看:138
本文介绍了在另一个Android覆盖位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,大家好我想要获得的图像(从资源帧)比原先的位图覆盖它。到目前为止,我不能让我的位图进入帧帧总是空的。原始位图现示出在框架内部。
这里是我的code,我使用做到这一点。


 画布油画=新的Canvas();
    位图的边界= NULL;
    位图scaledBorder = NULL;
    边界= BitmapFactory.de codeResource(getResources(),R.drawable.frame1);
    INT宽度= bmp.getWidth();
    INT高度= bmp.getHeight();
    scaledBorder = Bitmap.createScaledBitmap(边框,宽度,高度,FALSE);
    canvas.drawBitmap(scaledBorder,0,0,新的油漆());
    view.setImageBitmap(scaledBorder);


BMP作为我从画廊或照相机原始位。我找不到离开把它们放在一起。只有框便会出现,但不是BMP。
先谢谢了。


解决方案

感谢的人我理解了它以自身。使用这种

 无效HM1(){
    位图的边界= BitmapFactory.de codeResource(getResources(),R.drawable.vignette2);
    INT宽度= bmp.getWidth();
    INT高度= bmp.getHeight();
    变化= Bitmap.createScaledBitmap(其他城市,宽度,高度,FALSE);
    帆布帆布=新的Canvas(变化);
    位图scaledBorder = Bitmap.createScaledBitmap(边框,宽度,高度,FALSE);
    canvas.drawBitmap(scaledBorder,0,0,NULL);
    //canvas.drawBitmap(k,0,0,NULL);
    view.setImageBitmap(变化);
    }

通过任意点击按钮添加这个方法,菜单等你可以在对方绘制两个位图。结果
P.S:位图的变化是原来的,因为我不希望用户在使用原来的方法,但是,从改变一个覆盖另一个位图。
希望答案可以帮助别人。谢谢

hello guys i'm trying to get an image(Frame from resources) to overlay it over the original bitmap. so far i couldn't make my Bitmap goes into the frame as the frame always empty. the original bitmap is now showing inside the frame. here is my code that i'm using to accomplish this.

  Canvas canvas = new Canvas();
    Bitmap border = null;
    Bitmap scaledBorder = null;
    border = BitmapFactory.decodeResource(getResources(), R.drawable.frame1);
    int width = bmp.getWidth();
    int height = bmp.getHeight();
    scaledBorder = Bitmap.createScaledBitmap(border,width,height, false);
    canvas.drawBitmap(scaledBorder, 0, 0, new Paint());
    view.setImageBitmap(scaledBorder);

bmp as my original Bitmap from Gallery or Camera. i can't find away to put them together. only the frame will appear but not the bmp. thanks in advance.

解决方案

thanks man i figured it out by own. using this

void hm1(){
    Bitmap border = BitmapFactory.decodeResource(getResources(), R.drawable.vignette2);
    int width = bmp.getWidth();
    int height = bmp.getHeight();
    change = Bitmap.createScaledBitmap(change, width, height, false);
    Canvas canvas = new Canvas(change);
    Bitmap scaledBorder = Bitmap.createScaledBitmap(border,width,height, false);
    canvas.drawBitmap(scaledBorder, 0, 0,null);
    //canvas.drawBitmap(k, 0, 0, null);
    view.setImageBitmap(change);
    }

by adding this method on any click button , menu etc you can draw two bitmaps over each other.
P.S : Bitmap change is another bitmap from the original one as i don't want the user to apply the Overlay on the original method but on the changed one. hope the answer helps someone. thanks

这篇关于在另一个Android覆盖位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆