It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center




已关闭8年。




我正在寻找将近一个小时的示例,以在C#中使用imagemagick.net,但我找不到任何东西。

我所需要的只是将图像(.jpg)调整为新的尺寸图像(jpg,也是如此),如果您知道如何添加水印,那就太好了。

我从下载了imagemagick.net

http://imagemagick.codeplex.com/

最佳答案

您必须使用ImageMagick吗?如果您要重新传送其他尺寸的图像,则可以使用GDI +。 http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing提供此功能来调整大小。我过去曾将本教程用于加水印:http://www.codeproject.com/KB/GDI-plus/watermark.aspx

private  static Image resizeImage(Image imgToResize, Size size)
{
  int sourceWidth = imgToResize.Width;
  int sourceHeight = imgToResize.Height;

  float nPercent = 0;
  float nPercentW = 0;
  float nPercentH = 0;

  nPercentW = ((float)size.Width / (float)sourceWidth);
  nPercentH = ((float)size.Height / (float)sourceHeight);

  if (nPercentH < nPercentW)
    nPercent = nPercentH;
  else
    nPercent = nPercentW;

  int destWidth = (int)(sourceWidth * nPercent);
  int destHeight = (int)(sourceHeight * nPercent);

  Bitmap b = new Bitmap(destWidth, destHeight);
  Graphics g = Graphics.FromImage((Image)b);
  g.InterpolationMode = InterpolationMode.HighQualityBicubic;

  g.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
  g.Dispose();

  return (Image)b;
}

关于c# - 如何在.net中使用imagemagick.net? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2996973/

10-13 03:09