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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:18:57+00:00 2026-05-26T06:18:57+00:00

I am trying to erase an image with my touch in iOS. By setting

  • 0

I am trying to erase an image with my touch in iOS. By setting the blend mode to kCGBlendModeClear I am able to do this – but only with hard edges. I could draw my stroke with varying line widths and alphas, but it appears that CGContextSetAlpha does not have an effect with kCGBlendModeClear.

How do I go about this?

  • 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-05-26T06:18:58+00:00Added an answer on May 26, 2026 at 6:18 am

    I would use a transparency layer compositing with kCGBlendModeDestinationOut (Da * (1 - Sa), Dc * (1 - Sa).) Something like this:

    CGPathRef pathToErase = ...; // The path you want erased
    // could also be an image or (nearly) anything else
    // that can be drawn in a bitmap context
    
    CGContextSetBlendMode(ctx, kCGBlendModeDestinationOut);
    CGContextBeginTransparencyLayer(ctx, NULL);
    {
        CGContextSetGrayFillColor(ctx, 0.0, 1.0); // solid black
    
        CGContextAddPath(ctx, pathToErase);
        CGContextFillPath(ctx);
        // the above two lines could instead be CGContextDrawImage()
        // or whatever else you're using to clear
    }
    CGContextEndTransparencyLayer(ctx);
    

    Note that you should also save and restore the gstate (CGContextSaveGState()/CGContextRestoreGState()) before/after the transparency layer to ensure that the blend mode and any other gstate changes do not persist.

    Note: This is brain-compiled and it’s possible that transparency layers don’t play nice with all blend modes. If so, try drawing the path/image into a second bitmap context, then drawing the contents of that context with the above blend mode.

    You can also experiment with other blend modes for different effects.

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

Sidebar

Related Questions

I'm trying to make a database in android but I have this problem,erase the
I am trying to erase the paint in my app? but it is not
I'm trying to erase a pointer to an object, but I keep crashing the
Getting this error while trying to erase the last element of a list. I
I'm trying to make a very basic image creator using PySide. But I'm having
I was trying to erase a range of elements from map based on particular
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
I am trying to erase the last element of a multiset using: minheap.erase(minheap.rbegin()); It
I have a strange problem here. I'm trying to erase an iterator from a
We are trying to use the std::deque erase member function. The return value of

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.