Created
July 16, 2010 21:35
-
-
Save Clancey/478946 to your computer and use it in GitHub Desktop.
Allows on the fly change the properties of an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static UIImage AdjustImage(RectangleF rect,UIImage template, CGBlendMode mode,float red,float green,float blue,float alpha ) | |
{ | |
using (var cs = CGColorSpace.CreateDeviceRGB ()){ | |
using (var context = new CGBitmapContext (IntPtr.Zero, (int)rect.Width, (int)rect.Height, 8, (int)rect.Height*4, cs, CGImageAlphaInfo.PremultipliedLast)){ | |
context.TranslateCTM(0.0f,0f); | |
//context.ScaleCTM(1.0f,-1.0f); | |
context.DrawImage(rect,template.CGImage); | |
context.SetBlendMode(mode); | |
context.ClipToMask(rect,template.CGImage); | |
context.SetRGBFillColor(red,green,blue,alpha); | |
context.FillRect(rect); | |
return UIImage.FromImage (context.ToImage ()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment