水印图像位置[asp.net] [英] Watermarking image position[asp.net]

查看:93
本文介绍了水印图像位置[asp.net]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循以下 article ,并且很容易实现 text over image ,现在我的问题是在上述文章中,图像水印位于距左侧 10像素的位置,我应该将图像放置为与右上方,右上方,左上方,左上方,中间,中央,右上方以及与下方相似.

I'm trying to follow this article and it was easy to implement text over image and now my problem is in the above mentioned article the image watermark was placed 10 pixels from left so how do I place image similarly to top right,top middle,middle left, center,middle right and similary to bottom.

在这里它是如何放置在右上角的:

Here is how it was placed to the top right corner :

int xPosOfWm = ((phWidth - wmWidth)-10);
int yPosOfWm = 10;

grWatermark.DrawImage(
  imgWatermark,
  new Rectangle(
    xPosOfWm, yPosOfWm,
    wmWidth, wmHeight
  ),
  0, 0,
  wmWidth, wmHeight,
  GraphicsUnit.Pixel,
  imageAttributes
);

推荐答案

当前代码不会将水印放在左上方,而是将水印放在右上方.

The current code doesn't place the watermark at the top left, it places at the top right.

使用以下命令将其放置在左上方:

To place it at the top left, you use:

int xPosOfWm = 10;
int yPosOfWm = 10;

要将水印水平放置在左侧,中央和右侧:

To position the watermark horisontally at the left, center and right:

int xPosOfWm = 10;

int xPosOfWm = (phWidth - wmWidth) / 2;

int xPosOfWm = (phWidth - wmWidth) - 10;

要将水印垂直放置在顶部,中间和底部:

To position the watermark vertically at the top, middle and bottom:

int yPosOfWm = 10;

int yPosOfWm = (phHeight - wmHeight) / 2;

int yPosOfWm = (phHeight - wmHeight) - 10;

只需将一个水平与一个垂直组合即可获得所需的任何组合.

Just combine one horisontal with one vertical to get any combination that you want.

这篇关于水印图像位置[asp.net]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆