Exemple #1
0
        /// <summary>
        /// 指定所绘制图像的位置和大小。将图像进行缩放以适合该矩形。
        /// </summary>
        /// <returns></returns>
        private static Rectangle GetWatermarkRectangle(int baseMapWidth, int baseMapHeight, int WatermarkWidth, int WatermarkHeight, string WatermarkPosition)
        {
            if (WatermarkWidth > (baseMapWidth - 5) || WatermarkHeight > (baseMapHeight - 5))
            {
                return(new Rectangle(0, baseMapHeight - WatermarkHeight, WatermarkWidth, WatermarkHeight));
            }
            Rectangle result = new Rectangle();

            switch (WatermarkPosition.ToLower())
            {
            case "righttop":
                result = PicHandle.GetRightTopRectangle(baseMapWidth, baseMapHeight, WatermarkWidth, WatermarkHeight);
                break;

            case "rightbottom":
                result = PicHandle.GetRightBottomRectangle(baseMapWidth, baseMapHeight, WatermarkWidth, WatermarkHeight);
                break;

            case "lefttop":
                result = PicHandle.GetLeftTopRectangle(baseMapWidth, baseMapHeight, WatermarkWidth, WatermarkHeight);
                break;

            case "leftbottom":
                result = PicHandle.GetLeftBottomRectangle(baseMapWidth, baseMapHeight, WatermarkWidth, WatermarkHeight);
                break;

            case "center":
                result = PicHandle.GetCenterRectangle(baseMapWidth, baseMapHeight, WatermarkWidth, WatermarkHeight);
                break;

            default:
                result = PicHandle.GetRightBottomRectangle(baseMapWidth, baseMapHeight, WatermarkWidth, WatermarkHeight);
                break;
            }
            return(result);
        }