集范围内变焦图像 [英] zoom image within set bounds

查看:167
本文介绍了集范围内变焦图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序在那里我有一个表面观。在这个表面观我同时显示多达两个位图是从短片剪辑。我有这个工作正常,但是我允许用户缩放和平移图像/短片。我想平分屏幕,以便在垂直方向上我将有一个夹取屏幕的上半部分,而另一个夹取的下半部分。由于这是一款surfaceview存在的这些观点没有实际分离。

I have an app where I have a surface view. On this surface view I display up to two bitmaps at a time that are clips from a short movie. I have this working fine, however I allow the user to zoom and pan the images/clips. I would like to divide the screen equally so in a vertical orientation I would have one clip taking the top half of the screen and the other clip taking the bottom half. Since this is one surfaceview there is no actual separation of these views.

目前第二位图我画,如果它左路下底传中,屏幕房地产那么它覆盖在其他位虚边界。我想只砍掉跨越边界的图像部分,没有人知道我怎么能执行本我的画布上绘制时?

Currently the second bitmap I draw if it crosses the imaginary boundary for screen real estate then it is overlayed on the other bitmap. I would like to just chop off the parts of the image that cross the boundary, does anyone know how I can enforce this when drawing on my canvas?

推荐答案

我想通了这一点,我会在这里发布答案的情况下,任何人都遇到类似的东西。我做的是类似于下面的东西。我创建新画布对象一起工作,并为那些画布对象可写的位图。然后我可以在个人画布对象执行任何绘图和转换,然后只画那些我我SurfaceView的主画布。

I figured this out, i'll post the answer here in case anyone else comes across something similar. What I am doing is something similar to the following. I create new canvas objects to work with and a writable bitmap for those canvas objects. I can then perform any drawing and transformations on the individual canvas objects, and then just draw those to my main canvas of my SurfaceView.

if(workingBitmap==null){
        workingBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight()/2, Bitmap.Config.ARGB_4444);
        c.setBitmap(workingBitmap);
        workingBitmap2 = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight()/2, Bitmap.Config.ARGB_4444);
        c2.setBitmap(workingBitmap2);
    }

    super.onDraw(canvas);
    canvas.drawColor(Color.BLACK);
    c.drawBitmap(bitmap, 0,0,null);
    c2.drawBitmap(bitmap2, 0,-100,null);
    canvas.drawBitmap(workingBitmap, 0,0,null);
    canvas.drawBitmap(workingBitmap2, 0,canvas.getHeight()/2,null);

这篇关于集范围内变焦图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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