【问题标题】:Alternatives for languages that ad sense doesn't support广告感知不支持的语言的替代方案
【发布时间】:2016-01-27 09:29:16
【问题描述】:

简介:

我正在使用我的本地网站,该网站以本地语言显示本地内容。

问题:

很遗憾,Google Ads 不支持我的本地语言:

所以我想到的一种方法是将所有文本/字符串转换为图像并改为显示图像。(服务器端)

问题

我正在使用 c# 方法将文本转换为图像。我不明白它的多行文本的实现?

或者有没有更好的方法来支持广告感知不支持没有图像的语言?

C# 代码

            string text = str.Trim();
            Bitmap bitmap = new Bitmap(1, 1);
            Font font = new Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Pixel);
            Graphics graphics = Graphics.FromImage(bitmap);
            int width = (int)graphics.MeasureString(text, font).Width;
            int height = (int)graphics.MeasureString(text, font).Height;
            bitmap = new Bitmap(bitmap, new Size(width, height));
            graphics = Graphics.FromImage(bitmap);
            graphics.Clear(Color.White);
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            graphics.DrawString(text, font, new SolidBrush(Color.FromArgb(255, 0, 0)), 0, 0);
            graphics.Flush();
            graphics.Dispose();
            string fileName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".jpg";
            bitmap.Save(Server.MapPath("~/App_Images/") +"11"+fileName, ImageFormat.Jpeg);
            //imgText.ImageUrl = "~/images/" + fileName;
            //imgText.Visible = true;
            return "~/App_Images/My_Converted.jpg";

如果有人对此类问题或任何参考/链接有任何想法,请提供帮助。感谢您的宝贵时间。

【问题讨论】:

  • 什么语言?谷歌肯定会涵盖这一点……你为什么要将谷歌广告显示为图片?如果你这样做,你可能不会得到报酬,所以这没有任何意义,而且广告太多了。要回答您的问题,您可以为多线调用 2 次或更多 DrawString,Google:Msdn DrawString
  • @JeremyThompson 感谢您的回复,我的意思是我的网站内容是本地语言,谷歌 adsense 不支持。所以我想我可以显示用本地语言编写的该内容的图像.. ...
  • @DownVoter 关心解释他的否决行为的性质?????所以我可以相应地编辑我的问题!!!!
  • 好的,我明白了。必须有更好的方法,我用谷歌搜索并看到了困境(我没有投反对票)
  • @JeremyThompson 请将其发布为答案。如果我寻找内置的绘图方法来做到这一点,这是一个很好的方向.....亲爱的我知道,通常不赞成的人不会发表评论......

标签: c# asp.net .net asp.net-mvc c#-4.0


【解决方案1】:

在 C# 中,您可以简单地在字符串中添加一个换行符 (\r\n)。


我对您的问题进行了编辑,以使其更具吸引力并与更广泛的受众相关。请暂时不要标记此问题,以听取更多想法,干杯!

【讨论】:

  • 非常感谢,+1 的帮助
  • @"欢迎您\r\n";
猜你喜欢
  • 1970-01-01
  • 2015-09-26
  • 1970-01-01
  • 1970-01-01
  • 2014-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多