奇怪的结果将图像绘制到另一个图像上

时间:2016-10-04 12:59:33

标签: c# image watermark graphic

给出一张图片:

enter image description here

还有一个水印:

enter image description here

代码:

var originalImageBytes = originalFile.FileBytes();

// Draw watermark
using (var ms = new MemoryStream(originalImageBytes))
using(var originalImage = Image.FromStream(ms))
using (var watermark = Image.FromFile(Settings.FSO.RootNonPublicDirectory + "Images/Watermark/Watermark.png"))
using (var g = Graphics.FromImage(originalImage))
{
    g.DrawImage(watermark, 0, 0);

    using (var msOut = new MemoryStream())
    {
        originalImage.Save(msOut, ImageFormat.Jpeg);
        return msOut.ToArray();
    }
}

产生以下结果:

enter image description here

请注意,尺寸正确但图像底部的一大块缺失。

右键单击并save-as将此图像保存到我的磁盘上,看起来已损坏:

enter image description here

有谁知道这里发生了什么?

0 个答案:

没有答案