public static Bitmap OverlayBitmap(Bitmap destBmp, Bitmap bmpToOverlay, ImageCornerEnum corner) { return(OverlayBitmap(destBmp, bmpToOverlay, 0, corner)); }
public static Bitmap OverlayBitmap(Bitmap destBmp, Bitmap bmpToOverlay, ImageCornerEnum corner) { return OverlayBitmap(destBmp, bmpToOverlay, 0, corner); }
/// <summary> /// Renders a bitmap over another bitmap, with a specific alpha value. /// This can be used to overlay a logo or watermark over a bitmap /// </summary> /// <param name="destBmp">Bitmap over which image is to be overlaid</param> /// <param name="bmpToOverlay">Bitmap to overlay</param> /// <param name="overlayAlpha">Alpha value fo overlay bitmap. 0 = fully transparent, 100 = fully opaque</param> /// <param name="corner">Corner of destination bitmap to place overlay bitmap</param> /// <returns></returns> public static Bitmap OverlayBitmap(Bitmap destBmp, Bitmap bmpToOverlay, int overlayAlpha, ImageCornerEnum corner) { //Translate corner to rectangle and pass through to other impl Point overlayPoint; if (corner.Equals(ImageCornerEnum.TopLeft)) { overlayPoint = new Point(0, 0); } else if (corner.Equals(ImageCornerEnum.TopRight)) { overlayPoint = new Point(destBmp.Size.Width - bmpToOverlay.Size.Width, 0); } else if (corner.Equals(ImageCornerEnum.BottomRight)) { overlayPoint = new Point(destBmp.Size.Width - bmpToOverlay.Size.Width, destBmp.Size.Height - bmpToOverlay.Size.Height); } else if (corner.Equals(ImageCornerEnum.Center)) { overlayPoint = new Point(destBmp.Size.Width / 2 - bmpToOverlay.Size.Width / 2, destBmp.Size.Height / 2 - bmpToOverlay.Size.Height / 2); } else { overlayPoint = new Point(0, destBmp.Size.Height - bmpToOverlay.Size.Height); } return(OverlayBitmap(destBmp, bmpToOverlay, overlayAlpha, overlayPoint)); }
/// <summary> /// Renders a bitmap over another bitmap, with a specific alpha value. /// This can be used to overlay a logo or watermark over a bitmap /// </summary> /// <param name="destBmp">Bitmap over which image is to be overlaid</param> /// <param name="bmpToOverlay">Bitmap to overlay</param> /// <param name="overlayAlpha">Alpha value fo overlay bitmap. 0 = fully transparent, 100 = fully opaque</param> /// <param name="corner">Corner of destination bitmap to place overlay bitmap</param> /// <returns></returns> public static Bitmap OverlayBitmap(Bitmap destBmp, Bitmap bmpToOverlay, int overlayAlpha, ImageCornerEnum corner) { //Translate corner to rectangle and pass through to other impl Point overlayPoint; if (corner.Equals(ImageCornerEnum.TopLeft)) { overlayPoint = new Point(0, 0); } else if (corner.Equals(ImageCornerEnum.TopRight)) { overlayPoint = new Point(destBmp.Size.Width - bmpToOverlay.Size.Width, 0); } else if (corner.Equals(ImageCornerEnum.BottomRight)) { overlayPoint = new Point(destBmp.Size.Width - bmpToOverlay.Size.Width, destBmp.Size.Height - bmpToOverlay.Size.Height); } else if (corner.Equals(ImageCornerEnum.Center)) { overlayPoint = new Point(destBmp.Size.Width / 2 - bmpToOverlay.Size.Width / 2, destBmp.Size.Height / 2 - bmpToOverlay.Size.Height / 2); } else { overlayPoint = new Point(0, destBmp.Size.Height - bmpToOverlay.Size.Height); } return OverlayBitmap(destBmp, bmpToOverlay, overlayAlpha, overlayPoint); }