Solved

Send Picture With Winsock

Posted on 2004-08-06
4
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

630 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