Save image to file from memory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerry Spence1

    Save image to file from memory

    I am using a network camera that saves the image in a byte array in memory
    (via their ocx component, and in the OnNewImage event I can get the pointer
    to the image and the byte length as
    e.lFrmBytes

    e.lPtrToImage

    How do I get at that array in memory and save it to disk? It seems to
    suggest a pointer which is not supported in VB.

    -Jerry



  • Cor Ligthert[MVP]

    #2
    Re: Save image to file from memory

    Jerry,

    For sure you can use in VB Image.Save, there are no Net classes wich are not
    supported in VB for Net

    Cor




    "Jerry Spence1" <jerry.spence@s omewhere.co.uks chreef in bericht
    news:NP6dnYOgTb uOmL7VnZ2dnUVZ8 q6onZ2d@plusnet ...
    >I am using a network camera that saves the image in a byte array in memory
    >(via their ocx component, and in the OnNewImage event I can get the pointer
    >to the image and the byte length as
    e.lFrmBytes
    >
    e.lPtrToImage
    >
    How do I get at that array in memory and save it to disk? It seems to
    suggest a pointer which is not supported in VB.
    >
    -Jerry
    >
    >
    >

    Comment

    • kimiraikkonen

      #3
      Re: Save image to file from memory

      On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@s omewhere.co.uk>
      wrote:
      I am using a network camera that saves the image in a byte array in memory
      (via their ocx component, and in the OnNewImage event I can get the pointer
      to the image and the byte length as
      e.lFrmBytes
      >
      e.lPtrToImage
      >
      How do I get at that array in memory and save it to disk? It seems to
      suggest a pointer which is not supported in VB.
      >
      -Jerry
      Hi Jerry,
      If you're able to copy image to clipboard (memory), you can simply
      retrieve it into a picturebox and save by using save method. First
      make sure image is copied to clipboard.

      ' To get image from clipboard
      PictureBox1.Ima ge = Clipboard.GetIm age

      ' Then save image with a proper path
      PictureBox1.Ima ge.Save("image_ path.jpg")

      Hope this helps,

      Onur

      Comment

      • Jerry Spence1

        #4
        Re: Save image to file from memory

        Thanks. My problem is how to get at the memory in the first place. Given the
        pointer, how do I read it?

        -Jerry


        "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
        news:96a98ce9-747d-4d07-ad83-a4d943c36856@m7 3g2000hsh.googl egroups.com...
        On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@s omewhere.co.uk>
        wrote:
        >I am using a network camera that saves the image in a byte array in
        >memory
        >(via their ocx component, and in the OnNewImage event I can get the
        >pointer
        >to the image and the byte length as
        >e.lFrmBytes
        >>
        >e.lPtrToImag e
        >>
        >How do I get at that array in memory and save it to disk? It seems to
        >suggest a pointer which is not supported in VB.
        >>
        >-Jerry
        >
        Hi Jerry,
        If you're able to copy image to clipboard (memory), you can simply
        retrieve it into a picturebox and save by using save method. First
        make sure image is copied to clipboard.
        >
        ' To get image from clipboard
        PictureBox1.Ima ge = Clipboard.GetIm age
        >
        ' Then save image with a proper path
        PictureBox1.Ima ge.Save("image_ path.jpg")
        >
        Hope this helps,
        >
        Onur

        Comment

        • =?Utf-8?B?U3VydHVyWg==?=

          #5
          Re: Save image to file from memory

          I think you'll need to use Windows API calls.

          Maybe RtlMoveMemory?

          I wouldn't be surprised if VB.NET tries to frustrate you, though. VB.NET
          programmers aren't really meant to access memory directly.



          --
          David Streeter
          Synchrotech Software
          Sydney Australia


          "Jerry Spence1" wrote:
          Thanks. My problem is how to get at the memory in the first place. Given the
          pointer, how do I read it?
          >
          -Jerry
          >
          >
          "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
          news:96a98ce9-747d-4d07-ad83-a4d943c36856@m7 3g2000hsh.googl egroups.com...
          On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@s omewhere.co.uk>
          wrote:
          I am using a network camera that saves the image in a byte array in
          memory
          (via their ocx component, and in the OnNewImage event I can get the
          pointer
          to the image and the byte length as
          e.lFrmBytes
          >
          e.lPtrToImage
          >
          How do I get at that array in memory and save it to disk? It seems to
          suggest a pointer which is not supported in VB.
          >
          -Jerry
          Hi Jerry,
          If you're able to copy image to clipboard (memory), you can simply
          retrieve it into a picturebox and save by using save method. First
          make sure image is copied to clipboard.

          ' To get image from clipboard
          PictureBox1.Ima ge = Clipboard.GetIm age

          ' Then save image with a proper path
          PictureBox1.Ima ge.Save("image_ path.jpg")

          Hope this helps,

          Onur
          >
          >
          >

          Comment

          • =?Utf-8?B?U3VydHVyWg==?=

            #6
            Re: Save image to file from memory

            The namespace Microsoft.Win32 .SafeHandles Namespace might also yield a clue.
            I don't know anything about this namespace, but it looks promising.


            --
            David Streeter
            Synchrotech Software
            Sydney Australia


            "SurturZ" wrote:
            I think you'll need to use Windows API calls.
            >
            Maybe RtlMoveMemory?
            >
            I wouldn't be surprised if VB.NET tries to frustrate you, though. VB.NET
            programmers aren't really meant to access memory directly.
            >
            >
            >
            --
            David Streeter
            Synchrotech Software
            Sydney Australia
            >
            >
            "Jerry Spence1" wrote:
            >
            Thanks. My problem is how to get at the memory in the first place. Given the
            pointer, how do I read it?

            -Jerry


            "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
            news:96a98ce9-747d-4d07-ad83-a4d943c36856@m7 3g2000hsh.googl egroups.com...
            On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@s omewhere.co.uk>
            wrote:
            >I am using a network camera that saves the image in a byte array in
            >memory
            >(via their ocx component, and in the OnNewImage event I can get the
            >pointer
            >to the image and the byte length as
            >e.lFrmBytes
            >>
            >e.lPtrToImag e
            >>
            >How do I get at that array in memory and save it to disk? It seems to
            >suggest a pointer which is not supported in VB.
            >>
            >-Jerry
            >
            Hi Jerry,
            If you're able to copy image to clipboard (memory), you can simply
            retrieve it into a picturebox and save by using save method. First
            make sure image is copied to clipboard.
            >
            ' To get image from clipboard
            PictureBox1.Ima ge = Clipboard.GetIm age
            >
            ' Then save image with a proper path
            PictureBox1.Ima ge.Save("image_ path.jpg")
            >
            Hope this helps,
            >
            Onur

            Comment

            • Joel Lucsy

              #7
              Re: Save image to file from memory

              Try the System.Runtime. InteropServices .Marshal namespace.

              --
              Joel Lucsy
              "The dinosaurs became extinct because they didn't have a space program."
              -- Larry Niven

              Comment

              Working...