CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2001
    Location
    Islamabad , QAU,Pakistan
    Posts
    61

    Question converting binary to image data

    I am catching some real time snaps from camera which is connected through com port. I am able to interact with camera and getting data using camera api. Thing is that I need to display image in picture box. The image information I am getting comes in a string variable. Definitly that string contains binary data ( unreadable).

    I don't know how to convert this string to image. Once this binary string is converted then it will be easy to display in picture box.

    Can anybody tell me, how can I convert this binary string to image file...???

    Thanks in advance :

  2. #2
    Join Date
    Jan 2006
    Posts
    293

  3. #3
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: converting binary to image data

    the code in post may give u some ideas..

  4. #4
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Re: converting binary to image data

    Do you know the exact format of the data being retrieved? The native image classes are very picky that you use well-formed image data, and a string is generally not well formed image data.
    Last edited by Craig Gemmill; March 10th, 2006 at 03:04 PM. Reason: Wording.
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  5. #5
    Join Date
    Nov 2001
    Location
    Islamabad , QAU,Pakistan
    Posts
    61

    Question Re: converting binary to image data

    Hi Gemmill

    The data is in unreadable format. As Unmanaged Structure I am using is to hold image data from camera that is why I suppose that it is image data. The actual structure member (written in VC++) returns void* data. As I am using it from VB.NET, it is providing me in the format of string.... But data is totally unreadable.

    Any clue about that..

    Regards

    Imran

  6. #6
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: converting binary to image data

    Yeah, see the problem is that if you don't know the data format, you can't really do anything with that data (unless you guess obviously). So, do you know if it's JPEG, BMP, RAW, TIFF, etc.?

    Better yet, can you take a picture using the smallest resolution possible, then paste the contents of the string value to a text file, zip it, and post it here?
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  7. #7
    Join Date
    Nov 2001
    Location
    Islamabad , QAU,Pakistan
    Posts
    61

    Question Re: converting binary to image data

    Hi Gemmill

    I have saved that string in txt file and file is attached here named 112.txt. Please have a look at it. Thing is that the liberary i am using supports bmp and tiff format. So it could be one of them.

    bundle of thanks

    Regards

    Imran
    Attached Files Attached Files

  8. #8
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: converting binary to image data

    I forgot to ask you, you mentioned that the image data is a structure member. Are there any more member in that structure?
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  9. #9
    Join Date
    Nov 2001
    Location
    Islamabad , QAU,Pakistan
    Posts
    61

    Question Re: converting binary to image data

    Yes

    This is the structure.

    Public Structure TDICLibImageInformation
    Public data As String
    Public dataLength As Integer
    Public width As Integer
    Public height As Integer
    Public pixelSize As Integer
    Public pitch As Integer
    Public roiX0 As Integer
    Public roiX1 As Integer
    Public pixelType As integer
    End Structure

    I am able to get datalength. Similary

    width = 64
    height = 1510

    this mean i am getting frame of size 1510*64

    regards

    imran

  10. #10
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Re: converting binary to image data

    Is that right? 64x1510 seems a little weird.

    Do you have any documentation on the data you are receiving?
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  11. #11
    Join Date
    Nov 2001
    Location
    Islamabad , QAU,Pakistan
    Posts
    61

    Question Re: converting binary to image data

    YES

    ACCORDING TO CAMERA DOCUMENTATION THIS SIZE (64*1510) IS OK.

    It is the resolution of camera. This thing is confirmed that i have received right data.

    actual thing is how to convert it to image to display in picture box ????????????????

    Regards

    Imran

  12. #12
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: converting binary to image data

    Ok... look, we need all the info you have. We have no idea what you are working with here, so if you have more information, it will only help us help you. Otherwise we are wildy guessing.

    What are the rest of the values of the members in that structure?

    Again, any documentation?
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured