那好吧...是这样的:
Bitmap yourImage = ...;
Bitmap yourWatermark = ...;
int newWaterWidth = (int)((float)yourImage.Width * .3);
int newWaterHeight = (int)((float)yourImage.Height* .3);
using(Bitmap resizedWaterm = new Bitmap(newWaterWidth, newWaterHeight))
using(Graphics g = Graphics.FromImage((Image)resizedWaterm))
{
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(yourWatermark, 0, 0, newWaterWidth , newWaterHeight);
}
int x = ..., y = ...;
using(Graphics g2 = Graphics.FromImage((Image)resizedWaterm))
{
g2.FillRectangle(watermarkBrush, new Rectangle(new Point(x, y), new Size(watermarkImage.Width + 1, watermarkImage.Height)));
}
(未测试,你还需要在...点的值来填充)
代码调整大小:Resizing an Image without losing any quality
希望这有助于!
那么...你如何应用水印? 'Image'对象系列具有'.Width'和'.Height'值 - 所以你需要做一个简单的缩放操作,保留宽高比,并使用当你有水印但没有代码时,我们将无法帮助 – Basic 2013-05-02 07:44:41
@基本水印: imageGraphics.FillRectangle(watermarkBrush,new Rectangle(new Point(x,y),new Size(watermarkImage.Width + 1,watermarkImage.Height))); – 2013-05-02 07:48:22