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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:28:55+00:00 2026-05-28T03:28:55+00:00

I’m trying to apply BlendModes to a GreyScale image in order to have reusable

  • 0

I’m trying to apply BlendModes to a GreyScale image in order to have reusable static resources

I’ve been searching in the internet for hours and I did my own tests but I didn’t find any solution.

I started with this image:

enter image description here

And the basic idea was to draw a rectangle over it in a certain color and apply a blending mode to the image only where the alpha is 1.0

Here is the Code (this is part of a Cocos2d project although I think it can be applied to generic OGL ES):

-(void)draw
{
    [super draw];

    glBlendColor(0,255,0,255);

    glBlendFunc(GL_ZERO, GL_SRC_COLOR);
    glColor4ub(255, 0, 255, 255);
    glLineWidth(2);
    CGPoint vertices2[] = { ccp(0,100), ccp(100,100), ccp(100,0) };
    [ DrawingHelper  drawPolygonWithPoints:vertices2 points:3 closePolygon:YES];

}

*Draw helper is the logic to draw the triangle.

+(void)drawPolygonWithPoints:(CGPoint *)poli points:(int)points closePolygon:(BOOL)closePolygon
{
    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, poli);

    if( closePolygon )
        glDrawArrays(GL_TRIANGLE_FAN, 0, points);
    else
        glDrawArrays(GL_LINE_STRIP, 0, points);

    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);
}

And here some results:

enter image description here
enter image description here

As you can see is a good approximation but this two images has error:

OpenGL error 0x0502 in -[EAGLView swapBuffers]

My Questions are:

  1. How can I remove or fix this error?
  2. How can keep only the alpha of the image (shield) and apply the blend overlay color?

[Update]This is an example of what I would like (with the correct blends):

enter image description here

  • 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-28T03:28:56+00:00Added an answer on May 28, 2026 at 3:28 am

    apply a blending mode to the image only where the alpha is 1.0

    This sounds like an application for alpha testing. Only that I’d first draw the rectangle and then make the alpha test fail for equal 1.0 (or greater than 0.99 to allow for some margin). This doesn’t require blending.


    Edit for updated question

    Desired results:

    enter image description here

    I think you mixed up Multiply and Overlay captions up there.

    In all those cases this is done using either

    • glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GEQUAL, 0.995); // not using 1.0 for some margin

    or

    • glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    The effects are not created by setting the blend function or mode, but by texture environment or shader.

    The “Overlay” (actually multiply) effect corresponds to the GL_MODULATE texture environment mode. Or in terms of a shader gl_FragColor = texture2D(...) * color;.

    “Lighten” is min(texture2D(...), color);

    “Multiply” (actually overlay) is gl_FragColor = 1. - (1.-color*texture2D(...))*(1.-color);

    “Soft Light” is gl_FragColor = (1. - (1.-texture2D(...))*(1.-color))*k + b; (k and b choosen parameters).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.