ImageBox And PictureBox?

chrisD
01-19-2005, 03:42 PM
I'm trying to make the image smaller about 1/4 the size, I thought I could do this with An image box but it doesn't seem to work. Does anyone have any suggestions?
Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Dim lsrcDc As Long
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.ScaleMode = 3
Picture1.Height = Screen.Height
Picture1.Width = Screen.Width
lsrcDc = GetDC(0)

Winsock1.Bind 1001
Me.Caption = Winsock1.LocalIP
End Sub
Private Sub Form_Unload(Cancel As Integer)
ReleaseDC Me.hwnd, lsrcDc
End Sub

Private Sub Timer1_Timer()
Winsock2.Close
Winsock2.RemoteHost = IP.Text
Winsock2.RemotePort = 1001
Winsock2.SendData lsrcDc
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim tempDc As Long

Winsock1.GetData tempDc, vbLong

Picture1.Cls
BitBlt Picture1.hdc, 0, 0, Screen.Width, Screen.Height, tempDc, 0, 0, vbSrcCopy

SavePicture Picture1.Image, "C:\Image.bmp"

Image1.Picture = LoadPicture("C:\Image.bmp")
End Sub

passel
01-19-2005, 04:31 PM
I guess you could use StretchBlt instead of BitBlt.

zelg37
01-22-2005, 12:39 AM
Since you're saving it to a bitmap (.BMP) file anyway, the LoadImage API would also work. Just resize the picturebox by one quarter and load the bitmap to fit.

Some sample code from the Code Library:
http://www.xtremevbtalk.com/showthread.php?t=20234

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum