Solved

Send Picture With Winsock

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now