porter-duff

Expected behavior when using CIAdditionCompositing to add pure black?

爷,独闯天下 提交于 2021-01-27 06:22:48
问题 I am attempting to understand how CIAdditionCompositing works. As part of my testing, I have created a square mid-gray image: and a square black image: When I combined these two square images using a CIAdditionCompositing patch, I expected to see a gray square whose color matched the original mid-gray square exactly (because all color components of the black image have value 0). However, the final result is actually brighter than the original gray image: I don't understand how this result is

PorterDuffXfermode DST_IN not working as expected

落花浮王杯 提交于 2020-03-17 12:02:49
问题 So I'm trying to speed up some drawing we're doing (drawing a portion of an arc with alpha transparency) and was attempting to cache the entire arc into a separate bitmap, and show it selectively with an alpha mask. From the research I've done (the Xfermodes API demo for Android, this example, and this tool), if I have for example the following two graphics: and draw using the following: Xfermode DST_IN = new PorterDuffXfermode(PorterDuff.Mode.DST_IN); Paint paint = new Paint(Paint.ANTI_ALIAS

Android Crop Bitmap Canvas

与世无争的帅哥 提交于 2020-01-06 03:08:35
问题 I want to create the crop bitmap functionality and have referred Android: Free Croping of Image but this sets the bitmap in another imageView.Now I know I can set the cropped bitmap in the canvas but I want to retain the original bitmap and want to do the cropping in onDraw() and not make a different bitmap and then set it in canvas.I have tried to implement the below code in onDraw but there is no cropping and bitmap remains as it is.Pleas help so that I can code this in onDraw() method of

Android Crop Bitmap Canvas

淺唱寂寞╮ 提交于 2020-01-06 03:07:20
问题 I want to create the crop bitmap functionality and have referred Android: Free Croping of Image but this sets the bitmap in another imageView.Now I know I can set the cropped bitmap in the canvas but I want to retain the original bitmap and want to do the cropping in onDraw() and not make a different bitmap and then set it in canvas.I have tried to implement the below code in onDraw but there is no cropping and bitmap remains as it is.Pleas help so that I can code this in onDraw() method of

PorterDuff masking leaves opaque black background

淺唱寂寞╮ 提交于 2020-01-01 19:20:55
问题 I'm trying to mask a FrameLayout with a mask defined as a nine patch. However, although it works fine on 5.0+ on older versions (such as 4.4.4), the patch leaves an opaque black background. Is there anything that can be done to avoid this other than drawing to an off screen bitmap before rendering to the screen or reverting to software layers? public class MaskedLayout extends FrameLayout { private final static PorterDuffXfermode DST_IN = new PorterDuffXfermode(PorterDuff.Mode.DST_IN);

Programmatically setting Button Background Drawable Color

隐身守侯 提交于 2019-12-25 06:59:04
问题 I have a drawable created beforehand which is a shape of rectangle but is fully transparent. Now I would like to assign this drawable to the Button in code but also set the Color of this drawable from transparent to some specific color like Orange etc. I have already tried setting the same using some other posts like - Drawable mDrawable = ContextCompat.getDrawable(this, R.drawable.square_transparent); mDrawable.setColorFilter( new PorterDuffColorFilter( Color.Orange, Mode.SRC_IN) ); but it

Punch a hole in a rectangle overlay with HW acceleration enabled on View

ぐ巨炮叔叔 提交于 2019-12-17 21:45:47
问题 I have a view which does some basic drawing. After this I want to draw a rectangle with a hole punched in so that only a region of the previous drawing is visible. And I'd like to do this with hardware acceleration enabled for my view for best performance. Currently I have two methods that work, but only works when disabled hardware acceleration and the other is too slow. Method 1: SW Acceleration (Slow) final int saveCount = canvas.save(); // Clip out a circle. circle.reset(); circle

Remove white background from masked image in android

 ̄綄美尐妖づ 提交于 2019-12-12 02:29:55
问题 I want to crop a bitmap in polygon shape drawn above that bitmap. I'm using masking of bitmap to do this. The operation succeeds well, unfortunately the resulted bitmap after masking has a white background in cropped area,as you can see in the image: And my mask that is created runtime by dragging rectangle around image and creating a polygon shape on above the image is as below : I want to remove this unwanted white background. Does any one has idea how could I do this. Any clue or help

How to draw on bitmap using another bitmap as mask?

僤鯓⒐⒋嵵緔 提交于 2019-12-09 17:41:34
问题 I want to draw on a bitmap using another bitmap as mask. The mask is a black bitmap with a transparent object in it. I want this transparent part to be filled with an arbitrary color and added to my original image. How can this be done? + + blue color = 回答1: I had to change the masks as described by @Christian. Then, the wanted result could easily be produced: canvas.drawRect(rect, paint); paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); canvas.drawBitmap(mask, 0.0f, 0.0f, paint); 回答2:

PorterDuff and Path

放肆的年华 提交于 2019-12-07 09:40:05
问题 In my project I have a bitmap filling the entire screen. On this bitmap i draw a path with android.graphics.Canvas.drawPath(Path path, Paint paint) the paint is set in order to stroke and fill the content of the path. What I would achieve is to erase the portion of the bitamp that intersect the path. I have managed to obtain the same behavior using on another bitmmap instead of the path, and using the porter duff rules. Is there any chance to do the same thing with the path? mPaintPath