C# Windows application (GUI) Displaying a JPEG

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anwarv
    New Member
    • Mar 2008
    • 2

    C# Windows application (GUI) Displaying a JPEG

    Hi Guys

    I am a newbie to C#. I have a camera that sends me jpeg data in 500byte packets via the serial port. The encoding and compression is already done on the camera. The data is pure compressed jpeg. I simply want to receive this data via serial port and display the picture in a picture box. Receiving the data is not the problem as I understand the serial port class. Its how to display the data that I have no clue about. I would appreciate the simplest manner posssible plz

    Thank you
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I think what you would need is to use the Bitmap object (yes I know it seems like it is for BMP but it handles all image types)
    You can create a Bitmap object from a byte stream (use MemoryStream on your completed collection of bytes from the serial port) and then you should be able to set that object to a PictureBox control or some other control.

    Comment

    • anwarv
      New Member
      • Mar 2008
      • 2

      #3
      I was thinkink about using filestream. However I was not sure If this can be used for jpg files as all the examples I have seen involve txt files

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Well if the picture data you are getting is a complete jpeg data (header and all that good stuff), then a filestream would be fine. You could write the data bytes to the filestream (create a temp.jpg?) and then show it in your form.

        I wasn't sure if you wanted to go the temp file route.


        Actually, I suppose you could write a lot of jpeg files and just append the date/time to the filenames and create as many as you wanted.

        Comment

        Working...