In computer graphics, alpha compositing(technique invented by Porter and Duff) is the process of combining an image with a background to create the appearance of partial or full transparency. It is often useful to render image elements in separate passes, and then combine the resulting multiple 2D images into a single, final image in a process called compositing.
Questions tagged [porter-duff]
118 questions
157
votes
2 answers
What does PorterDuff.Mode mean in android graphics.What does it do?
I would like to know what PorterDuff.Mode means in android graphics.
I know that it is a transfer mode.
I also know, that it has attributes such as DST_IN, Multiply etc.

rogerstone
- 7,541
- 11
- 53
- 62
83
votes
4 answers
Masking(crop) image in frame
Having a rich UI application in which I want to show image with complex shape like this
Now what I want is to crop my image as per Mask image, Actually image is coming dynamic and can be imported from Camera or Gallery(square or rectangle shape)…

Mohammed Azharuddin Shaikh
- 41,633
- 14
- 96
- 115
35
votes
7 answers
Drawing on Canvas - PorterDuff.Mode.CLEAR draws black! Why?
I'm trying to create a custom View which works simple: there is a Bitmap which is revealed by arc path - from 0deg to 360deg. Degrees are changing with some FPS.
So I made a custom View with overridden onDraw() method:
@Override
protected void…

cadavre
- 1,334
- 1
- 18
- 34
35
votes
1 answer
Punch a hole in a rectangle overlay with HW acceleration enabled on View
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…

Joseph Earl
- 23,351
- 11
- 76
- 89
29
votes
5 answers
i want to add a color filter to the imageview
I'd like to add a ColorFilter to ImageView.
Currently I'm using:
ImageView iv = (ImageView)findViewById(resIdOfImageToFilter);
iv.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
I've checked Multiple Modes in PotterDuff such as SRC_IN, SRC…

Shashank Degloorkar
- 3,151
- 4
- 32
- 50
20
votes
4 answers
How to create a 'transparent circle inside rectangle' shape in XML in Android?
I'm trying to create the following design in my app.
Design Mockup
Its an overlay on top of the main UI. Trying to create this using a layout on top of the main UI with its background as a translucent shape created in XML. However, even after…

vepzfe
- 4,217
- 5
- 26
- 46
19
votes
0 answers
DrawableCompat.setTint(drawable, color) vs Drawable.setColorFilter(color, mode)
What's the difference between those two implementations?
DrawableCompat.setTintMode(wrappedDrawable, Mode.SRC_ATOP);
DrawableCompat.setTint(wrappedDrawable, color);
and
drawable.setColorFilter(color, Mode.SRC_ATOP);

jeff
- 6,299
- 1
- 15
- 18
14
votes
3 answers
Android ColorFilter - Porter-Duff Modes
I'm trying to solve a problem with android ColorFilters. Documentation is very poor, so the main method is trying different variants.
The problem:
There is a Bitmap. Some pixels have alpha=255, others have alpha=0. I'm trying to draw a circle with a…

Alexander Taran
- 976
- 3
- 12
- 25
13
votes
1 answer
Porter-Duff: different behavior for different shapes?
I have the following layout:

injecteer
- 20,038
- 4
- 45
- 89
13
votes
3 answers
PorterDuff color effects in android for views under a given view
Is it possible in android to set up a view in a way that it applies some color filter to everything below that's visible in its bounds? Like in this example:
Just a simple rectangular view that inverts colors of everything below it. Of course when…

Łukasz Sromek
- 3,637
- 3
- 30
- 43
12
votes
4 answers
Blending two images together with multiply and % opacity
I'm trying to blend two images together with Android, using a Multiply-like blending mode.
// Prepare -------------------------------
// Create source images
Bitmap img1 = ...
Bitmap img2 = ...
// Create result image
Bitmap result = ...
Canvas…

zeh
- 10,130
- 3
- 38
- 56
11
votes
2 answers
Android Gauge Animation Question
Okay so i've been trying to do this for a couple of days and i am getting no where. So i have the following two images:
The First is a RPM Gauge
The Second image is a full white graphic representing rpm gauge being full:
I want to do the…

Mark Manickaraj
- 1,661
- 5
- 28
- 44
11
votes
0 answers
Android custom XferMode / PorterDuff.Mode
There are some predefined blending modes described here: https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html
Is there a possibility to use some other custom modes? (for drawing various stuff on Canvas)
For example, I really…

Display Name
- 8,022
- 3
- 31
- 66
9
votes
0 answers
Android PorterDuff.Mode.DST_IN combined with Bitmap.Config.ALPHA_8
I was playing around with Bitmaps masking and occasionally found an interesting issue when trying to draw ALPHA_8 bitmap mask with PorterDuff.Mode.DST_IN Paint. It just doesn't work, at least on Android 6.x and 5.x.
Here is my sample drawable…

Arkady Gamza
- 195
- 6
9
votes
5 answers
How do I make a puzzle app in droid without running out of memory?
I notice that other puzzle apps from the google play store can go up to as many as 400 separate movable puzzle pieces
I have been attempting to learn how to at least take an image that will represent my puzzle,
Crop certain sections and mask the…

user1091368
- 359
- 1
- 4
- 17