Jump to content
Fórum Script Brasil
  • 0

Gravar imagens com Visual Studio


Ronaldo Quadros

Question

1 answer to this question

Recommended Posts

  • 0

Bom, eu uso estas duas funções:

Public Function ToImage(ByVal bytes() As Byte) As Image
            Dim memarq As New IO.MemoryStream(bytes)
            Dim img As Image

            Try
                img = Image.FromStream(memarq)
            Catch ex As Exception
                img = Nothing
            End Try

            memarq.Close()

            Return img
        End Function

        Public Function ToBytes(ByVal img As Image) As Byte()
            Dim memarq As New IO.MemoryStream()
            Dim nimg As New Bitmap(img)

            nimg.Save(memarq, System.Drawing.Imaging.ImageFormat.Jpeg)

            memarq.Seek(0, IO.SeekOrigin.Begin)

            Dim bytes(memarq.Length) As Byte

            memarq.Read(bytes, 0, memarq.Length)
            memarq.Close()

            Return bytes
        End Function

A primeira converte uma sequência de bytes para uma imagem (para "ler" a imagem) e a outra faz o inverso (para "gravar" a imagem). Veja se dá certo aí para você.

Abraços,

Graymalkin

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...