-
Sep 1st, 2023, 02:11 AM
#1
Thread Starter
PowerPoster
VB6 Download image and automatically center in Picture1 control
Download the image and automatically center it in the Picture1 control
'References to:
'
' Microsoft Windows Image Acquisition Library v2.0
' Microsoft WinHTTP Services, version 5.1
Code:
Function ShowWebIMG_WIA(imgURL As String, Picture1 As PictureBox)
Dim Vector As WIA.Vector
Picture1.BorderStyle = 0
Picture1.ScaleMode = 3 'pix
Picture1.AutoRedraw = True
With New WinHttp.WinHttpRequest
.Open "GET", imgURL, Async:=True
.Send
.WaitForResponse
Set Vector = New WIA.Vector
Vector.BinaryData = .ResponseBody
End With
With Vector.ImageFile
Dim ip As WIA.ImageProcess
Set ip = CreateObject("WIA.ImageProcess")
ip.Filters.Add ip.FilterInfos("Scale").FilterID
ip.Filters(1).Properties("MaximumWidth") = Picture1.ScaleWidth
ip.Filters(1).Properties("MaximumHeight") = Picture1.ScaleHeight
Dim IMG2 As WIA.ImageFile
Set IMG2 = CreateObject("WIA.ImageFile")
Set IMG2 = ip.Apply(Vector.ImageFile)
Vector.BinaryData = IMG2.FileData.BinaryData
End With
Dim MemPicture As IPictureDisp
Set MemPicture = Vector.Picture
With MemPicture
'.Render Picture1.hDC, (Picture1.ScaleWidth - IMG2.Width) / 2, (Picture1.ScaleHeight - IMG2.Height) / 2, IMG2.Width, IMG2.Height, 0, 0, .Width, .Height, 0 'GOOD1
.Render Picture1.hDC, (Picture1.ScaleWidth - IMG2.Width) / 2, IMG2.Height + (Picture1.ScaleHeight - IMG2.Height) / 2, IMG2.Width, -IMG2.Height, 0, 0, .Width, .Height, 0 'GOOD1
End With
Picture1.Refresh
End Function
Private Sub Command1_Click()
ShowWebIMG_WIA "https://mbdp01.bdstatic.com/static/landing-pc/img/logo_top.79fdb8c2.png", Me.Picture1
End Sub
-
Sep 2nd, 2023, 11:25 PM
#2
Lively Member
Re: VB6 Download image and automatically center in Picture1 control
'// Off topic:
I lived in China / Hong Kong for 15 years.
I'm a native English speaker, so I understand how hard it is to communicate logic or emotions properly.
Putonghua or Cantonese, using Google or Baidu never seems to get the information right!
I'm sure AI will bring us all closer together with proper translation. e/acc
Where are you from? Everywhere in Asia holds so much beauty.
I want all of us to know each other better, and I realize some here might not understand your
goodwill hand reaching out for communication, (伸出善意之手进行沟通)
And I think that is their loss, not yours. Cheers
-
Sep 3rd, 2023, 05:39 AM
#3
Thread Starter
PowerPoster
Re: VB6 Download image and automatically center in Picture1 control
 Originally Posted by taishan
I lived in China / Hong Kong for 15 years.
I'm a native English speaker, so I understand how hard it is to communicate logic or emotions properly.
Putonghua or Cantonese, using Google or Baidu never seems to get the information right!
I'm in Hengdian World Studios, near Yiwu Commodity City, Zhejiang Province.
The world economy is connected, but the United States has been suppressing China's high-tech (5G, chip code, etc.), really not easy.
Now many of China's foundry business has been transferred to India and other countries, China's labor costs are also rising, mainly because the housing price is too high. This is also the reason why Japanese housing prices collapsed and the economy fell back by 30 years.
Hong Kong is too small, too many people, and housing prices have become sky-high. Many people live in very small houses. Like thousands of rabbits living in a single room.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|