string”不包含“GetExtension”的定义,并且找不到可接受类型为“string”的第一个参数的扩展方法
publicstaticvoidAddWater(stringPath,stringPath_sy,Dictionary<string,string>config){st...
public static void AddWater(string Path, string Path_sy, Dictionary<string, string> config)
{
string s = config["maxValue"];
Image image = Image.FromFile(Path);
int width = image.Width;
int height = image.Height;
if ((width < 50) | (height < 50))
{
image.Dispose();
}
else
{
Image image2 = new Bitmap(width, height);
Graphics graphics = Graphics.FromImage(image2);
graphics.InterpolationMode = InterpolationMode.High;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.Clear(Color.Transparent);
graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
image.Dispose();
graphics.Dispose();
Graphics graphics2 = Graphics.FromImage(image2);
graphics2.DrawImage(image2, 0, 0, image2.Width, image2.Height);
Font font = new Font("Verdana", 12f);
Brush brush = new SolidBrush(Color.Black);
graphics2.DrawString(s, font, brush, (float)0f, (float)0f);
graphics2.Dispose();
//下面的语句出现错误:“string”不包含“GetExtension”的定义,并且找不到可接受类型为“string”的第一个参数的扩展方法“GetExtension”(是否缺少 using 指令或程序集引用?)
string str3 = Path.GetExtension(Path_sy).ToLower();
if (str3 != null)
{
if (!(str3 == ".jpg"))
{
if (str3 == ".bmp")
{
image2.Save(Path_sy, ImageFormat.Bmp);
}
else if (str3 == ".gif")
{
image2.Save(Path_sy, ImageFormat.Gif);
}
else if (str3 == ".png")
{
image2.Save(Path_sy, ImageFormat.Png);
}
}
else
{
image2.Save(Path_sy, ImageFormat.Jpeg);
}
}
image2.Dispose();
}
} 展开
{
string s = config["maxValue"];
Image image = Image.FromFile(Path);
int width = image.Width;
int height = image.Height;
if ((width < 50) | (height < 50))
{
image.Dispose();
}
else
{
Image image2 = new Bitmap(width, height);
Graphics graphics = Graphics.FromImage(image2);
graphics.InterpolationMode = InterpolationMode.High;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.Clear(Color.Transparent);
graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
image.Dispose();
graphics.Dispose();
Graphics graphics2 = Graphics.FromImage(image2);
graphics2.DrawImage(image2, 0, 0, image2.Width, image2.Height);
Font font = new Font("Verdana", 12f);
Brush brush = new SolidBrush(Color.Black);
graphics2.DrawString(s, font, brush, (float)0f, (float)0f);
graphics2.Dispose();
//下面的语句出现错误:“string”不包含“GetExtension”的定义,并且找不到可接受类型为“string”的第一个参数的扩展方法“GetExtension”(是否缺少 using 指令或程序集引用?)
string str3 = Path.GetExtension(Path_sy).ToLower();
if (str3 != null)
{
if (!(str3 == ".jpg"))
{
if (str3 == ".bmp")
{
image2.Save(Path_sy, ImageFormat.Bmp);
}
else if (str3 == ".gif")
{
image2.Save(Path_sy, ImageFormat.Gif);
}
else if (str3 == ".png")
{
image2.Save(Path_sy, ImageFormat.Png);
}
}
else
{
image2.Save(Path_sy, ImageFormat.Jpeg);
}
}
image2.Dispose();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询