Solved

Send Picture With Winsock

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

856 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