|
■No80412 (WebSurfer さん) に返信 > ■No80411 (国方賢治 さん) に返信 > >国方賢治の返事 指摘のとうりに次のように、コードを変えました Imports System.Drawing Public Class Pyramid Inherits System.Web.UI.Page Dim img As New Bitmap(500, 500) Dim g As Graphics = Graphics.FromImage(img) Const XMAX = 399, YMAX = 399 Const HABA = 60, MITUDO = 25, RITTAIDO = 2 Dim TAKASA(0 To XMAX), DOT(0 To XMAX) As String Dim pathtofile = Server.MapPath("~/images/pyramid3.png") Private pyramid3 As Object
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
OBJECTBYOGA() For Y = 0 To YMAX ' Erase DOT For i = 0 To XMAX DOT(i) = "" Next
TAKASALOAD(Y) For X = 0 To XMAX Dim TAKASA1 As Integer = TAKASA(X) * RITTAIDO If DOT(X) = "" Then If Rnd() * 100 < MITUDO Then DOT(X) = "7" Else DOT(X) = "0" End If End If img.SetPixel(X, Y, System.Drawing.ColorTranslator.FromOle(QBColor(Val(DOT(X))))) Dim TUGI As Integer = X + HABA - (TAKASA1 * RITTAIDO) If TUGI >= 0 And TUGI <= XMAX Then
DOT(TUGI) = DOT(X) End If Next Next
' Response.ContentType = "image/png" ' Response.Flush() ' img.Save(Response.OutputStream, Imaging.ImageFormat.Png) ' img.Save(Server.MapPath("/pyramid3.png"), Imaging.ImageFormat.Png) ' img.Save(pathtofile, Imaging.ImageFormat.Png) ' Response.WriteFile("/pyramid3.png") ' Response.WriteFile(pathtofile) ' Image1.ImageUrl = pathtofile ' Label1.Text = pathtofile ' Response.End()
img.Save(pathtofile, Imaging.ImageFormat.Png) Image1.ImageUrl = "~/images/pyramid3.png" Label1.Text = pathtofile
End Sub
Private Function QBCN(ByVal IRO As String) As Integer
If IRO = "FF000000" Then QBCN = 0 ElseIf IRO = "ff000080" Then QBCN = 1 ElseIf IRO = "ff008000" Then QBCN = 2 ElseIf IRO = "ff008080" Then QBCN = 3 ElseIf IRO = "ff800000" Then QBCN = 4 ElseIf IRO = "ff800080" Then QBCN = 5 ElseIf IRO = "ff808000" Then QBCN = 6 ElseIf IRO = "ffc0c0c0" Then QBCN = 7 ElseIf IRO = "ff808080" Then QBCN = 8 ElseIf IRO = "ff0000ff" Then QBCN = 9 ElseIf IRO = "ff00ff00" Then QBCN = 10 ElseIf IRO = "ff00ffff" Then QBCN = 11 ElseIf IRO = "ffff0000" Then QBCN = 12 ElseIf IRO = "ffff00ff" Then QBCN = 13 ElseIf IRO = "ffffff00" Then QBCN = 14 ElseIf IRO = "ffffffff" Then QBCN = 15 End If Return QBCN
End Function
Sub TAKASALOAD(ByVal Y) For X = 0 To XMAX Dim col1 As New Color col1 = img.GetPixel(X, Y) TAKASA(X) = QBCN(col1.Name) Next End Sub Private Sub OBJECTBYOGA() Dim col1 As New Color Dim i As Integer Dim j As Integer = 1 For i = 1 To 7 col1 = System.Drawing.ColorTranslator.FromOle(QBColor(i)) Dim b As New Drawing2D.LinearGradientBrush(New Point(0 + 25 * (i - j), 0 + 25 * (i - j)), New Point(400 - 25 * (i - j), 400 - 25 * (i - j)), col1, col1) g.FillRectangle(b, 0 + 25 * (i - j), 0 + 25 * (i - j), 400 - 50 * (i - j), 400 - 50 * (i - j)) Next End Sub
デバッグしたところ、
img.Save(.........) でエラーが発生しました。 型 'System.Runtime.InteropServices.ExternalException' の例外が Microsoft.VisualBasic.dll で発生しましたが、ユーザー コード内ではハンドル されませんでした
追加情報:GDI+ で汎用エラーが発生しました。
残念です。
|