Link to home
Create AccountLog in
Visual Basic Classic

Visual Basic Classic

--

Questions

--

Followers

Top Experts

Avatar of Tom_Hickerson
Tom_Hickerson🇺🇸

DIsplaying JPG stream or binary JPG in VB6
I am converting vb.net program that displays images from an IP camera.  So far I can retieve the data that is the picture, but can't figure out how to make VB turn it into a JPG.  The data for the image looks like this when displayed in a text box (see below).  From what the camera people say it is a JPEG bit stream.  I have also read somewhere that this is a binary JPG.  How can I display it in my vb6 app?

ÿØÿâñãYÔãxð­±" =©t«Ôc3ÚaIõÉ416!¦ó~xÇJ ÇüÔÔûÍI¬þiy¡+âæÜ~û})½D8`NüÐÜ      ÐFûËOpÜ^ø£¨¤îÓXѰ xº09¦âìþT&s¬j"­¨×áXErISÂÈ:­h"®a×:RÐdmÊ=AQ²õë@
+"éÏO­!?¿¥æ>{'ST,vºµ$À²§sñQK# !êM7 È9¶G<
¹f~fOÄSÝ./J)B$Ö<`@&ϯJ\Ð19Í!lÑp[t,=EmXÚ}¹ÿ&4 ¿Û¥5"/îZÞØù|Í'É÷=ê¥ïú"x>d¿<­ßüó@É4h3#Nz(Úµ¯LCó¯Ö¢¿Æ½’£
;`ñW¨ÚeçÚôØ%cûÅ]þðâ¥Ó½u-ÆcFA$°û¾cþï§Ò²Öhv<F
8k`ÅØxëOE,ÜdÕ Øè¬âò! üG©«KËzÑÖðìþt²«FJ䨡5gY½ ûO±h}Æ!ÒSxa3}ÕÛ"¦[pÓ¿²ÔaÃ9=6=>"¤1&bÆe[Âe"#Q÷¿"tè8Ö4ÆÕàU!’×0SÜ ûÓÏô¦ô¹£­ ~¾µ$_ëÞ:+ÄÈL6}q¸6>"R
̤sRQ}h¸ÇE1öÅ-4´¬/Ó¥Ýè4
Here is the code vb.net uses to decode the file.  Is there a way to do this vb6?
 
'this converting is not necessary
                    ' you can just set break here and see what data you're receiving
                    Dim str2 As String = encoding.GetString(bytes2)
 
                    ' read jpeg data
                    Dim bytesFrame(lenFrame) As Byte
                    len1 = 0
                    Do While len1 < lenFrame
                        len1 = len1 + Stream.Read(bytesFrame, len1, lenFrame - len1)
                    Loop
                    'convert data do image
                    Dim imageStream As MemoryStream = New MemoryStream(bytesFrame)
                    imageStream.Position = 0
                    Dim img As Image = New Bitmap(imageStream)
                    'display
                    PictureBox1.Image = img
                    PictureBox1.Refresh()

Open in new window

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Shahid ThaikaShahid Thaika🇮🇳

Please check the following link for a potential solution...

http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=43966

Avatar of Tom_HickersonTom_Hickerson🇺🇸

ASKER

Thanks for the link.  Unfotunatly that is for vb.net, and I need vb6

If you can get the binary image data, why don't you simply try writing it to a file in your local hard disk and loading it in a picture control. I am not sure if there is any other way.

FileName = "C:\Path\..\mypic.jpg"
Open FileName For Binary as #1
Put #1, , StreamData
Close #1
Picture1.Picture = LoadPicture(FileName)

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


ASKER CERTIFIED SOLUTION
Avatar of ArkArk🇷🇺

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account
Visual Basic Classic

Visual Basic Classic

--

Questions

--

Followers

Top Experts

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.