0

I want to get values of R, G and B of pixels of an image. I already did it with HDC, but now I would like to complete it with Gdi+ and input image.

This is my code so far:

#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include "gdiplus.h"
#include "stdio.h"
#include "iostream"

using namespace Gdiplus;
using namespace std;

void main(int argc, char* argv[])
{
Bitmap* mybitmap = new("bink.bmp");
int x=0;
int y=0;
Color pixelColor;
//Color pixelcolor[1000][1000];
for ( x = 0; x < 640; x++ )
   {
      for ( y = 0; y < 480; y++ )
      {
             //Color pixelColor[x][y] = mybitmap->GetPixel(x,y);
         mybitmap->GetPixel(x,y, &pixelColor);
         cout << "Pixel color " << x << ",  " << y; "is  " << pixelColor;
         //cout << "Pixel color " << x << ",  " << y; "is  " << pixelColor[x][y];
      }
   }
}

It is not working... can You help somehow?

4

1 回答 1

0

你应该使用 pixelColor.GetGreen、pixelColor.GetRed、pixelColor.GetBlue

于 2013-11-11T19:00:33.883 回答