S
S
Scalar2011-08-31 19:21:36
iPhone
Scalar, 2011-08-31 19:21:36

Weird black border around the PNG image, in places of translucency (CoreGraphics/ObjC)

When I try to render PNG images with translucency, I get this
image
: strange dark pixels in places with translucency, although they obviously should not be there.

Original image - normal:
image

Render code:

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

                UIImage* allIcons =  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);


CHADNT?
plz help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Infernal, 2011-08-31
@Infernal

Try calling CGContextSetBlendMode(currentContext, kCGBlendModeSourceIn) before CGContextDrawImage but this piece is obviously superfluous here
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question