<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[BYTE-Array in IStream]]></title><description><![CDATA[<p>Also ... ich bekomm Daten von meiner Server app... als BYTE-Array... soweit kein Problem ... doch es handelt sich bei dem Array um Bilddaten, d.h. will ich diese Daten in einen IStream packen und diesen dann an Gdiplus::Image::FromStream übergeben... doch ich bekomms nicht richtig hin, die Daten des Arrays in nen Stream zu packen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /> Hat da jemand nen Lösungsvorschlag? Was ich versucht hab hat net gaanz so geklappt ...</p>
<pre><code class="language-cpp">/* 
LoadImage:
   - lpbyData: Zeiger auf BYTE-Array der die Bild-Daten enthält.
   - dwLen: größe des Arrays
*/
bool dataPictureCtrl::LoadImage(LPCBYTE lpbyData, unsigned long dwLen)
{
	// m_pImage ist ein Pointer auf ein Gdiplus::Image
	if (lpbyData == NULL)
		return false;

	if (m_pImage != NULL) 
	{
		delete m_pImage;
		m_pImage = NULL;
	}

    LPVOID	lpData	= NULL;
    HGLOBAL	hGlobal	= GlobalAlloc(GMEM_MOVEABLE, dwLen);

    if (hGlobal == NULL)
		return false;

    lpData = GlobalLock(hGlobal);

    if (lpData == NULL)
    {
        GlobalUnlock(hGlobal);
        return false;
    }

	memcpy(lpData, lpbyData, dwLen);

    GlobalUnlock(hGlobal);

    LPSTREAM lpStream = NULL;

    if (FAILED(CreateStreamOnHGlobal(hGlobal, TRUE, &amp;lpStream)))
	{
		if (lpStream != NULL)
            lpStream-&gt;Release();

		return false;
	}

	if (lpStream == NULL)
		return false;

	m_pImage = Gdiplus::Image::FromStream(lpStream);

	if (m_pImage == NULL || m_pImage-&gt;GetLastStatus() != Gdiplus::Ok)
	{
		lpStream-&gt;Release();
		return false;
	}

	lpStream-&gt;Release();

	RedrawWindow();

	return true;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/163282/byte-array-in-istream</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 11:50:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/163282.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 27 Oct 2006 18:52:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to BYTE-Array in IStream on Fri, 27 Oct 2006 18:52:42 GMT]]></title><description><![CDATA[<p>Also ... ich bekomm Daten von meiner Server app... als BYTE-Array... soweit kein Problem ... doch es handelt sich bei dem Array um Bilddaten, d.h. will ich diese Daten in einen IStream packen und diesen dann an Gdiplus::Image::FromStream übergeben... doch ich bekomms nicht richtig hin, die Daten des Arrays in nen Stream zu packen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /> Hat da jemand nen Lösungsvorschlag? Was ich versucht hab hat net gaanz so geklappt ...</p>
<pre><code class="language-cpp">/* 
LoadImage:
   - lpbyData: Zeiger auf BYTE-Array der die Bild-Daten enthält.
   - dwLen: größe des Arrays
*/
bool dataPictureCtrl::LoadImage(LPCBYTE lpbyData, unsigned long dwLen)
{
	// m_pImage ist ein Pointer auf ein Gdiplus::Image
	if (lpbyData == NULL)
		return false;

	if (m_pImage != NULL) 
	{
		delete m_pImage;
		m_pImage = NULL;
	}

    LPVOID	lpData	= NULL;
    HGLOBAL	hGlobal	= GlobalAlloc(GMEM_MOVEABLE, dwLen);

    if (hGlobal == NULL)
		return false;

    lpData = GlobalLock(hGlobal);

    if (lpData == NULL)
    {
        GlobalUnlock(hGlobal);
        return false;
    }

	memcpy(lpData, lpbyData, dwLen);

    GlobalUnlock(hGlobal);

    LPSTREAM lpStream = NULL;

    if (FAILED(CreateStreamOnHGlobal(hGlobal, TRUE, &amp;lpStream)))
	{
		if (lpStream != NULL)
            lpStream-&gt;Release();

		return false;
	}

	if (lpStream == NULL)
		return false;

	m_pImage = Gdiplus::Image::FromStream(lpStream);

	if (m_pImage == NULL || m_pImage-&gt;GetLastStatus() != Gdiplus::Ok)
	{
		lpStream-&gt;Release();
		return false;
	}

	lpStream-&gt;Release();

	RedrawWindow();

	return true;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1162786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1162786</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 27 Oct 2006 18:52:42 GMT</pubDate></item><item><title><![CDATA[Reply to BYTE-Array in IStream on Sat, 28 Oct 2006 11:33:55 GMT]]></title><description><![CDATA[<p>Sieht doch gut aus. Was klappt denn nicht?<br />
Achte daruf, dass die Rückgabewerte (HRESULT) meistens wertvolle Infrmationen Infos geben.</p>
<pre><code class="language-cpp">HRESULT hr;
hr = Operation();
if (FAILED(hr))
    ...
</code></pre>
<p>Ist ein besserer Stil für die Fehlerkontrolle!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1162992</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1162992</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Sat, 28 Oct 2006 11:33:55 GMT</pubDate></item><item><title><![CDATA[Reply to BYTE-Array in IStream on Sun, 29 Oct 2006 08:44:10 GMT]]></title><description><![CDATA[<p>Hmm ok wenn das richtig wäre, müsste er das Bild ja anzeigen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Hmm das mit der Fehlerkontrolle werd ich machen ... die Funktion ist auch NOCH nicht fertig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> Die Fehlerüberprüfung(durch verschiedene returns <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ) kommt imma bei mir am ende <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>naja ... hmm k aber eigentlich müsste Invalidate(), RedrawWindow() oder InvalidateRect den ja eigentlich dazu bringen die WM_ERASEBACKGROUND nochmal aufzurufen... und dann würde GDI+ das ganze ja auch anzeigen... aber tuts nunmal nicht ... ich guck jetzt einfach mal was GetLastError meint ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163539</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163539</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 29 Oct 2006 08:44:10 GMT</pubDate></item></channel></rss>