Discussion:
如何在圖檔中加上文字呢?
(时间太久无法回复)
unknown
2006-08-23 07:54:02 UTC
Permalink
請教專家們:

我用VB語法想描繪出線條與文字,可是碰到宣告上的問題,可否請專家指點迷津,謝謝!
例子如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'在這裡放置使用者程式碼以初始化網頁
Dim BitMap1 As New Bitmap(800, 400)
Dim g As Graphics = Graphics.FromImage(BitMap1)
g.Clear(Color.Yellow)
Dim Bluepen As New System.Drawing.Pen(Color.Blue, 5)
Dim Redpen As New System.Drawing.Pen(Color.Red, 7)
Dim F As New System.Drawing.Font("arial", 10)
Dim b As New System.Drawing.Brushes(Color.Red)
g.DrawString("這是測試", F, b, 90, 20)
g.DrawLine(Bluepen, 10, 12, 100, 12)
g.DrawLine(Redpen, 100, 42, 380, 42)
BitMap1.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)


End Sub

錯誤訊息如下:

c:\inetpub\wwwroot\cgd\graph.aspx.vb(32): 無法在此內容中存取
'System.Drawing.Brushes.Private Sub New()',因為它是 'Private'。
c:\inetpub\wwwroot\cgd\graph.aspx.vb(33): 多載解析失敗,因為具備這些引數的 'DrawString'
不存在,故無法呼叫:
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': 型別 System.Drawing.Brushes 的值無法轉換成
System.Drawing.Brush。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成
System.Drawing.RectangleF。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成
System.Drawing.StringFormat。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': 型別 System.Drawing.Brushes 的值無法轉換成
System.Drawing.Brush。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成 System.Drawing.PointF。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成 System.Drawing.StringFormat。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, x As Single, y As Single)': 型別
System.Drawing.Brushes 的值無法轉換成 System.Drawing.Brush。
璉璉
2006-08-23 09:11:10 UTC
Permalink
€wŠb­Ó€H live spaces €WŠ^ÂСAÂà¶KŠp€U¡G
§Aªº¿ù»~°T®§Š³»¡¡G¡u«¬§O System.Drawing.Brushes ªº­ÈµLªkÂàŽ«Šš System.Drawing.Brush¡v
©Ò¥H¥i¥H±À±o§Aªº«Å§i¬O¿ù»~ªº¡G
Dim b As New System.Drawing.Brushes(Color.Red)
œÐžÕµÛ§ï¬°¡G
Dim b As New System.Drawing.SolidBrush(Color.Red)
§AŠb³oÃä¶K€j¶qªº­ì©lœX»P¿ù»~°T®§¡A·PıŠ³ÂI¶Ã¡A¥B§AŠb°Qœ×°ÏŠ³¯dš¥€F¡A«Øij§AŠb°Qœ×°Ïµo€å§Y¥i¡AŠb spaces €W¡AŠ]¬°ª©­±Š³­­¡A€£€ÓŸAŠX¶K€j¶qµ{Š¡œX¡C
©ó news:B1C065CB-10AF-44A3-B188-0D1496ADBCC6%40microsoft.com µoªí
œÐ±Ð±M®a­Ì¡G
§Ú¥ÎVB»yªk·QŽyÞ¥Xœu±ø»P€åŠr¡A¥i¬OžIšì«Å§i€Wªº°ÝÃD¡A¥i§_œÐ±M®a«üÂI°g¬z¡AÁÂÁ¡I
šÒ€lŠp€U¡G
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Šb³ožÌ©ñžmšÏ¥ÎªÌµ{Š¡œX¥Hªì©l€Æºô­¶
Dim BitMap1 As New Bitmap(800, 400)
Dim g As Graphics = Graphics.FromImage(BitMap1)
g.Clear(Color.Yellow)
Dim Bluepen As New System.Drawing.Pen(Color.Blue, 5)
Dim Redpen As New System.Drawing.Pen(Color.Red, 7)
Dim F As New System.Drawing.Font("arial", 10)
Dim b As New System.Drawing.Brushes(Color.Red)
g.DrawString("³o¬OŽúžÕ", F, b, 90, 20)
g.DrawLine(Bluepen, 10, 12, 100, 12)
g.DrawLine(Redpen, 100, 42, 380, 42)
BitMap1.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
¿ù»~°T®§Šp€U¡G
c:\inetpub\wwwroot\cgd\graph.aspx.vb(32): µLªkŠbŠ¹€º®e€€Šsšú
'System.Drawing.Brushes.Private Sub New()'¡AŠ]¬°¥Š¬O 'Private'¡C
c:\inetpub\wwwroot\cgd\graph.aspx.vb(33): ŠhžüžÑªR¥¢±Ñ¡AŠ]¬°šã³Æ³ošÇ€ÞŒÆªº 'DrawString'
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': «¬§O System.Drawing.Brushes ªº­ÈµLªkÂàŽ«Šš
System.Drawing.Brush¡C
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': «¬§O Integer ªº­ÈµLªkÂàŽ«Šš
System.Drawing.RectangleF¡C
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': «¬§O Integer ªº­ÈµLªkÂàŽ«Šš
System.Drawing.StringFormat¡C
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': «¬§O System.Drawing.Brushes ªº­ÈµLªkÂàŽ«Šš
System.Drawing.Brush¡C
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': «¬§O Integer ªº­ÈµLªkÂàŽ«Šš System.Drawing.PointF¡C
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': «¬§O Integer ªº­ÈµLªkÂàŽ«Šš System.Drawing.StringFormat¡C
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, x As Single, y As Single)': «¬§O
System.Drawing.Brushes ªº­ÈµLªkÂàŽ«Šš System.Drawing.Brush¡C
--
­·¬ê¬ì§ÞÅçÃÒŠ³­­€œ¥q ASP.NET Web News Reader 0.2.3 UTF-8 Beta
ºô¯žŠa¹Ï http://tlcheng.twbbs.org/wwwmap.htm
¬y°ìšŸ¬x/°Ï°ì€ôžê·œ/®}ª@ºô/ªŽºÀ¹Ï/»y­µ³q°T €å³¹»Pµ{Š¡
Basic/Fortran/Windows API/.Net/»²§U»¡©úÀÉ ­ì©lœX¡B€å³¹»P°Qœ×
·L³nµ{Š¡³]­p·s°Qœ×°Ï MSDN §Þ³Nœ×ŸÂ¡Aºô€ÍŠ^ÂЫá§Y®É²°T¡B¹q€l¶l¥ó³qªŸ¡G
http://forums.microsoft.com/msdn-cht/default.aspx?siteid=14
--
ASPNET News Reader http://tlcheng.twbbs.org/News/Reader.aspx
RSS 2.0 http://tlcheng.twbbs.org/News/rss2.aspx?Action=List&Newsgroup=microsoft.public.tw.dotnet.framework.aspnet
unknown
2006-08-23 09:20:01 UTC
Permalink
謝謝指教

"璉璉" 來函:
已在個人 live spaces 上回覆,轉貼如下:
你的錯誤訊息有說:「型別 System.Drawing.Brushes 的值無法轉換成 System.Drawing.Brush」
所以可以推得你的宣告是錯誤的:
Dim b As New System.Drawing.Brushes(Color.Red)
請試著改為:
Dim b As New System.Drawing.SolidBrush(Color.Red)
你在這邊貼大量的原始碼與錯誤訊息,感覺有點亂,且你在討論區有留言了,建議你在討論區發文即可,在 spaces 上,因為版面有限,不太適合貼大量程式碼。
於 news:B1C065CB-10AF-44A3-B188-0D1496ADBCC6%40microsoft.com 發表
請教專家們:
我用VB語法想描繪出線條與文字,可是碰到宣告上的問題,可否請專家指點迷津,謝謝!
例子如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'在這裡放置使用者程式碼以初始化網頁
Dim BitMap1 As New Bitmap(800, 400)
Dim g As Graphics = Graphics.FromImage(BitMap1)
g.Clear(Color.Yellow)
Dim Bluepen As New System.Drawing.Pen(Color.Blue, 5)
Dim Redpen As New System.Drawing.Pen(Color.Red, 7)
Dim F As New System.Drawing.Font("arial", 10)
Dim b As New System.Drawing.Brushes(Color.Red)
g.DrawString("這是測試", F, b, 90, 20)
g.DrawLine(Bluepen, 10, 12, 100, 12)
g.DrawLine(Redpen, 100, 42, 380, 42)
BitMap1.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
錯誤訊息如下:
c:\inetpub\wwwroot\cgd\graph.aspx.vb(32): 無法在此內容中存取
'System.Drawing.Brushes.Private Sub New()',因為它是 'Private'。
c:\inetpub\wwwroot\cgd\graph.aspx.vb(33): 多載解析失敗,因為具備這些引數的 'DrawString'
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': 型別 System.Drawing.Brushes 的值無法轉換成
System.Drawing.Brush。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成
System.Drawing.RectangleF。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, layoutRectangle As System.Drawing.RectangleF, format
As System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成
System.Drawing.StringFormat。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': 型別 System.Drawing.Brushes 的值無法轉換成
System.Drawing.Brush。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成 System.Drawing.PointF。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, point As System.Drawing.PointF, format As
System.Drawing.StringFormat)': 型別 Integer 的值無法轉換成 System.Drawing.StringFormat。
'Public Sub DrawString(s As String, font As System.Drawing.Font, brush
As System.Drawing.Brush, x As Single, y As Single)': 型別
System.Drawing.Brushes 的值無法轉換成 System.Drawing.Brush。
--
風禹科技驗證有限公司 ASP.NET Web News Reader 0.2.3 UTF-8 Beta
網站地圖 http://tlcheng.twbbs.org/wwwmap.htm
流域防洪/區域水資源/徐昇網/玫瑰圖/語音通訊 文章與程式
Basic/Fortran/Windows API/.Net/輔助說明檔 原始碼、文章與討論
微軟程式設計新討論區 MSDN 技術論壇,網友回覆後即時簡訊、電子郵件通知:
http://forums.microsoft.com/msdn-cht/default.aspx?siteid=14
--
ASPNET News Reader http://tlcheng.twbbs.org/News/Reader.aspx
RSS 2.0 http://tlcheng.twbbs.org/News/rss2.aspx?Action=List&Newsgroup=microsoft.public.tw.dotnet.framework.aspnet
Loading...