如何实现在Android的照片拼贴 [英] How to implement photo collage on Android

查看:234
本文介绍了如何实现在Android的照片拼贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作Android上的照片拼贴项目。我想知道如何实现以下拼贴效果?

I am working on photo collage project on Android. I want to know how to implement the following collage effect?

因此​​,有两张照片将适用于每一个三角形。

So there are two photos will fit into each triangle.

或更复杂的形状是这样的:(这将HOD 5张)

or more complex shape like this: (this will hod 5 photos)

推荐答案

这并不容易。

一个解决办法是从删除您的图像,如下面的代码片段中不需要的像素此线程(关闭削减右上角):

One solution would be to remove the unwanted pixel of your image like the following snippet from this thread (cuts off the top right corner):

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageView iv = (ImageView) findViewById(R.id.your_image);
    int drawableId = R.drawable.your_drawable;
    cutOffTopRightCorner(iv, drawableId, skewWidth);
}

@SuppressLint("NewApi")
private void cutOffTopRightCorner(ImageView iv, int resId, int skewWidth) {
    Bitmap bm = BitmapFactory.decodeResource(getResources(), resId).copy(Config.ARGB_8888, true);
    bm.setHasAlpha(true);
    final int bmWidth = bm.getWidth();

    for (int i = bmWidth; i > bmWidth - skewWidth; --i) {
        for (int k = 0; k < i - (bmWidth - skewWidth); ++k) {
            bm.setPixel(i - 1, k, Color.TRANSPARENT);
        }
    }
    iv.setImageBitmap(bm);
} 

另一个解决方案是用FrameLayouts工作(differenz Z-指数),并与其他图像或可绘制叠加图像。

Another solution would be to work with FrameLayouts (differenz z-indices) and to overlay your images with other images or drawables.

您还可以看看到这个线程。

这篇关于如何实现在Android的照片拼贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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