由网友(世界這麽脏゛裝純給誰)分享简介:我有一个位图外面,我切了multipi点多边形。我很好奇的正确处理是用于取任意形状内的像素,并将它们拷贝到一个新的位图,其中的像素的其余部分是透明的。其目的是使用户能够跟踪形状,然后除去该多边形外一切I have a bitmap out of which I'm cutting out a multipi poin...
我有一个位图外面,我切了multipi点多边形。我很好奇的正确处理是用于取任意形状内的像素,并将它们拷贝到一个新的位图,其中的像素的其余部分是透明的。其目的是使用户能够跟踪形状,然后除去该多边形外一切
I have a bitmap out of which I'm cutting out a multipi point polygon. I'm curious what the correct process is for taking the pixels within the arbitrary shape and copying them onto a new bitmap where the rest of the pixels are transparent. The objective is to allow the user to trace the shape and then remove everything outside the polygon.
我有多边形组成部分制定(如点的数组),但现在很为难,如何只选择像素转移到一个新的位图。
I have the polygon part worked out (as a an array of points), but now am stumped as to how to transfer just the selected pixels to a new Bitmap.
TIA
推荐答案
不知道如何你的code ++工程,但这里是如何做到这一点的想法:
Not sure how your code works, but here's an idea on how to do it:
计算所选区域(找分钟X,最小Y,最大x和最大Y点从点)的边框。 裁剪图像使用任何的边框的位图
或画布
- 方法。
创建一个 路径
从你的观点,全部搬迁到新的位图(X- =其minX,Y = MINY)
;
设置你的路径FillType一个是反向(补外)。
在新的裁剪画布,画用油漆与Xfermode为PorterDuff.CLEAR,这将删除所有的颜色。
Calculate the bounding rectangle of the selected area (find min x, min y, max x and max y from your points).
Crop your image to the bounding rectangle using any of the Bitmap
or Canvas
-methods.
Create a Path
from your points, all moved into your new bitmap (x-=minX, y-=minY)
;
Set your Paths FillType
to one that is inverse (fill the outside).
On your new cropped canvas, draw the Path using a paint with the Xfermode as PorterDuff.CLEAR
, which removes all color.相关推荐
最新文章