title: Black borders around PNG image, drawn with OpenGL
body: <p>When I'm trying to draw a PNG image with transparency, using OpenGL, I get a strange black border around it:</p>
  
  <p><img src="https://i.stack.imgur.com/59YP2.png" alt="Two images with borders"></p>
  
  <p>But the original images are clean and normal:</p>
  
  <p><img src="https://i.stack.imgur.com/EnKYh.png" alt="Normal icons"></p>
  
  <p>My code:</p>
  
  <pre><code>glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
  UIImage* allIcons = [[appDelegate load_image_from_zip: pl.icons[ico_index]] retain];
  
                  CGRect rect = CGRectMake( 0, 0, allIcons.size.width/nIcons, allIcons.size.height );
                  UIGraphicsBeginImageContext(rect.size);
  
                  CGContextRef currentContext = UIGraphicsGetCurrentContext();
  
                  CGContextTranslateCTM ( currentContext, 0, allIcons.size.height );
                  CGContextScaleCTM ( currentContext, 1, -1 );
  
                  CGRect clippedRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
                  CGContextClipToRect( currentContext, clippedRect);
                  CGRect drawRect = CGRectMake(rect.origin.x * -1, rect.origin.y * -1, allIcons.size.width, allIcons.size.height);
                  CGContextDrawImage(currentContext, drawRect, allIcons.CGImage);
  </code></pre>