Save Image data into a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psnanu
    New Member
    • Sep 2007
    • 3

    Save Image data into a file

    Hi,
    I have an image file and I have to store the image data into an existing file in binary. How do I do this in VB?
    thanks.
  • VBPhilly
    New Member
    • Aug 2007
    • 95

    #2
    Originally posted by psnanu
    Hi,
    I have an image file and I have to store the image data into an existing file in binary. How do I do this in VB?
    thanks.
    the only way I am aware of is not related to a file but uses a sql server database (there is a binary datatype).

    however, try opening the image in a text editor and you should see that it is already in binary format.

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      Open the Image in "Binary File " Mode, Read using "Get" and save in TextFile using "Put"
      Check this :

      [code=vb]
      Dim TStr As String
      Dim FN As Long
      FN = FreeFile
      Open "C:\MyPict. bmp" For Binary Access Read As FN
      Get FN, , TStr
      [/code]

      To Save in TextFile, open text file and use:

      Put FNDest, , TStr

      REgards
      Veena

      Comment

      • psnanu
        New Member
        • Sep 2007
        • 3

        #4
        Thanks Veena.
        Where r u assiging the value for TStr? When that Tsr gets populated?
        Thanks in advance.


        Originally posted by QVeen72
        Hi,

        Open the Image in "Binary File " Mode, Read using "Get" and save in TextFile using "Put"
        Check this :

        [code=vb]
        Dim TStr As String
        Dim FN As Long
        FN = FreeFile
        Open "C:\MyPict. bmp" For Binary Access Read As FN
        Get FN, , TStr
        [/code]

        To Save in TextFile, open text file and use:

        Put FNDest, , TStr

        REgards
        Veena

        Comment

        • molmon
          New Member
          • Jul 2012
          • 1

          #5
          You need to set the string to the length of the input binary file before doing the get, so the get knows how much you want.

          dim lngInputLen as long
          lngInputLen = LOF(FN)
          TStr = String(lngInput Len, " ")
          Get FN, , TStr

          Comment

          Working...