Solved

Send Picture With Winsock

Posted on 2004-08-06
4
441 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 125 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

749 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