Nov 10, 2019 10:08 AM
(This post was last modified: Nov 10, 2019 10:08 AM by SIM-3437924.)
So basically I've been trying to send a HBITMAP over winsock to another application that's going to paint the bitmap onto the applications screen. Obviously you can't just send any sort of handle over a socket and winsock takes a const char* parameter. I found a solution on stackoverflow but it's just been playing with my mind and I can't seem to get it working. If anyone could post a solution or an example I would be very grateful.
Here the stackoverflow link I mentioned.
c++ - HBITMAP/BITMAP to BITMAPINFOHEADER -> over network - > BITMAPINFOHEADER to HBITMAP/BITMAP - Stack Overflow
if you know how to send unsigned char pointer and read write file then its simple as writing your thread
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Nov 10, 2019 10:17 AM)HFDone Wrote: if you know how to send unsigned char pointer and read write file then its simple as writing your thread
Can you give an example? Wouldn't you have to send width, height, bitmapinfo, and then covert hbitmap to bitmap, then bitmap to bits etc etc etc... And that doesn't even cover how you would receive it and convert the bits back to hbitmap. I'm not sure it's as simple as you say but I don't know tho.
DO NOT DEAL WITH THIS MEMBER
(Nov 10, 2019 10:24 AM)SIM-3437924 Wrote: Can you give an example? Wouldn't you have to send width, height, bitmapinfo, and then covert hbitmap to bitmap, then bitmap to bits etc etc etc... And that doesn't even cover how you would receive it and convert the bits back to hbitmap. I'm not sure it's as simple as you say but I don't know tho.
No why would you need to do all of that? Read the handle into a buffer and send the buffer along with the size of the buffer. Then write it back to file on the other end. Not that complicated.
Nov 10, 2019 02:13 PM
(This post was last modified: Nov 10, 2019 02:55 PM by SIM-3437924.)
(Nov 10, 2019 12:38 PM)YouthInAsia Wrote: No why would you need to do all of that? Read the handle into a buffer and send the buffer along with the size of the buffer. Then write it back to file on the other end. Not that complicated.
A handle is only useful to the computer that it was created in. It refrences data in memory so if you were to send the handle across a socket to another computer there would be nothing in memory for the handle to refrence. Also on the recieving end I am trying to convert the buffer back to a hbitmap without writing anything to disk.
EDIT: oops! " read the handle into a buffer", sorry I read too fast.
he said "Read the handle into a buffer"
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
Nov 10, 2019 02:20 PM
(This post was last modified: Nov 10, 2019 02:24 PM by SIM-3437924.)
(Nov 10, 2019 02:14 PM)HFDone Wrote: he said "Read the handle into a buffer"
Ok, how should I read handle to buffer. and after i send it along with the buffer size, how do I convert back to hbitmap?
Nov 10, 2019 02:30 PM
(This post was last modified: Nov 10, 2019 02:30 PM by malpwn.)
(Nov 10, 2019 02:20 PM)SIM-3437924 Wrote: Ok, how should I read handle to buffer. and after i send it along with the buffer size, how do I convert back to hbitmap?
To construct it again use CreateBitMap()
DO NOT DEAL WITH THIS MEMBER
Nov 10, 2019 02:35 PM
(This post was last modified: Nov 10, 2019 02:36 PM by YouthInAsia.)
(Nov 10, 2019 02:13 PM)SIM-3437924 Wrote: A handle is only useful to the computer that it was created in. It refrences data in memory so if you were to send the handle across a socket to another computer there would be nothing in memory for the handle to refrence. Also on the recieving end I am trying to convert the buffer back to a hbitmap without writing anything to disk.
Are you retarded? Did you read nothing of what I said. You're clearly lacking reading comprehension. When did I ever say send the handle over a socket? I said READ THE HANDLE INTO A BUFFER AND SEND THE BUFFER
(Nov 10, 2019 02:30 PM)malpwn Wrote: To construct it again use CreateBitMap()
True but if all he wants is to write it to a file he might not even need to reconstruct the bitmap. I assume his goal is to just send the bitmap and write it to file.
Nov 10, 2019 02:45 PM
(This post was last modified: Nov 10, 2019 02:47 PM by malpwn.)
(Nov 10, 2019 02:20 PM)SIM-3437924 Wrote: Ok, how should I read handle to buffer. and after i send it along with the buffer size, how do I convert back to hbitmap?
(Nov 10, 2019 02:35 PM)YouthInAsia Wrote: True but if all he wants is to write it to a file he might not even need to reconstruct the bitmap. I assume his goal is to just send the bitmap and write it to file.
Considering he asked how to convert it back to hbitmap ✌
Besides this is not so hard task I suggest OP can take over this now we have done nuff
Nov 10, 2019 02:46 PM
(This post was last modified: Nov 10, 2019 02:49 PM by SIM-3437924.)
(Nov 10, 2019 02:35 PM)YouthInAsia Wrote: Are you retarded? Did you read nothing of what I said. You're clearly lacking reading comprehension. When did I ever say send the handle over a socket? I said READ THE HANDLE INTO A BUFFER AND SEND THE BUFFER
True but if all he wants is to write it to a file he might not even need to reconstruct the bitmap. I assume his goal is to just send the bitmap and write it to file.
You're a hypocrite. Read what I told you "Also on the recieving end I am trying to convert the buffer back to a hbitmap without writing anything to disk."
(Nov 10, 2019 02:30 PM)malpwn Wrote: To construct it again use CreateBitMap()
Thank you.
DO NOT DEAL WITH THIS MEMBER
(Nov 10, 2019 02:46 PM)SIM-3437924 Wrote: You're a hypocrite. Read what I told you "Also on the recieving end I am trying to convert the buffer back to a hbitmap without writing anything to disk."
Thank you.
THat's not reading miscomprehension thats me getting pissed off at your stupidity to finish your entire post. I'm not a hypocrite because I can actually understand, do I want to read your nonsense? No fuck you
|