0

因此,我的任务是将网站迁移到共享环境,该环境不允许安装前 3 位开发人员使用的第 3 方软件。我需要做的是从 GIF 的一个子集创建一个图像并从一个 asp 页面返回它。这是我当前的代码:

原始页面将其称为:

<p align="center"><img src="/code.asp"></p>

code.asp页面如下:

<%
Path = Server.MapPath("/images")
CodePath = Server.MapPath("/images/codes")
Dim test As System.Drawing.Image
Dim strWord As String
Dim nWidth = 0
Dim nHeight = 0
Dim strLetter as String
Dim imgpath As String
Dim imgpathnext As String
Dim nX As Integer
    Dim binary As String

    strWord = "OhYeah"

if len(strWord) = 0 then
    strWord = "fjkuypd"
end if

nX = 1
strLetter = lcase(mid(strWord,nX,1))
imgpath = Path & "\letter_" & strLetter & ".gif"
for nX = 2 to len(strWord)

    If(nX = 2)
        strLetter = lcase(mid(strWord,nX,1))
        imgpathnext = Path & "\letter_" & strLetter & ".gif"
        test = MergeImages(System.Drawing.Image.FromFile(imgpath),System.Drawing.Image.FromFile(imgpathnext))
        Continue For
    End If
    strLetter = lcase(mid(strWord,nX,1))
    imgpathnext = Path & "\letter_" & strLetter & ".gif"
    test = MergeImages(test,System.Drawing.Image.FromFile(imgpathnext))             
next

    binary = ImageConversion(test)                
    Response.Clear
    Response.ContentType = "image/jpeg"
    Response.BinaryWrite(binary)


 Public Function ImageConversion(ByVal image As System.Drawing.Image) As String
    If image Is Nothing Then Return ""
    Dim memoryStream As System.IO.MemoryStream = New System.IO.MemoryStream
    image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif)
    Dim value As String = ""
    For intCnt As Integer = 0 To memoryStream.ToArray.Length - 1
        value = value & memoryStream.ToArray(intCnt) & ","
    Next
    Return value
End Function

Public Function MergeImages(ByVal Pic1 As System.Drawing.Image, ByVal pic2 As    System.Drawing.Image) As System.Drawing.Image

Dim MergedImage As System.Drawing.Image ‘ This will be the finished merged image

Dim Wide, High As Integer 
Wide = Pic1.Width + pic2.Width

   If Pic1.Height >= pic2.Height Then
     High = Pic1.Height
   Else
     High = pic2.Height
   End If

Dim bm As New Bitmap(Wide, High)
Dim gr As Graphics = Graphics.FromImage(bm)

gr.DrawRectangle(Pens.Black, 0, 0, Wide - 1, High - 1)
gr.DrawImage(Pic1, 0, 0)
gr.DrawImage(pic2, Pic1.Width, 0)

MergedImage = bm

gr.Dispose()
Return MergedImage

End Function

%>

我得到的只是一个红色的 X。对此的任何帮助将不胜感激。

4

0 回答 0