Thread: Using image as a mask in cairo (a c library)

  1. #1
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153

    Using image as a mask in cairo (a c library)

    I'm using cairo but have run into a snag. I want to load a raster image (a .png file) and then use that image as a mask. The image I am loading is black, and I would like to use it as clipping mask, or regular mask and 'stamp' so that I could change the image from black to another color (or gradient.) Pseudo-code or comments greatly appreciated. And this for my own project, not homework. Thanks.

  2. #2
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    I should probably add that the .png I am loading is a shape, a closed path, e.g. a palm tree.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    And how much of the online manual have you read this time?

    That is, before I go and read it for you (which is getting kinda boring)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    Figured it out, and I have read the online manual several times. It does not cover masking from a raster file. (Not masking a raster file, that's easy) There is a heck of a lot of cairo that is essentially undocumented, save for the api, which is not a replacement for simple usage examples. Still cairo does rock. For the record, I had to create a new surface from a png file. Create a mask from that surface. Set the source, mask a new context , and then write that context back to the original surface.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cairo, rasterizing text
    By javaeyes in forum C Programming
    Replies: 1
    Last Post: 03-06-2012, 08:51 PM
  2. vector field image library
    By kezman in forum C Programming
    Replies: 0
    Last Post: 04-18-2009, 08:02 AM
  3. Cairo and GTK, still need a pixmap?
    By TriKri in forum Linux Programming
    Replies: 0
    Last Post: 03-18-2008, 04:18 PM
  4. Good Image Library
    By e66n06 in forum C Programming
    Replies: 7
    Last Post: 09-24-2007, 09:36 AM
  5. Image Library
    By stickman in forum Windows Programming
    Replies: 8
    Last Post: 10-07-2006, 10:33 AM