# Android – Create a Vignette effect

Essay Writing 1 Let’s say you want to want to dynamically apply a “vignette” on an ImageView. source url Something like this:

ghost writer bachelor thesis These are basically 4 steps we need in order to accomplish the task:

viagra in vietnam pay to have essays written
1. Create a Paint using the PorterDuff.Mode.DST_OUT as Xfermode
3. Alter the gradient matrix using the setLocalMatrix method.
4. Use canvas.saveLayer when drawing

### 1. Paint using PorterDuff.Mode.DST_OUT

http://envsci.uprrp.edu/?purchase-college-admissions-essay purchase college admissions essay This is needed in order to draw an “hole” in our back background.

dissertation help love
 paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));

http://www.sephiroth.it/?university-phd-by-dissertation-only university phd by dissertation only

### 3. Alter the gradient matrix

http://www.urbanhhealth.com/college-research-paper-writer/ college research paper writer The again, in order to create a real vignette effect we need to draw a custom “oval”, otherwise the result of draw something using the radialgradient shader will result in a simple circle. Instead, if we alter its matrix we can modify its aspect ratio, giving it the oval shape:

 Matrix matrix = new Matrix(); source link matrix.postTranslate(rect.centerX(), rect.centerY()); matrix.postScale(rect.width() / 2, rect.height() / 2, rect.centerX(), rect.centerY()); shader.setLocalMatrix(matrix);

### 4. Draw on a canvas

http://www.stemcellslab.net/patent-bar-admission-resume/ patent bar admission resume Now we need to draw our objects on a real canvas. We need to save the current layer using Canvas.saveLayer because otherwise everything we previously drawn will be erased by our paint. But because we’re using saveLayer, we actually are drawing on an offscreen bitmap.

http://salon-cvetov.kz/best-website-for-essay-writing/
 12345678 // save current status // 'pBitmapRect' is the current Bitmap rectangle canvas.saveLayer(pBitmapRect, mPaint, Canvas.ALL_SAVE_FLAG); // draw the black background canvas.drawRect(pBitmapRect, mBlackPaint); // draw the vignette on the black background using our radial gradient canvas.drawOval(tempRect2, mPaintShader); canvas.restore();

## Source Code

order essay for one page You can download the complete source code here:
https://github.com/sephiroth74/vignette_demo

http://teamlasolas.com/best-research-papers/