views:

337

answers:

2

Hello, I am trying to do custom drawing of an image(with alpha) and eventually going to apply different color tints to it. Right now I am just trying to draw it correctly. This might be simple problem but the result is the ALPHA on my image is black. Image is .png 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 alpha being black. Any help appreciated.

Tried another method of drawing, but shows black alpha and upside down(don't care about it being upside right now tho)

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

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

CGContextRestoreGState(context);
}
A: 

I believe that when you use drawInRect:blendMode:alpha, the alpha that you pass in overrides the alpha in your image. The documentation I just looked at wasn't quite clear.

mahboudz
How would I draw the image then without drawInRect?
A: 
[imagename drawInRect:CGRectMake(x, y, width, height)];

or

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