|
-
May 8th, 2002, 05:37 PM
#1
Thread Starter
Junior Member
Putting a picture into a string and resizing.
Hello
I want to capture the screen, then resize the image and then put it into a string (because i must send the picture through winsock to another pc)
I can capture the screen.
But by resizing and putting it into a string i'm having troubles.
I've got already a little bit code but the function StretchBlt won't put data into the variable "HdcOut".
Code:
'//api
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
'//code
Public Sub GetDesktop()
Dim dhandle As Long
Dim HdcOut As Long
dhandle = GetDesktopWindow
Dim ddc As Long
ddc = GetDC(dhandle)
StretchBlt HdcOut, 0, 0, 640, 480, ddc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, vbSrcCopy
End Sub
thanks!!
-
May 8th, 2002, 05:52 PM
#2
I think your going to have to use a byte array to send the data, you can't put a picture in a string.....at least I don't think you can...
-
May 8th, 2002, 06:03 PM
#3
PowerPoster
Originally posted by hellswraith
I think your going to have to use a byte array to send the data, you can't put a picture in a string.....at least I don't think you can...
You can if you convert the bytes to ASCII characters.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Oct 4th, 2002, 06:02 AM
#4
Addicted Member
hey any one of u can tell abt how to convert a picture from picture box to Byte array .. i want to send these byte array data to another PC .. any one suggest on this ??
-
Jan 20th, 2003, 06:06 AM
#5
Fanatic Member
same prob
hey,
i got the same prob as this, i have always needed to send a picture using winsock, WITHOUT SAVING THE PIC TO FILE.
but, I havnt been able to.
There is also the prob about size too.
If i knew how you could change a picture into a string, that wud be fantastic. Would also help if there is a way to reduce its quality/size too, to make it transfer quicker!
This is just wat i need, aswell as the thread starter, why hasnt anyone go further with this thread?
I would also appreciate any responses to this!
Thanks,
-
Jan 20th, 2003, 07:26 AM
#6
Have a look at this site
It has some sample code to convert a picture to and from a byte array.
-
Jan 20th, 2003, 07:35 AM
#7
Fanatic Member
thanks
thanks frans c, looks like a good website, ill take a look in a min and tell ya what i think and if it helps,
thanks in advanced 
1 min lata (edited)
looks good, thanks for the code, ill try the code lata in my prog
-
Jan 21st, 2003, 01:07 AM
#8
Addicted Member
surely its good code to convert pictures , but how u r going to transfer it on winsock .. i think data transmits in form of string on winsock .. how can we transmit byte array ?
one more way to convert picture data in strings through Serialization .. i m not much sure of it but i m working on it , and also i hv to check if after serialization i could unserialize to get it back in picture object or any other format from which it was converted .. hopefuly if i suceed i will let u know ...
-
Jan 21st, 2003, 06:10 AM
#9
Fanatic Member
that code is way too advanced for what i need, and it doesnt work anyway, not for what i want anyway!
and yea, how are u supposed to transfer a byte array? didnt we say about strings, not byte arrays. peeps today dont listen
-
Jan 21st, 2003, 07:45 AM
#10
Winsock has no problem with byte arrays (just press F1 on SendData), and converting a byte array to a string is so easy, that I assumed it was common knowledge.
MyString = MyByteArray
Or if like your strings in unicode (will double the size though):
MyString = StrConv(MyByteArray, vbUnicode)
If you don't like advanced code, just save it to a file first, and then read it back in a string.
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
|