Custom alpha drawing

I am trying to customize an image (with alpha) and end up going to apply different color tones to it. Right now I'm just trying to get it right. It might be a simple problem, but the ALPHA results in black in my image. The .png image is created from photoshop with correct alpha.

- (void) drawRect:(CGRect)area
{

[imgView.image drawInRect: area blendMode:blendMode alpha:alpha]; // draw image
}

      

blendMode is normal and alpha is 1.0. The image is good except for alpha, black. Any help was appreciated.

Tried another drawing method but shows black alpha and upside down (don't worry it's up top right now)

- (void) drawRect:(CGRect)area
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);

// Draw picture first
CGContextDrawImage(context, area, imgView.image.CGImage);

CGContextRestoreGState(context);
}

      

+2


source to share


2 answers


I believe that when you use drawInRect:blendMode:alpha

, the alpha you pass overrides the alpha in your image. The documentation I just looked at is not entirely clear.



0


source


[imagename drawInRect:CGRectMake(x, y, width, height)];

      

or



[imagename drawAtPoint:CGPointMake(x, y)];

      

0


source







All Articles