porter-duff

Android Scratch card app

拜拜、爱过 提交于 2019-12-06 13:47:09
问题 I am doing a small project for college and wondering if someone can tell me how I would go about doing a scratch card app. This app should have one image overlaying another. The one on top should allow the user to remove the image depending on where they rub on the image and thus part of the image that was removed revealing the image underneath. Pretty much like a scratch card. Any help would be great! This is the code im using at the moment . public class workinggraphics extends Activity { /

Android color overlay - PorterDuff modes

梦想与她 提交于 2019-12-05 23:11:10
问题 I have a black & white ninepatch drawable as background of a view and I would like to apply a color on it, like a semi-transparent overlay that leaves the drawing visible but applies the desired color on it. I thought drawable.setColorFilter(color,mode) might do the trick, but I can't figure out what the different modes mean. Could anyone give me a hint? 回答1: I believe this question may help you: Understanding the Use of ColorMatrix and ColorMatrixColorFilter to Modify a Drawable's Hue That

Android Scratch card app

不想你离开。 提交于 2019-12-04 19:33:29
I am doing a small project for college and wondering if someone can tell me how I would go about doing a scratch card app. This app should have one image overlaying another. The one on top should allow the user to remove the image depending on where they rub on the image and thus part of the image that was removed revealing the image underneath. Pretty much like a scratch card. Any help would be great! This is the code im using at the moment . public class workinggraphics extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle

PorterDuff masking leaves opaque black background

↘锁芯ラ 提交于 2019-12-04 19:26:52
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); private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private NinePatchDrawable mMask; private

Implementing different PorterDuff modes in android

二次信任 提交于 2019-11-29 05:10:34
I am working on a picture editing tool in which I need to merge two images. Most of the image editing tools like gimp use PorterDuff modes for merging or blending images. I am also using the same approach in android. As android provides limited number of PorterDuff modes, I am not able to achieve the desired result. So, I am thinking of implementing PorterDuff modes(Overlapping, Hard-Light, Soft-Light, Color-burn, Color-dodge) which are not included in android. The problem is I don't know where to start. So, any reference or guidance in this regard will be highly appreciated. This is how you

Draw a transparent circle onto a filled android canvas

蓝咒 提交于 2019-11-29 02:36:34
I am trying to do something very simple (see above). I want all of the pixels of a canvas to be a solid color, except for the the pixels that fill a centered circle. I have read hundreds stack overflow post on this subject and have tried hundreds of things including setting the PorterDuff.Mode. Here is my current onDraw() of MyView extends View: protected void onDraw(Canvas canvas) { int w = canvas.getWidth(); int h = canvas.getHeight(); Paint framePaint = new Paint(); framePaint.setStyle(Paint.Style.FILL); framePaint.setColor(Color.BLUE); canvas.drawRect(0, 0, w, h, framePaint); Paint

i want to add a color filter to the imageview

廉价感情. 提交于 2019-11-29 01:58:25
问题 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 etc., but I'm not getting any difference in any of the modes... All mode turns the whole ImageView in perfect Red color. I need to blend RED color in the existing image so that image will look with a REDDISH tinge.... 回答1: The right way to do it was

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

十年热恋 提交于 2019-11-28 16:05:57
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.addCircle(cx, cy, radius, Path.Direction.CW); circle.close(); canvas.clipPath(circle, Region.Op.DIFFERENCE); /

Android Gauge Animation Question

心已入冬 提交于 2019-11-28 05:33:14
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 following: ask the user for an RPM input, if for example they enter 1.2 the gauge will fill up as follows: I have the user input working i need help with the animation. Here is what i have tried: I have tried using PorterDuff but it also clips the gauge in the background not just the white bar I've tried splitting the image into little bitmaps and store them

How to create a 'transparent circle inside rectangle' shape in XML in Android?

烈酒焚心 提交于 2019-11-27 19:54:58
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 reading multiple posts, I'm not able to figure it out. I tried the following approach, but it didn't work. Created a ring shape with 200dp stroke and set it as source for a imageview and then set the scaletype to centerCrop but the shape does not scale as a bitmap does. Shape XML : <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http:/