从不同来源连接在一起的System.Drawing图像产生不同的结果

问题描述

我有一个项目,根据该值我必须返回与搜索相关的图像,以根据要搜索的图像数量获取所有图像并将它们粘贴为一张图像。

当使用未突出显示的链接来检索图像时,下面放置的功能可以很好地工作,但是当我使用注释掉的源时,不会得到相同的结果。

我分别下载了图像,并且它们的高度和宽度相同-但是我没有得到相同的图像结果。

下载图像信息时唯一可以看到的是水平分辨率不同-这会产生影响吗?为何如此?如果可以,我该如何解决?

如果有人能为我提供任何启示,我将不胜感激。

Private Function GetImageStream(ByVal url As String) As IO.Stream
    Dim client As WebClient = New WebClient()
    Dim stream As Stream = client.OpenRead(url)
    Return stream
End Function

Private Function GenerateImage(ByVal cardlist As List(Of String)) As Stream

    'cardlist
    'cardlist.Add("1_infantry_regiment.jpg")
    'cardlist.Add("5th_brigade.jpg")
    'cardlist.Add("16th_rifles.jpg")

    Dim imagelist As New List(Of Image)
    Dim imagelist1 As New List(Of Image)
    Dim NewImageHeight As Integer
    Dim NewImageWidth As Integer

    For Each card As String In cardlist
        'imagelist.Add(Image.FromStream(GetImageStream("http://167.71.143.162/cardimages/" & card)))
        imagelist.Add(Image.FromStream(GetImageStream("https://playkards.com/public/cards/" & card)))
    Next


    NewImageHeight = imagelist.First.Height
    NewImageWidth = imagelist.First.Width * imagelist.Count

    Dim NewImageBmp As New Bitmap(NewImageWidth,NewImageHeight,Imaging.PixelFormat.Format32bppArgb)
    Dim NewImageGrx As Graphics = System.Drawing.Graphics.FromImage(NewImageBmp)
    Dim PrevImageWidth As Integer = 0

    For Each img As Image In imagelist
        NewImageGrx.DrawImageUnscaled(img,PrevImageWidth,0)
        'NewImageGrx.DrawImageUnscaledAndClipped(img,New Rectangle(PrevImageWidth,NewImageWidth,NewImageHeight))
        PrevImageWidth += img.Width
    Next

    Dim CombineImage As String = Guid.NewGuid().ToString() + ".jpg"

    Dim combinedimage As MemoryStream = New MemoryStream()
    NewImageBmp.Save(combinedimage,ImageFormat.Jpeg)
    ' saving combined image. You can specify the ImageFormat as per your requirment.        

    NewImageBmp.Dispose()
    NewImageGrx.Dispose()

    combinedimage.Position = 0
    Return combinedimage
End Function

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...