OSDN Git Service

アイコン取得がおかしくなるのを修正
authorsyo68k <syo68k@users.sourceforge.jp>
Wed, 29 Sep 2010 15:26:50 +0000 (15:26 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:15:38 +0000 (23:15 +0900)
git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@919 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/Connection/HttpVarious.vb
Tween/Twitter.vb

index 9de1638..3138020 100644 (file)
@@ -42,6 +42,16 @@ Public Class HttpVarious
     End Function
 
     Public Overloads Function GetImage(ByVal url As String, ByVal referer As String, ByVal timeout As Integer, ByRef errmsg As String) As Image
+        Return GetImageInternal(AddressOf CheckValidImage, url, referer, timeout, errmsg)
+    End Function
+
+    Public Function GetIconImage(ByVal url As String, ByVal timeout As Integer) As Image
+        Return GetImageInternal(AddressOf CheckValidIconImage, url, "", timeout, Nothing)
+    End Function
+
+    Private Delegate Function CheckValidImageDelegate(ByVal img As Image, ByVal width As Integer, ByVal height As Integer) As Image
+
+    Private Overloads Function GetImageInternal(ByVal CheckImage As CheckValidImageDelegate, ByVal url As String, ByVal referer As String, ByVal timeout As Integer, ByRef errmsg As String) As Image
         Try
             Dim req As HttpWebRequest = CreateRequest(GetMethod, New Uri(url), Nothing, False)
             If Not String.IsNullOrEmpty(referer) Then req.Referer = referer
@@ -60,7 +70,7 @@ Public Class HttpVarious
                 End If
             End If
             If img IsNot Nothing Then img.Tag = url
-            If ret = HttpStatusCode.OK Then Return CheckValidImage(img, img.Width, img.Height)
+            If ret = HttpStatusCode.OK Then Return CheckImage(img, img.Width, img.Height)
             Return Nothing
         Catch ex As WebException
             If errmsg IsNot Nothing Then
@@ -151,7 +161,7 @@ Public Class HttpVarious
         End Try
     End Function
 
-    Public Overloads Function CheckValidImage(ByVal img As Image) As Image
+    Private Function CheckValidIconImage(ByVal img As Image, ByVal width As Integer, ByVal height As Integer) As Image
         Return CheckValidImage(img, 48, 48)
     End Function
 
@@ -161,7 +171,8 @@ Public Class HttpVarious
         Dim bmp As New Bitmap(width, height)
         Dim tag As Object = img.Tag
         Using g As Graphics = Graphics.FromImage(bmp)
-            g.InterpolationMode = Drawing2D.InterpolationMode.High
+            g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
+            g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
             g.DrawImage(img, 0, 0, width, height)
         End Using
         img.Dispose()
index 9301c40..022c6e3 100644 (file)
@@ -247,7 +247,7 @@ Public Class Twitter
             End If
 
             Dim httpVar As New HttpVarious
-            img = httpVar.GetImage(post.ImageUrl, 10000)
+            img = httpVar.GetIconImage(post.ImageUrl, 10000)
             If img Is Nothing Then
                 TabInformations.GetInstance.AddPost(post)
                 Exit Sub