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 7720781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:45:26+00:00 2026-06-01T03:45:26+00:00

I have a cairo_t cr which I can draw upon with cairo. I want

  • 0

I have a cairo_t cr which I can draw upon with cairo.
I want to try to create a highlighting effect on this cairo graphic that should do one of the things:

  • Lighten up the whole image so it looks a little brighter
  • Change the background, that is the transparent parts of the image to some brighter color (e.g white)
  • Maybe add a slight blur on the background

How can I do that with cairo?

[Edit] I have a widget that displays an icon and I want to highlight it when I move the mouse over the widget. Additionally to the highlight I also want to have some white background drawn, so that it is more clear which icon is highlighted. [/Edit]

  • 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-01T03:45:28+00:00Added an answer on June 1, 2026 at 3:45 am

    I think you should check out some of the operators that cairo has:

    http://cairographics.org/operators/

    Lightening up the whole image should be doable with SOFT_LIGHT or LIGHTEN and a bright source color. I guess. I’ll do some experiments on that.

    Why exactly do you want to change the transparent parts of the image? I would guess that most surfaces don’t have any transparent parts.
    Anyway, I think that the DEST_OVER with a white source should do that.

    Bluring is something that cairo cannot do for you. However, you can draw your image to an image surface and use some of the code that is floating around the internet for blurring that. For example, google just lead me this way: http://taschenorakel.de/mathias/2008/11/24/blur-effect-cairo/

    Edit: I did some experiments (this is the oocairo lua bindings, http://oocairo.naquadah.org/). I think that you want the operator CAIRO_OPERATOR_ATOP with a solid source of e.g. rgba(1, 1, 1, 0.25). This seems to indeed lighten up the image.

    
    oocairo = require("oocairo")
    
    s = oocairo.image_surface_create("argb32", 600, 400)
    img = oocairo.image_surface_create_from_png("/usr/share/icons/wesnoth-1.8-icon.png")
    local w, h = img:get_width(), img:get_height()
    
    cr = oocairo.context_create(s)
    
    function before()
        cr:save()
        cr:rectangle(0, 0, w, h)
        cr:clip()
        cr:set_source(img)
        cr:paint()
    end
    function after()
        cr:restore()
        cr:translate(w, 0)
    end
    
    function try_operator(op, alpha)
        before()
        cr:set_operator(op)
        cr:set_source_rgba(1, 1, 1, alpha)
        cr:paint()
        after()
    end
    
    function try_alpha(alpha)
        cr:save()
        before()
        after()
        try_operator("atop", alpha)
        try_operator("color-dodge", alpha)
        try_operator("soft-light", alpha)
        try_operator("hard-light", alpha)
        try_operator("hsl-hue", alpha)
        try_operator("hsl-saturation", alpha)
        try_operator("hsl-color", alpha)
        try_operator("hsl-luminosity", alpha)
        cr:restore()
        cr:translate(0, h)
    end
    
    try_alpha(1)
    try_alpha(0.75)
    try_alpha(0.5)
    try_alpha(0.25)
    try_alpha(0)
    
    s:write_to_png("/tmp/t.png")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code guile> (cairo-pdf-surface-create foo.pdf 100.0 100.0) ; and get this error
have written this little class, which generates a UUID every time an object of
I have a small application that uses a DrawingArea to draw a simple map
How can I stretch draw an area of a gdk pixbuf to a cairo
I have an album title of some music band. I want to draw it
Have you used or seen cairo dock in linux? I've read in wikipedia that's
I have this javascript in my html what i want to do here is
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:

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.