DB 内の画像を含む DB を既に取得しているため、「DB の質問に画像を保存する必要があるかどうか」全体について説明します。ここで言及するのは、他の人がそれについてコメントし、それが最善のアイデアではないことを言及しないことで私にポイントをドッキングすると確信しているためです. できる限りあなたの質問にお答えします。
Web サービスで画像を直接返すことができます。それはかなり簡単です...
これは、あなたができるかどうかを確認するために私が書いた Web サービスのコード スニペットです。うまくいけば、必要に応じて変更できます。
<WebMethod()> _
Public Function GetImage() As Byte()
Try
Dim outStream As New System.IO.MemoryStream
Dim REturnValue As New System.Drawing.Bitmap(500, 500)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(REturnValue)
'g.RotateTransform(5)
Dim f As New System.Drawing.Font(System.Drawing.FontFamily.GenericMonospace, 16, Drawing.FontStyle.Regular, Drawing.GraphicsUnit.Point)
Dim b As System.Drawing.Brush = Drawing.Brushes.Lime
g.DrawString("Hello", f, b, 0, 0)
g.DrawString("Would you like to play a game? (Y/N)", f, b, 0, 40)
g.DrawString("> Y", f, b, 0, 80)
g.DrawString("Loading Global Thermonuclear War,", f, b, 0, 120)
g.DrawString("please wait...", f, b, 0, 160)
REturnValue.Save(outStream, System.Drawing.Imaging.ImageFormat.Jpeg)
Return outStream.ToArray()
Catch ex As Exception
Throw New Exception(ex.ToString())
End Try
End Function
そして、画像を表示するAsp.Netページ..
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ts As New TestServices
Dim b As System.Drawing.Bitmap
Dim bytes As Byte()
Dim inStream As System.IO.MemoryStream
bytes = ts.GetImage()
inStream = New System.IO.MemoryStream(bytes)
b = New System.Drawing.Bitmap(inStream)
Response.ContentType = "image/jpeg"
b.Save(Response.OutputStream, b.RawFormat)
b.Dispose()
End Sub