If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

[win32] Send bitmap over socket

I want to send a bitmap over socket, however since I kinda work with bitmaps for the first time, I dont really have an idea how to do that, so far I have code that gets the screenshot of the screen and stores it to HBITMAP (works fine), then fills BITMAPINFO struct and then creates a BYTE buffer from that struct, so I can send it via socket and then somehow (i still dont know how) recreate the bitmap using the BYTE buffer I created

Re: [win32] Send bitmap over socket

Originally Posted by DaigonoYouso

I want to send a bitmap over socket, however since I kinda work with bitmaps for the first time,

Then you should be attempting to save the bitmap to a file, and then attempt to read it back. You don't need to add complexity by introducing sockets. Saving and reading from a file is essentially all you're doing, and the socket stuff is just another way of saving/reading. If you can successfully save the bitmap to a file in one program, and have another program attempt to read the file you just saved and display the bitmap, then you basically have the problem solved.

There are a huge number of examples of saving and reading bitmaps, as this is a common functionality of Windows image processing. Please do a google search and you can't miss them.

Re: [win32] Send bitmap over socket

Originally Posted by Paul McKenzie

Then you should be attempting to save the bitmap to a file, and then attempt to read it back. You don't need to add complexity by introducing sockets. Saving and reading from a file is essentially all you're doing, and the socket stuff is just another way of saving/reading.

There are a huge number of examples of saving and reading bitmaps, as this is a common functionality of Windows image processing. Please do a google search and you can't miss them.

Re: [win32] Send bitmap over socket

Originally Posted by DaigonoYouso

but I want to send the bitmap over socket, not to save it ...

So where is the problem with the socket? I didn't see anything in your first post where you were having a problem with the socket. The act of saving and reading to a file is no different than what you're doing with a socket.

You're concentrating on the means of getting a bitmap from point A to point B. That isn't what you're having a problem with -- your problem is purely an error with putting together data to save to a file, send over a socket, whatever. That's why if you can save the data to a file and read it back, then all you need to do after that is send that very same data to a socket, and have the other side read it back and put together the bitmap.

If you can't save the data to a file, then you can't send the data over a socket. So that's why you should concentrate on saving to a file, as there are thousands, if not millions of examples of saving to a file. Once you learn that, you take those very same bytes you used to save to a file, and just send them over the socket.

Re: [win32] Send bitmap over socket

Originally Posted by Paul McKenzie

So where is the problem with the socket? I didn't see anything in your first post where you were having a problem with the socket. The act of saving and reading to a file is no different than what you're doing with a socket.

You're concentrating on the means of getting a bitmap from point A to point B. That isn't what you're having a problem with -- your problem is purely an error with putting together data to save to a file, send over a socket, whatever. That's why if you can save the data to a file and read it back, then all you need to do after that is send that very same data to a socket, and have the other side read it back and put together the bitmap.

that is why I'm trying to get the bitmap info to BITMAPINFO struct and then to buffer, using GetDIBits function, which is unfortunatelly giving me an error

Re: [win32] Send bitmap over socket

Originally Posted by DaigonoYouso

that is why I'm trying to get the bitmap info to BITMAPINFO struct and then to buffer, using GetDIBits function, which is unfortunatelly giving me an error

Then again, take one of the many examples of saving HBITMAP data, compile it, run it. Once you have that working, you just change the code from doing file writing to "socket sending". Saving HBITMAP's to a file is one of the examples you can't miss if you do a google search -- again this is a fundamental of Windows bitmap processing.

Re: [win32] Send bitmap over socket

Originally Posted by DaigonoYouso

1. is there a way to "WriteFile" those 2 things at ONCE?

But how would the receiver know what is data and what is header information? You will need to send one item at a time, unless you have a way to inform the receiver that the data sent is header as opposed to the bitmap info data.

2. how do I recreate the bitmap?

Look at code that reads a bitmap from a file and recreates the HBITMAP by reading the header and data.

3. WriteFile sends a packets via socket? (I know it can accept a socket handle, but I dont know if it sends it or what does it do with it?)

Re: [win32] Send bitmap over socket

Originally Posted by DaigonoYouso

the way you reply,

And what is "the way"? You asked a question, I answered it. What are you expecting as a reply?

Where in any of my responses do you see violence even suggested against you? I even took the time to show you where your memory leak was and how to fix it. Do you still want to "punch in the face with a chair"?

I didnt threat you nor harassed you in any way

Punching in face with a chair -- ok, that is not harassment or threatening.

And you expect others to help you with the likelihood of being given a response like that?

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.