<?xml version="1.0"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>將影像轉換成 Byte()</Title>
      <Author>Microsoft Corporation</Author>
      <Description>將影像轉換成 Byte()。位元組陣列通常是影像資訊儲存在資料庫中的方式</Description>
      <Shortcut>imageByte</Shortcut>
    </Header>
    <Snippet>
      <References>
        <Reference>
          <Assembly>System.Drawing</Assembly>
        </Reference>
      </References>
      <Imports>
        <Import>
          <Namespace>System</Namespace>
        </Import>
        <Import>
          <Namespace>System.Drawing</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Literal>
          <ID>inputImage</ID>
          <Type>item</Type>
          <ToolTip>取代為輸入影像的名稱。</ToolTip>
          <Default>img</Default>
        </Literal>
        <Literal>
          <ID>outputByteArray</ID>
          <Type>item</Type>
          <ToolTip>取代為輸出位元組陣列的名稱。</ToolTip>
          <Default>outBytes</Default>
        </Literal>
        <Literal>
          <ID>tempStream</ID>
          <Type>item</Type>
          <ToolTip>取代為用來讀取影像資料之暫存資料流的名稱。</ToolTip>
          <Default>ms</Default>
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method body"><![CDATA[Public Function GetByteArrayFromImage(ByVal $inputImage$ As Bitmap) As Byte()
        Dim $tempStream$ As New System.IO.MemoryStream
        $inputImage$.Save($tempStream$, Imaging.ImageFormat.Bmp)
        Dim $outputByteArray$(CInt($tempStream$.Length - 1)) As Byte
        $tempStream$.Seek(0, System.IO.SeekOrigin.Begin)
        $tempStream$.Read($outputByteArray$, 0, CInt($tempStream$.Length))
        Return $outputByteArray$
    End Function]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
