private void DrawClippedBitmap(bool roundTop, CGBitmapContext bit, bool roundBottom) { // Clipping path for the image, different on top, middle and bottom. if (roundBottom) { bit.AddArc(Rad, Rad, Rad, (float)Math.PI, (float)(3 * Math.PI / 2), false); } else { bit.MoveTo(0, Rad); bit.AddLineToPoint(0, 0); } bit.AddLineToPoint(Dimx, 0); bit.AddLineToPoint(Dimx, Dimy); if (roundTop) { bit.AddArc(Rad, Dimy - Rad, Rad, (float)(Math.PI / 2), (float)Math.PI, false); bit.AddLineToPoint(0, Rad); } else { bit.AddLineToPoint(0, Dimy); } bit.Clip(); bit.DrawImage(_rect, _scaled.CGImage); }
public override UITableViewCell GetCell(UITableView tv) { var cell = tv.DequeueReusableCell(ikey); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, ikey); } if (scaled == null) { return(cell); } Section psection = Parent as Section; bool roundTop = psection.Elements [0] == this; bool roundBottom = psection.Elements [psection.Elements.Count - 1] == this; using (var cs = CGColorSpace.CreateDeviceRGB()){ using (var bit = new CGBitmapContext(IntPtr.Zero, dimx, dimy, 8, 0, cs, CGImageAlphaInfo.PremultipliedFirst)){ if (roundBottom) { bit.AddArc(rad, rad, rad, (float)Math.PI, (float)(3 * Math.PI / 2), false); } else { bit.MoveTo(0, rad); bit.AddLineToPoint(0, 0); } bit.AddLineToPoint(dimx, 0); bit.AddLineToPoint(dimx, dimy); if (roundTop) { bit.AddArc(rad, dimy - rad, rad, (float)(Math.PI / 2), (float)Math.PI, false); bit.AddLineToPoint(0, rad); } else { bit.AddLineToPoint(0, dimy); } bit.Clip(); bit.DrawImage(rect, scaled.CGImage); cell.ImageView.Image = UIImage.FromImage(bit.ToImage()); } } return(cell); }
public override void InitializeCell(UITableView tableView) { if (scaled != null) { ISection psection = Parent as ISection; bool roundTop = psection.Elements[0] == this; bool roundBottom = psection.Elements[psection.Elements.Count - 1] == this; using (var cs = CGColorSpace.CreateDeviceRGB()) { using (var bit = new CGBitmapContext(IntPtr.Zero, dimx, dimy, 8, 0, cs, CGImageAlphaInfo.PremultipliedFirst)) { // Clipping path for the image, different on top, middle and bottom. if (roundBottom) { bit.AddArc(rad, rad, rad, (float)Math.PI, (float)(3 * Math.PI / 2), false); } else { bit.MoveTo(0, rad); bit.AddLineToPoint(0, 0); } bit.AddLineToPoint(dimx, 0); bit.AddLineToPoint(dimx, dimy); if (roundTop) { bit.AddArc(rad, dimy - rad, rad, (float)(Math.PI / 2), (float)Math.PI, false); bit.AddLineToPoint(0, rad); } else { bit.AddLineToPoint(0, dimy); } bit.Clip(); bit.DrawImage(rect, scaled.CGImage); Cell.ImageView.Image = UIImage.FromImage(bit.ToImage()); } } } }
public override UITableViewCell GetCell (UITableView tv) { var cell = tv.DequeueReusableCell (ikey); if (cell == null){ cell = new UITableViewCell (UITableViewCellStyle.Default, ikey); } if (scaled == null) return cell; Section psection = Parent as Section; bool roundTop = psection.Elements [0] == this; bool roundBottom = psection.Elements [psection.Elements.Count-1] == this; using (var cs = CGColorSpace.CreateDeviceRGB ()){ using (var bit = new CGBitmapContext (IntPtr.Zero, dimx, dimy, 8, 0, cs, CGImageAlphaInfo.PremultipliedFirst)){ // Clipping path for the image, different on top, middle and bottom. if (roundBottom){ bit.AddArc (rad, rad, rad, (float) Math.PI, (float) (3*Math.PI/2), false); } else { bit.MoveTo (0, rad); bit.AddLineToPoint (0, 0); } bit.AddLineToPoint (dimx, 0); bit.AddLineToPoint (dimx, dimy); if (roundTop){ bit.AddArc (rad, dimy-rad, rad, (float) (Math.PI/2), (float) Math.PI, false); bit.AddLineToPoint (0, rad); } else { bit.AddLineToPoint (0, dimy); } bit.Clip (); bit.DrawImage (rect, scaled.CGImage); cell.ImageView.Image = UIImage.FromImage (bit.ToImage ()); cell.TextLabel.Text = "image profile"; } } return cell; }
public override void InitializeCell(UITableView tableView) { if (_Scaled != null) { bool roundTop = Section.Elements[0] == this; bool roundBottom = Section.Elements[Section.Elements.Count - 1] == this; using (var cs = CGColorSpace.CreateDeviceRGB()) { using (var bit = new CGBitmapContext(IntPtr.Zero, dimx, dimy, 8, 0, cs, CGImageAlphaInfo.PremultipliedFirst)) { // Clipping path for the image, different on top, middle and bottom. if (roundBottom) { bit.AddArc(rad, rad, rad, (float)Math.PI, (float)(3 * Math.PI / 2), false); } else { bit.MoveTo(0, rad); bit.AddLineToPoint(0, 0); } bit.AddLineToPoint(dimx, 0); bit.AddLineToPoint(dimx, dimy); if (roundTop) { bit.AddArc(rad, dimy - rad, rad, (float)(Math.PI / 2), (float)Math.PI, false); bit.AddLineToPoint(0, rad); } else { bit.AddLineToPoint(0, dimy); } bit.Clip(); bit.DrawImage(rect, _Scaled.CGImage); Cell.ImageView.Image = UIImage.FromImage(bit.ToImage()); } } } }