Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:30:11+00:00 2026-06-04T13:30:11+00:00

So this is what I have for a vignette style effect in Android (image

  • 0

So this is what I have for a vignette style effect in Android (image is a Bitmap):

public void vignette() {
    float radius = (float) (image.getWidth()/1.5);
    RadialGradient gradient = new RadialGradient(image.getWidth()/2, image.getHeight()/2, radius, Color.TRANSPARENT, Color.BLACK, Shader.TileMode.CLAMP);

    Canvas canvas = new Canvas(image);
    canvas.drawARGB(1, 0, 0, 0);

    final Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(Color.BLACK);
    paint.setShader(gradient);

    final Rect rect = new Rect(0, 0, image.getWidth(), image.getHeight());
    final RectF rectf = new RectF(rect);

    canvas.drawRect(rectf, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(image, rect, rect, paint);
}

This “works” but there are a couple of problems. First of all, this is not really a vignette, it’s just a gradient so you can see bits of the black going nearly all the way to the center rather than feathering out closer to the edges.

The RadialGradient used also only allows for setting the radius of a circle rather than an ellipse. An ellipse would be able to more effectively match the dimensions of a non-square image than a circle.

The quality of the gradient is also not superb.

I’m trying to replicate the vignetteImage method from ImageMagick (I’m referring specifically to the php version). I have this code in PHP that produces the style of image that I want:

$im = new IMagick('city.png');
$im->vignetteImage($width/1.5, 350, 20, 20);

I’ve tried building ImageMagick with the NDK but have been unsuccessful in properly linking the various image libraries (I’ve only successfully built with gif support but no png, jpeg or tiff).

I’ve also attached an image comparing the two methods shown above. The image on the left was generated with ImageMagick through php and the image on the right was generated using the method shown above for Android.

left: vignette from php/ImageMagick. right: vignette from Android using method shown above

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:30:12+00:00Added an answer on June 4, 2026 at 1:30 pm

    If you look carefully at the image on left, tf uses exponential increase in Alpha (transparency) vs. image on right which is very linear.

    Clearly Shader.TitleMode.CLAMP is a linear function. What you should do instead is use RadialGradient(float x, float y, float radius, int[] colors, float[] positions, Shader.TileMode tile) to define 10 or more points on the image with exponentially decreasing color values (black to transparent).

    Alternatively, you can refer gallery 3d source for ICS gallery http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/gallery3d/photoeditor/filters/VignetteFilter.java?av=h

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some queries that look like this: public List<AnObjectModel> GetObjectFromDB(TheParameters) { using MyDataContext
IF i have the following: MyString.ValueType = typeof(System.Decimal); how can i make this have
I'm soon to launch a beta app and this have the option to create
This must have been answered previously, but my Google powers are off today and
This may have been answered before, and if so, point me to the answer.
I have this array in PHP: array( [0] => array( 'username' => 'user1' )
We have this software that has a webservices component. Now, the administrator of this
I have this error message: Msg 8134, Level 16, State 1, Line 1 Divide
I have this membership site setup on my local machine using the ASP.NET membership
I have this DependencyProperty which holds an entity with a property that is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.