0

My name is Miguel, and I'm trying to get each single pixel in one .bmp, but so far, when i initialize the bitmap, it doesn't get any value, so i guess that i have initialized it wrong. This is my current code:(Snippet)

Bitmap *PerlinImage;

void OpenPerlinFile()
{
    PerlinImage = new Bitmap((WCHAR*)"C:\\Users\\Utilizador\\Documents\\Visual Studio 2012\\Projects\\Cube3D\\IDTech_JavaOpenGL_Port\\perlinNoise.bmp");
}

// END

void Initialize(void)
{
    OpenPerlinFile();

    Unit tempunit;
    Color color; 

    int ccount = 0;
    for (int h = 0; h != PerlinImage->GetHeight(); h++)
......

Now, can you look at my code, and maybe predict what I'm doing wrong.

Thank You

Miguel Petersen

Miguel P
  • 1,262
  • 6
  • 23
  • 48
  • I know you probably think it's polite, but your name REALLY isn't relevant to the question. If you want to let us know, change your username. – Cubic Aug 26 '12 at 00:05

2 Answers2

1

Assuming you've got the path correct, the following:

PerlinImage = new Bitmap((WCHAR*)"C:\\Users\\Utilizador\\Documents\\Visual Studio 2012\\Projects\\Cube3D\\IDTech_JavaOpenGL_Port\\perlinNoise.bmp");

should be:

PerlinImage = new Bitmap(_T("C:\\Users\\Utilizador\\Documents\\Visual Studio 2012\\Projects\\Cube3D\\IDTech_JavaOpenGL_Port\\perlinNoise.bmp"));

Or, without the helper macro:

PerlinImage = new Bitmap(L"C:\\Users\\Utilizador\\Documents\\Visual Studio 2012\\Projects\\Cube3D\\IDTech_JavaOpenGL_Port\\perlinNoise.bmp");
ta.speot.is
  • 26,914
  • 8
  • 68
  • 96
  • The path is correct, i tried to change as you said, but it's still null. – Miguel P Aug 26 '12 at 00:30
  • @user1492812 Well I'm assuming you've called `GdiplusStartup`. The only other thing I can think of is that the BMP is in a format that GDI+ doesn't understand. – ta.speot.is Aug 26 '12 at 01:47
0

Invoking GdiplusStartup is needed. Also check value of PerlinImage, if it's not NULL, then you could check error with PerlinImage->GetLastStatus(). If PerlinImage is NULL, then you may forget to call GdiplusStartup.

mr.dot
  • 16
  • 4