/// <summary>
        /// 建構子
        /// </summary>
        /// <param name="image">圖片</param>
        /// <param name="watermark">浮水印圖片</param>
        /// <param name="position">位置</param>
        public DrawWatermark(Image image, Image watermark, positionType position)
        {
            this.image = image;
            this._watermark = watermark;
            this._position = position;

            _countMaskPos(_position);
        }
示例#2
0
        /// <summary>
        /// 建構子
        /// </summary>
        /// <param name="image">圖片</param>
        /// <param name="watermark">浮水印圖片</param>
        /// <param name="position">位置</param>
        public DrawWatermark(Image image, Image watermark, positionType position)
        {
            this.image      = image;
            this._watermark = watermark;
            this._position  = position;

            _countMaskPos(_position);
        }
示例#3
0
        /// <summary>
        /// 計算出座標位置
        /// </summary>
        private void _countMaskPos(positionType position)
        {
            switch (position)
            {
            case positionType.LeftTop:
                // 左上
                _mask_pos_x = _mask_offset_x;
                _mask_pos_y = _mask_offset_y;
                break;

            case positionType.LeftBottom:
                // 左下
                _mask_pos_x = _mask_offset_x;
                _mask_pos_y = image.Height - _watermark.Height - _mask_offset_y;
                break;

            case positionType.RightTop:
                // 右上
                _mask_pos_x = image.Width - _watermark.Width - _mask_offset_x;
                _mask_pos_y = _mask_offset_y;
                break;

            case positionType.RightBottom:
                // 右下
                _mask_pos_x = image.Width - _watermark.Width - _mask_offset_x;
                _mask_pos_y = image.Height - _watermark.Height - _mask_offset_y;
                break;

            case positionType.CenterMiddle:
                // 置中
                _mask_pos_x = image.Width / 2 - _watermark.Width / 2;
                _mask_pos_y = image.Height / 2 - _watermark.Height / 2;
                break;

            default:
                // 預設將水印放到右下,偏移指定像素
                _mask_pos_x = image.Width - _watermark.Width - _mask_offset_x;
                _mask_pos_y = image.Height - _watermark.Height - _mask_offset_y;
                break;
            }
        }
        /// <summary>
        /// 計算出座標位置
        /// </summary>
        private void _countMaskPos(positionType position)
        {
            switch(position)
                {
                    case positionType.LeftTop:
                        // 左上
                        _mask_pos_x = _mask_offset_x;
                        _mask_pos_y = _mask_offset_y;
                        break;

                    case positionType.LeftBottom:
                        // 左下
                        _mask_pos_x = _mask_offset_x;
                        _mask_pos_y = image.Height - _watermark.Height - _mask_offset_y;
                        break;

                    case positionType.RightTop:
                        // 右上
                        _mask_pos_x = image.Width - _watermark.Width - _mask_offset_x;
                        _mask_pos_y = _mask_offset_y;
                        break;

                    case positionType.RightBottom:
                        // 右下
                        _mask_pos_x = image.Width - _watermark.Width - _mask_offset_x;
                        _mask_pos_y = image.Height - _watermark.Height - _mask_offset_y;
                        break;

                    case positionType.CenterMiddle:
                        // 置中
                        _mask_pos_x = image.Width / 2 - _watermark.Width / 2;
                        _mask_pos_y = image.Height / 2 - _watermark.Height / 2;
                        break;

                    default:
                        // 預設將水印放到右下,偏移指定像素
                        _mask_pos_x = image.Width - _watermark.Width - _mask_offset_x;
                        _mask_pos_y = image.Height - _watermark.Height - _mask_offset_y;
                        break;
                }
        }