title: How can I crop an Image with mask and combine it with another image (background) on iPhone? (OpenGL ES 1.1 is preferred)
body: <p>I need to combine three images the way I represent in attached file:</p>
  
  <p><img src="https://i.stack.imgur.com/Jg3CT.jpg" alt="enter image description here"></p>
  
  <p>1) One image is background. It is 'solid' in sense it has no alpha channel.</p>
  
  <p>2) Another one is sprite. Sprite lies upon background. Sprite may have its own alpha channel, background has to be visible in places where sprite is transparent.</p>
  
  <p>3) There's a number of masks: I apply new mask to Sprite every frame. Mask isn't rectangular.</p>
  
  <p>In other words, visible pixel = 
  pixel of background, if cropping mask corresponding color is white OR sprite is transparent;
  pixel of sprite otherwise (for example, corresponding mask's pixel is black).</p>
  
  <p>I'm working with cocos2d-iphone. Can I make such combination with cocos2d-iphone or with OpenGL ES 1.1? If any answer is YES, working code would be appreciated. If both answers is NO, is there another technology on iOS to make what I want (maybe Quartz2d or OpenGL ES 2.0) ?</p>
  
  <p>Mask format is not obligatory black for Sprite and white for Background. I can make Mask of required format, such as transparency for Background and white for Sprite if needed.</p>
  
  <p>P.S. There's another unanswered question of same kind: 
  <a href="https://stackoverflow.com/questions/787783/possible-to-change-the-alpha-value-of-certain-pixels-on-iphone">Possible to change the alpha value of certain pixels on iPhone?</a></p>