<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1364604</guid>
        <pubDate>Mon, 04 Dec 2006 09:09:11 +0000</pubDate>
        <title>Как загрузить картинку в Image</title>
        <link>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1364604</link>
        <description><![CDATA[SCINER: Вот:]]></description>
        <author>SCINER</author>
        <category>Visual Basic: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1364592</guid>
        <pubDate>Mon, 04 Dec 2006 08:57:57 +0000</pubDate>
        <title>Как загрузить картинку в Image</title>
        <link>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1364592</link>
        <description><![CDATA[HardRock: Там в коде есть лишние дёргания с CopyMemory и байтовыми массивами, что приводит к падению проги с ошибкой записи памяти если грузит больше 2 картинок подряд.<br>
<br>
Чуток переписал этот код для стабильности и удобности использования<br>
<br>
Вот что получилось:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&#39; ----------------------------------------------------------------------</div><div class="code_line">&#39; --- Загрузка картинки из строки</div><div class="code_line">Public Function LoadPic(Buffer As String) As IPicture</div><div class="code_line">Dim hMem &nbsp;As Long, lpMem &nbsp;As Long</div><div class="code_line">Dim IID_IPicture(15)</div><div class="code_line">Dim istm As stdole.IUnknown</div><div class="code_line">Dim ByteCount As Long</div><div class="code_line">On Error GoTo Err_Init</div><div class="code_line">&nbsp;&nbsp; &nbsp;ByteCount = Len(Buffer)</div><div class="code_line">&nbsp;&nbsp; &nbsp;If ByteCount = 0 Then GoTo Err_Init</div><div class="code_line">&nbsp;&nbsp; &nbsp;hMem = GlobalAlloc(&amp;H2, ByteCount)</div><div class="code_line">&nbsp;&nbsp; &nbsp;If hMem &#60;&#62; 0 Then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lpMem = GlobalLock(hMem)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;If lpMem &#60;&#62; 0 Then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MoveMemory ByVal lpMem, ByVal Buffer, ByteCount</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Call GlobalUnlock(hMem)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If CreateStreamOnHGlobal(hMem, 1, istm) = 0 Then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If CLSIDFromString(StrPtr(&quot;{7BF80980-BF32-101A-8BBB-00AA00300CAB}&quot;), IID_IPicture(0)) = 0 Then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Call OleLoadPicture(ByVal ObjPtr(istm), ByteCount, 0, IID_IPicture(0), LoadPic)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;End If</div><div class="code_line">&nbsp;&nbsp; &nbsp;End If</div><div class="code_line">&nbsp;&nbsp; &nbsp;Exit Function</div><div class="code_line">Err_Init:</div><div class="code_line">&nbsp;&nbsp; &nbsp;If Err.Number = 9 Then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MsgBox &quot;Невозможно загрузиьт картинку, нет данных!&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MsgBox Err.Number &amp; &quot; - &quot; &amp; Err.Description</div><div class="code_line">&nbsp;&nbsp; &nbsp;End If</div><div class="code_line">End Function</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>HardRock</author>
        <category>Visual Basic: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1363631</guid>
        <pubDate>Sat, 02 Dec 2006 20:12:06 +0000</pubDate>
        <title>Как загрузить картинку в Image</title>
        <link>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1363631</link>
        <description><![CDATA[HardRock: Оо круто&#33;&#33;&#33; Огромное спасибо&#33;&#33;&#33; :yes: <br>PS: Надеюсь это должно работать на виндах ниже XP.]]></description>
        <author>HardRock</author>
        <category>Visual Basic: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1363580</guid>
        <pubDate>Sat, 02 Dec 2006 18:51:57 +0000</pubDate>
        <title>Как загрузить картинку в Image</title>
        <link>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1363580</link>
        <description><![CDATA[SCINER: Вот:]]></description>
        <author>SCINER</author>
        <category>Visual Basic: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1363543</guid>
        <pubDate>Sat, 02 Dec 2006 17:43:54 +0000</pubDate>
        <title>Как загрузить картинку в Image</title>
        <link>https://forum.sources.ru/index.php?showtopic=163490&amp;view=findpost&amp;p=1363543</link>
        <description><![CDATA[HardRock: Такая ситуация:<br>Есть файл картинки, прочитаный в память. <br>Как его загрузить в Image/PictureBox? Не горю желание сохранять сначала в файл, а затем грузить....]]></description>
        <author>HardRock</author>
        <category>Visual Basic: Общие вопросы</category>
      </item>
	
      </channel>
      </rss>
	