<?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[Bmp]]></title><description><![CDATA[<p>Ich schreibe grade einen Steganographen. ICh habe nun aber schon mein erstes Problem... wenn ich die geöffnete(unveränderte) BMP speichere, hat sie einen nuen Farbton... Wieso?<br />
[Quellcode hat noch nichts mit meinem Projekt zu tun, dient nur zur Problembehandlung]</p>
<pre><code class="language-cpp">/*****************************************************************************//
#include &lt;windows.h&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

#pragma  pack(1)
struct BMFH // BitmapFileHeader
{
	char         bmtype[2];     // 2 bytes - 'B' 'M'
	unsigned int iFileSize;     // 4 bytes
	short int    reserved1;     // 2 bytes
	short int    reserved2;     // 2 bytes
	unsigned int iOffsetBits;   // 4 bytes

};// End of stBMFH structure - size of 18 bytes
#pragma pack()

#pragma pack(1)
struct BMIF // BitmapInfoHeader
{
	unsigned int iSizeHeader;    // 4 bytes - 40
	unsigned int iWidth;         // 4 bytes
	unsigned int iHeight;        // 4 bytes
	short int    iPlanes;        // 2 bytes
	short int    iBitCount;      // 2 bytes
	unsigned int Compression;    // 4 bytes
	unsigned int iSizeImage;     // 4 bytes
	unsigned int iXPelsPerMeter; // 4 bytes
	unsigned int iYPelsPerMeter; // 4 bytes
	unsigned int iClrUsed;       // 4 bytes
	unsigned int iClrImportant;  // 4 bytes
};// End of stBMIF structure - size 40 bytes
#pragma pack()

struct Image
{
	unsigned int iWidth;
	unsigned int iHeight;
	unsigned int* pARGB; // Alpha Red Green Blue
};
//*****************************************************************************//
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

HWND g_hWnd;

//*****************************************************************************//
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX	WndClassEx;
	wchar_t		*classname = L&quot;Application&quot;;
	MSG			msg;

	ZeroMemory(&amp;WndClassEx, sizeof(WNDCLASSEX));
	ZeroMemory(&amp;msg,		sizeof(MSG));

	WndClassEx.cbClsExtra		= NULL;
	WndClassEx.cbSize			= sizeof(WNDCLASSEX);
	WndClassEx.cbWndExtra		= NULL;
	WndClassEx.hbrBackground	= (HBRUSH) (COLOR_BTNFACE + 1);
	WndClassEx.hCursor			= LoadCursor(NULL, IDC_ARROW);
	WndClassEx.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	WndClassEx.hIconSm			= NULL;
	WndClassEx.hInstance		= hInstance;
	WndClassEx.lpfnWndProc		= WndProc;
	WndClassEx.lpszClassName	= classname;
	WndClassEx.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;

	RegisterClassEx(&amp;WndClassEx);

	g_hWnd = CreateWindowEx(NULL,
						  classname,
						  L&quot;Own Control&quot;,
						  WS_OVERLAPPEDWINDOW,
						  CW_USEDEFAULT,
						  CW_USEDEFAULT,
						  800,
						  300,
						  NULL,
						  NULL,
						  hInstance,
						  NULL);

	ShowWindow(g_hWnd, SW_SHOWNORMAL);
	UpdateWindow(g_hWnd);

	while(GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}

	return 0;
}
//*****************************************************************************//
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static HDC hDC;
	switch(uMsg)
	{
	case WM_CREATE:
		hDC = GetDC(hWnd);
		return 0;

	case WM_PAINT:
		{
			std::basic_fstream&lt;char&gt; in(&quot;test1.bmp&quot;, std::ios_base::in | std::ios_base::binary);
			if(!in)
				return -1;

			BMFH bMFH;
			BMIF bMIF;

			in.read((char*) &amp;bMFH, sizeof(BMFH));
			in.read((char*) &amp;bMIF, sizeof(BMIF));

			Image img;
			img.iWidth  = bMIF.iWidth;
			img.iHeight = bMIF.iHeight;
			img.pARGB	= new(unsigned int[img.iWidth * img.iHeight]);

			int iNumPaddedBytes = (img.iWidth * 3) % 4;

			in.seekp(bMFH.iOffsetBits);
			for(unsigned int h = 0; h &lt; img.iHeight; h ++)
			{
				for(unsigned int w = 0; w &lt; img.iWidth; w ++)
				{
					unsigned char r, g, b;

					in.read((char*) &amp;b, sizeof(char));
					in.read((char*) &amp;g, sizeof(char));
					in.read((char*) &amp;r, sizeof(char));
					SetPixel(hDC, w, img.iHeight - h, RGB(r, g, b));

					img.pARGB[w + h * img.iWidth] = (r &lt;&lt; 16 | g &lt;&lt; 8 | b);
				}

				if(iNumPaddedBytes != 0)
				{
					unsigned char skip[4];
					in.read((char*) &amp;skip, sizeof(skip));
				}
			}

			std::basic_fstream&lt;char&gt; out(&quot;test3.bmp&quot;, std::ios_base::out | std::ios_base::binary);
			out.write((char*) &amp;bMFH, sizeof(BMFH));
			out.write((char*) &amp;bMIF, sizeof(BMIF));

			unsigned char r, g, b;
			for(unsigned int h = 0; h &lt; img.iHeight; h ++)
			{
				for(unsigned int w = 0; w &lt; img.iWidth; w ++)
				{		
					r  = img.pARGB[w + h * img.iWidth] = GetRValue(img.pARGB[w + h * img.iWidth]);
					g  = img.pARGB[w + h * img.iWidth] = GetGValue(img.pARGB[w + h * img.iWidth]);
					b  = img.pARGB[w + h * img.iWidth] = GetBValue(img.pARGB[w + h * img.iWidth]);

					SetPixel(hDC, w + img.iWidth, img.iHeight - h, RGB(r, g, b));

					out.write((char*) &amp;r, sizeof(char));
					out.write((char*) &amp;g, sizeof(char));
					out.write((char*) &amp;b, sizeof(char));
				}
			}

			delete[](img.pARGB);

			ValidateRect(hWnd, NULL);

			return 0;
		}

	case WM_DESTROY:
		DeleteDC(hDC);
		PostQuitMessage(0);
		return 0;

	default:
		break;
	}

	return(DefWindowProc(hWnd, uMsg, wParam, lParam));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/134396/bmp</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 19:37:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/134396.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jan 2006 17:59:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bmp on Wed, 25 Jan 2006 20:59:50 GMT]]></title><description><![CDATA[<p>Ich schreibe grade einen Steganographen. ICh habe nun aber schon mein erstes Problem... wenn ich die geöffnete(unveränderte) BMP speichere, hat sie einen nuen Farbton... Wieso?<br />
[Quellcode hat noch nichts mit meinem Projekt zu tun, dient nur zur Problembehandlung]</p>
<pre><code class="language-cpp">/*****************************************************************************//
#include &lt;windows.h&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

#pragma  pack(1)
struct BMFH // BitmapFileHeader
{
	char         bmtype[2];     // 2 bytes - 'B' 'M'
	unsigned int iFileSize;     // 4 bytes
	short int    reserved1;     // 2 bytes
	short int    reserved2;     // 2 bytes
	unsigned int iOffsetBits;   // 4 bytes

};// End of stBMFH structure - size of 18 bytes
#pragma pack()

#pragma pack(1)
struct BMIF // BitmapInfoHeader
{
	unsigned int iSizeHeader;    // 4 bytes - 40
	unsigned int iWidth;         // 4 bytes
	unsigned int iHeight;        // 4 bytes
	short int    iPlanes;        // 2 bytes
	short int    iBitCount;      // 2 bytes
	unsigned int Compression;    // 4 bytes
	unsigned int iSizeImage;     // 4 bytes
	unsigned int iXPelsPerMeter; // 4 bytes
	unsigned int iYPelsPerMeter; // 4 bytes
	unsigned int iClrUsed;       // 4 bytes
	unsigned int iClrImportant;  // 4 bytes
};// End of stBMIF structure - size 40 bytes
#pragma pack()

struct Image
{
	unsigned int iWidth;
	unsigned int iHeight;
	unsigned int* pARGB; // Alpha Red Green Blue
};
//*****************************************************************************//
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

HWND g_hWnd;

//*****************************************************************************//
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX	WndClassEx;
	wchar_t		*classname = L&quot;Application&quot;;
	MSG			msg;

	ZeroMemory(&amp;WndClassEx, sizeof(WNDCLASSEX));
	ZeroMemory(&amp;msg,		sizeof(MSG));

	WndClassEx.cbClsExtra		= NULL;
	WndClassEx.cbSize			= sizeof(WNDCLASSEX);
	WndClassEx.cbWndExtra		= NULL;
	WndClassEx.hbrBackground	= (HBRUSH) (COLOR_BTNFACE + 1);
	WndClassEx.hCursor			= LoadCursor(NULL, IDC_ARROW);
	WndClassEx.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	WndClassEx.hIconSm			= NULL;
	WndClassEx.hInstance		= hInstance;
	WndClassEx.lpfnWndProc		= WndProc;
	WndClassEx.lpszClassName	= classname;
	WndClassEx.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;

	RegisterClassEx(&amp;WndClassEx);

	g_hWnd = CreateWindowEx(NULL,
						  classname,
						  L&quot;Own Control&quot;,
						  WS_OVERLAPPEDWINDOW,
						  CW_USEDEFAULT,
						  CW_USEDEFAULT,
						  800,
						  300,
						  NULL,
						  NULL,
						  hInstance,
						  NULL);

	ShowWindow(g_hWnd, SW_SHOWNORMAL);
	UpdateWindow(g_hWnd);

	while(GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}

	return 0;
}
//*****************************************************************************//
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static HDC hDC;
	switch(uMsg)
	{
	case WM_CREATE:
		hDC = GetDC(hWnd);
		return 0;

	case WM_PAINT:
		{
			std::basic_fstream&lt;char&gt; in(&quot;test1.bmp&quot;, std::ios_base::in | std::ios_base::binary);
			if(!in)
				return -1;

			BMFH bMFH;
			BMIF bMIF;

			in.read((char*) &amp;bMFH, sizeof(BMFH));
			in.read((char*) &amp;bMIF, sizeof(BMIF));

			Image img;
			img.iWidth  = bMIF.iWidth;
			img.iHeight = bMIF.iHeight;
			img.pARGB	= new(unsigned int[img.iWidth * img.iHeight]);

			int iNumPaddedBytes = (img.iWidth * 3) % 4;

			in.seekp(bMFH.iOffsetBits);
			for(unsigned int h = 0; h &lt; img.iHeight; h ++)
			{
				for(unsigned int w = 0; w &lt; img.iWidth; w ++)
				{
					unsigned char r, g, b;

					in.read((char*) &amp;b, sizeof(char));
					in.read((char*) &amp;g, sizeof(char));
					in.read((char*) &amp;r, sizeof(char));
					SetPixel(hDC, w, img.iHeight - h, RGB(r, g, b));

					img.pARGB[w + h * img.iWidth] = (r &lt;&lt; 16 | g &lt;&lt; 8 | b);
				}

				if(iNumPaddedBytes != 0)
				{
					unsigned char skip[4];
					in.read((char*) &amp;skip, sizeof(skip));
				}
			}

			std::basic_fstream&lt;char&gt; out(&quot;test3.bmp&quot;, std::ios_base::out | std::ios_base::binary);
			out.write((char*) &amp;bMFH, sizeof(BMFH));
			out.write((char*) &amp;bMIF, sizeof(BMIF));

			unsigned char r, g, b;
			for(unsigned int h = 0; h &lt; img.iHeight; h ++)
			{
				for(unsigned int w = 0; w &lt; img.iWidth; w ++)
				{		
					r  = img.pARGB[w + h * img.iWidth] = GetRValue(img.pARGB[w + h * img.iWidth]);
					g  = img.pARGB[w + h * img.iWidth] = GetGValue(img.pARGB[w + h * img.iWidth]);
					b  = img.pARGB[w + h * img.iWidth] = GetBValue(img.pARGB[w + h * img.iWidth]);

					SetPixel(hDC, w + img.iWidth, img.iHeight - h, RGB(r, g, b));

					out.write((char*) &amp;r, sizeof(char));
					out.write((char*) &amp;g, sizeof(char));
					out.write((char*) &amp;b, sizeof(char));
				}
			}

			delete[](img.pARGB);

			ValidateRect(hWnd, NULL);

			return 0;
		}

	case WM_DESTROY:
		DeleteDC(hDC);
		PostQuitMessage(0);
		return 0;

	default:
		break;
	}

	return(DefWindowProc(hWnd, uMsg, wParam, lParam));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/976233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976233</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Wed, 25 Jan 2006 20:59:50 GMT</pubDate></item><item><title><![CDATA[Reply to Bmp on Wed, 25 Jan 2006 20:23:19 GMT]]></title><description><![CDATA[<p>Benutze bitte Code-Tags, dann kann man den Code besser lesen/kopieren.</p>
<p>Es liegt an folgenden drei Zeilen:</p>
<pre><code class="language-cpp">r = img.pARGB[w + h * img.iWidth] = GetRValue(img.pARGB[w + h * img.iWidth]);
g = img.pARGB[w + h * img.iWidth] = GetGValue(img.pARGB[w + h * img.iWidth]);
b = img.pARGB[w + h * img.iWidth] = GetBValue(img.pARGB[w + h * img.iWidth]);
</code></pre>
<p>Was machst du da? Wofür zwei Zuweisungen?? Versuch es mal so:</p>
<pre><code class="language-cpp">r = GetRValue(img.pARGB[w + h * img.iWidth]);
g = GetGValue(img.pARGB[w + h * img.iWidth]);
b = GetBValue(img.pARGB[w + h * img.iWidth]);
</code></pre>
<p>Dann klappt's bei mir.</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976371</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Wed, 25 Jan 2006 20:23:19 GMT</pubDate></item><item><title><![CDATA[Reply to Bmp on Wed, 25 Jan 2006 21:00:41 GMT]]></title><description><![CDATA[<p>Man, das ich diesen dummen Fehler nicht selbst erkannt habe...<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/976397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976397</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Wed, 25 Jan 2006 21:00:41 GMT</pubDate></item></channel></rss>