Hallo,
bin ein c++ Anfänger und arbeite mit VC++ 6.0.Ich möchte mit VC++ 6.0
die Grauwerte eines 8-bit grayscale Bitmap Bildes ermitteln und in einem
2D Array speichern.Ich habe auf dieser Seite gesehen, dass es einen
ähnlichen Beitrag gibt aber mir ist es immer noch nicht klar wie ich die
Grauwerte im Array M kriegen kann.ich kriege 4 fehlermeldungen, die ich
nicht verstehe.
1 | #include <windows.h>
|
2 | #include <stdio.h>
|
3 | #include<string.h>
|
4 | #include <iostream>
|
5 |
|
6 | using namespace std;
|
7 | void Bitmap2Array(char filename, int** M)
|
8 | {
|
9 | //filename:Path where the bmp file is located
|
10 | char buf[100];
|
11 | char file=strcpy(buf,filename); //Fehlermeldung hier
|
12 | HDC hdc;
|
13 | // Handle for the Bitmap
|
14 | static HBITMAP hbitmap;
|
15 | //Bitmapobject
|
16 | BITMAP bm;
|
17 | RGBQUAD rgbquad;
|
18 | hbitmap=(HBITMAP)LoadImage(NULL,file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
|
19 | GetObject(hbitmap,sizeof(bm),&bm);
|
20 | int Width=bm.bmWidth,Height=bm.bmHeight;
|
21 | int i,j;
|
22 | byte red,green,blue;
|
23 | float gray;
|
24 | for(j=0;j<=Height;j++){
|
25 | for(i=0;i<=Width;i++){
|
26 | COLORREF col=GetPixel(hdc,j,i);
|
27 | // Extract color components (R,G,B)
|
28 | blue=rgbquad.rgbBlue(col); // Fehlermeldung hier
|
29 | green=rgbquad.rgbGreen(col); // Fehlermeldung hier
|
30 | red=rgbquad.rgbRed(col); //Fehlermeldung hier
|
31 | // Convert from RGB to gray scale, using
|
32 | gray = 0.3*red + 0.59*green + 0.11*blue;
|
33 |
|
34 | //Store the gray values in the array
|
35 | //M[i][j]= ;
|
36 | }
|
37 | }
|
38 | }
|
Habe die Funktion "GetDIbits" gelesen weiss aber nicht wie ich sie
erfolgreich einsetzen kann.
Danke