<?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[Grauwerte eines Bitmaps in 2D Array speichern]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte mit VC++ 6.0 die Grauwerte eines<br />
8-bit grayscale Bitmap Bildes ermitteln und in einem 2D Array speichern.Ich möchte dafür keine MFC benutzen sondern eine Konsolenanwendung.Ich habe dafür folgende Funktion geschrieben wobei ich noch nicht richtig weiss,wie ich die Grauwerte an dem Array M übergeben kann und ausserdem kriege ich 5 Fehlermeldungen, die ich nicht ganz verstehe.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include&lt;string.h&gt;
#include &lt;iostream&gt;

using namespace std;

void Bitmap2Array(char filename, int** M)
{
//filename:Path where the bmp file is located
char buf[100];
char file=strcpy(buf,filename);
//
HDC hdc;

// Handle for the Bitmap
static HBITMAP hbitmap;

//Bitmapobject 
BITMAP bm;            
hbitmap=(HBITMAP)LoadImage(NULL,file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
GetObject(hbitmap,sizeof(bm),&amp;bm); 

int Width=bm.bmWidth,Height=bm.bmHeight;
int i,j;
byte red,green,blue;
float gray;
for(j=0;j&lt;=Height;j++){
	for(i=0;i&lt;=Width;i++){
	 COLORREF col=GetPixel(hdc,j,i);
 // Extract color components (R,G,B)
	   blue=RGBQUAD.rgbBlue(col);
	    green=RGBQUAD.rgbGreen(col);
	    red=RGBQUAD.rgbRed(col);

// Convert from RGB to gray scale, using
gray = 0.3f*red + 0.59f*green + 0.11f*blue;

//Store the gray values in the array
//M[i][j]=            ;

}
}
}
</code></pre>
<p>Hätte Jemand eine Idee ?<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206553/grauwerte-eines-bitmaps-in-2d-array-speichern</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 01:03:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206553.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Feb 2008 11:44:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Grauwerte eines Bitmaps in 2D Array speichern on Tue, 26 Feb 2008 11:55:01 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte mit VC++ 6.0 die Grauwerte eines<br />
8-bit grayscale Bitmap Bildes ermitteln und in einem 2D Array speichern.Ich möchte dafür keine MFC benutzen sondern eine Konsolenanwendung.Ich habe dafür folgende Funktion geschrieben wobei ich noch nicht richtig weiss,wie ich die Grauwerte an dem Array M übergeben kann und ausserdem kriege ich 5 Fehlermeldungen, die ich nicht ganz verstehe.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include&lt;string.h&gt;
#include &lt;iostream&gt;

using namespace std;

void Bitmap2Array(char filename, int** M)
{
//filename:Path where the bmp file is located
char buf[100];
char file=strcpy(buf,filename);
//
HDC hdc;

// Handle for the Bitmap
static HBITMAP hbitmap;

//Bitmapobject 
BITMAP bm;            
hbitmap=(HBITMAP)LoadImage(NULL,file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
GetObject(hbitmap,sizeof(bm),&amp;bm); 

int Width=bm.bmWidth,Height=bm.bmHeight;
int i,j;
byte red,green,blue;
float gray;
for(j=0;j&lt;=Height;j++){
	for(i=0;i&lt;=Width;i++){
	 COLORREF col=GetPixel(hdc,j,i);
 // Extract color components (R,G,B)
	   blue=RGBQUAD.rgbBlue(col);
	    green=RGBQUAD.rgbGreen(col);
	    red=RGBQUAD.rgbRed(col);

// Convert from RGB to gray scale, using
gray = 0.3f*red + 0.59f*green + 0.11f*blue;

//Store the gray values in the array
//M[i][j]=            ;

}
}
}
</code></pre>
<p>Hätte Jemand eine Idee ?<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1463137</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1463137</guid><dc:creator><![CDATA[noname82]]></dc:creator><pubDate>Tue, 26 Feb 2008 11:55:01 GMT</pubDate></item><item><title><![CDATA[Reply to Grauwerte eines Bitmaps in 2D Array speichern on Tue, 26 Feb 2008 11:58:30 GMT]]></title><description><![CDATA[<p>guck dir mal die strukturen BITMAPFILEHEADER und BITMAPINFOHEADER an<br />
die kannst du direkt von der festplatte mit fread oder sonstwas einlesen und füllen.</p>
<p>der member <em>bfOffBits</em> von<br />
BITMAPFILEHEADER hat dann den offset zu den pixeldaten gespeichert.</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/ms532321(VS.85).aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms532321(VS.85).aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1463147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1463147</guid><dc:creator><![CDATA[agga ugga]]></dc:creator><pubDate>Tue, 26 Feb 2008 11:58:30 GMT</pubDate></item><item><title><![CDATA[Reply to Grauwerte eines Bitmaps in 2D Array speichern on Wed, 27 Feb 2008 15:29:10 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-403.html" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-4.html" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1464111</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1464111</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 27 Feb 2008 15:29:10 GMT</pubDate></item></channel></rss>