Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Send Picture With Winsock

Posted on 2004-08-06
4
Medium Priority
?
451 Views
Last Modified: 2013-11-13
I am trying to send a picture through winsock very fast and its a big picture bigger than 800 x 600 ive tryed sending pixel by pixel but that takes very long ive tryed using this...


Private Function PictureBitsGet(ByRef objPicBox As PictureBox, ByRef bytBits() As Byte) As Boolean
    Dim typBMP As BITMAP, lngSize As Long
    If GetObject(objPicBox.Image, Len(typBMP), typBMP) <> 0 Then
        lngSize = ((typBMP.bmWidth * 3 + 3) And &HFFFFFFFC)
        lngSize = lngSize * typBMP.bmHeight * 3
        ReDim bytBits(1 To lngSize) As Byte
        If GetBitmapBits(objPicBox.Image, UBound(bytBits), bytBits(1)) <> 0 Then
            PictureBitsGet = True
        End If
    End If
End Function
Private Function PictureBitsSet(ByRef objPicBox As PictureBox, ByRef bytBits() As Byte) As Boolean
    If SetBitmapBits(objPicBox.Image, UBound(bytBits), bytBits(1)) <> 0 Then
        PictureBitsSet = True
        Call objPicBox.Refresh
    End If
End Function



and ive tryed saving it then sending the file the sending part only takes 1/10 of a second but the problem is it takes to long to save and load the picture. What im asking for and just an idea of how to send the picture very very fast lke under a 1/2 of a second would be nice but im out of ideas of how to do it. thanks, ricky
0
Comment
Question by:Rickyman45
  • 3
4 Comments
 
LVL 17

Expert Comment

by:inthedark
ID: 11741956
You could either use compression, but what you need is a routine that will create a JPG or GIF which is a compressed image.  This will save you time at the other end as you can deploy the image in a shorter time.  There is some code to create the JPG in memory. You don;t want to save the image as this will kickoff your virus scanner etc. and will take time and resources.

GIF can make a better job of compressions, but in some cases JPG is better it just dependson the picture.  The problem with GIF is that it is that the code for the process is copywritten and it is hard to find code.  Using any GIF code you find would be ilegal. So you need to concentrate on finding JPG code.  Another way to go would be to use compression, but finding good in-memory compressions is not going to be easy.  You can use code like zlib, but this code can't be used on a server as it is too slow and does not have enough doevents in the code.
0
 
LVL 17

Accepted Solution

by:
inthedark earned 500 total points
ID: 11741958
You may find the code you need here:

http://vbaccelerator.com/codelib/gfx/vbjpeg.htm
0
 
LVL 17

Expert Comment

by:inthedark
ID: 11742014
It creates a JPG but only has an option to save to disk. But the DLL seems to have an in memory option...

IJL_JBUFF_WRITEWHOLEIMAGE searching this on google gives this.

http://www.google.com/search?hl=en&ie=UTF-8&q=IJL_JBUFF_WRITEWHOLEIMAGE&btnG=Google+Search

So not a lot of help....but at least you can try a quick save then transmit.
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11742259
You can directly load the picture to memory to a byte array (using GetDIBBits) and then send it... then after the other side receives it you just put it back to DIB (device independent bitmap) and do with it whatever you want

Darko
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question