0
我想添加文字到圖片,因爲文字太長,所以我需要檢查text.width> image.width,如果是的話,我需要自動換行符。我也需要檢查text.height> image.height,如果是的話,我需要其他圖像來繪製text.i也在圖像上繪製文本。如何在c#中自動換行Windows Mobile#
public int makePictrue(string address, string pictrueAddress, string[] str, int[][] intPoint, Font font, SolidBrush solidB)
{
try
{
for (int i = 0; i < str.Length; i++)
{
Bitmap bmp;
if (pictrueAddress.Trim() == "")
{
bmp = new Bitmap("1.jpg");
}
else
{
bmp = new Bitmap(pictrueAddress);
}
g = Graphics.FromImage((Image)bmp);
g.DrawString(str[i], font, solidB, intPoint[i][0], intPoint[i][1]);
MemoryStream stream = new MemoryStream();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
bitmap = bmp;
}
return 1;
}
catch (Exception ex)
{
return 0;
}
}
謝謝回答,我HAVA使用MeasureString(),問題的關鍵是我DONOT知道如何自動換行,如何判斷角色到達哪個邊界。從哪個角色開始另一行。 – pengwang 2010-10-30 01:02:47