如何定制帧添加到图像编程 [英] How to add custom frames to images programmatically

查看:183
本文介绍了如何定制帧添加到图像编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个应用程序,我需要的帧添加到images.i没有任何想法改编this.i了其中帧被加入到images.could任何一个环节帮助我。

I want to create an app where i need to add frames to the images.i don't have any idea regrading this.i got one link where the frames are added to the images.could anybody help me.

下面是链接

@Thanks提前!!

@Thanks in Advance!!

推荐答案

编辑:图库 OnItemClickListener

gallery.setOnItemClickListener(new OnItemClickListener() {
        Bitmap frame = null, out = null;

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
           Bitmap urImage = BitmapFactory.decodeResource(getResources(),
                    R.drawable.urBackgroundImageID);//edit
            frame = BitmapFactory.decodeResource(getResources(),
                    frames[arg2]);
            out = combineImages(frame, urImage);
            imageView.setImageBitmap(out); //add "out" for ur ImageView
        }
    });

帧[] 是可绘制的阵列,即不同的帧

frames[] is array of drawables ie different frames

下面的方法将动态结合两个图像

The following method will combine two images dynamically

public Bitmap combineImages(Bitmap frame, Bitmap image) {

    Bitmap cs = null;
    Bitmap rs = null;

    rs = Bitmap.createScaledBitmap(frame, image.getWidth(),
            image.getHeight(), true);

    cs = Bitmap.createBitmap(rs.getWidth(), rs.getHeight(),
            Bitmap.Config.RGB_565);

    Canvas comboImage = new Canvas(cs);

    comboImage.drawBitmap(image, 0, 0, null);
    comboImage.drawBitmap(rs, 0, 0, null);

    if (rs != null) {
        rs.recycle();
        rs = null;
    }
    Runtime.getRuntime().gc();

    return cs;
}

您可以尝试在不同的整数值

You can try different integer values in

comboImage.drawBitmap(image, 0, 0, null);
comboImage.drawBitmap(rs, 0, 0, null);

在这里我已经把 0 来获得所需要的图像帧位置。

where I have put 0 to get needed frame position on the image.

这篇关于如何定制帧添加到图像编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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