• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

We're also offering banner ads on our site from just \$5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

### #ActualDanicco

Posted 28 August 2013 - 01:35 AM

I was restructuring the code and when I tried to test it again, the textures weren't showing anymore.

After a bunch of tests, I got to something really weird.

The reading from the BMP wasn't changed at all, so I don't think that's the cause, and the draw function is also really simple (it's also copied from another project I'm 100% sure it's working).

I tried changing BMPs to see if that was the issue, and a bunch of other images didn't show either.

However a simple checker BMP image I did some time ago for tests was showing perfectly fine.

This is the checker image, and what displays when I call it:

This is another image I tried to display (among a bunch of others) and this is what shows:

After testing for hours and not finding anything, I decided to do a little test, I copied some pixels from the image that wasn't displaying to the one that was:

And then I called it "Weird.bmp" and tried to load it on my code, and this is what happened:

(Note the messed up first pixel row)

Also, another BMP that I was using for tests (640x913 BMP) seems to cause my BMP loading code to bug out/infinite loop, as it's header's height/width are being set to a negative value:

if(fileReader.is_open())
{

_texture->textureHeight = bitmapInfoHeader->biHeight; //On this specific BMP image, this has a -842150451

long imageTotalBytes = _texture->textureHeight * _texture->textureWidth * 4;

_texture->_textureData = new GLubyte[imageTotalBytes];

char pixelInfo[3];
int c = 0;
while(c < imageTotalBytes)
{
_texture->_textureData[c] = (GLubyte)pixelInfo[2];
_texture->_textureData[c - 1] = (GLubyte)pixelInfo[1];
_texture->_textureData[c - 2] = (GLubyte)pixelInfo[0];
_texture->_textureData[c - 3] = 255; //Manually filling alpha

c += 4;
}

}


Even after I got the original and re-saved it again, I'm still getting the same wrong header file. And it seems to be just on this specific file.

What could be causing this, or do you have any suggestions on how can I debug this?

Edit: I have this same image that has a negative header value in a binary file I made for test reading/writing, and when I load it from there, it shows perfectly fine.

However, now even my project that I use to load/read files and pack them in a single binary file isn't working anymore because it's reading this BMPs wrongly as well (it's even a different file, same image, in a different folder).

### #1Danicco

Posted 28 August 2013 - 01:31 AM

I was restructuring the code and when I tried to test it again, the textures weren't showing anymore.

After a bunch of tests, I got to something really weird.

The reading from the BMP wasn't changed at all, so I don't think that's the cause, and the draw function is also really simple (it's also copied from another project I'm 100% sure it's working).

I tried changing BMPs to see if that was the issue, and a bunch of other images didn't show either.

However a simple checker BMP image I did some time ago for tests was showing perfectly fine.

This is the checker image, and what displays when I call it:

This is another image I tried to display (among a bunch of others) and this is what shows:

After testing for hours and not finding anything, I decided to do a little test, I copied some pixels from the image that wasn't displaying to the one that was:

And then I called it "Weird.bmp" and tried to load it on my code, and this is what happened:

(Note the messed up first pixel row)

Also, another BMP that I was using for tests (640x913 BMP) seems to cause my BMP loading code to bug out/infinite loop, as it's header's height/width are being set to a negative value:

if(fileReader.is_open())
{

_texture->textureHeight = bitmapInfoHeader->biHeight; //On this specific BMP image, this has a -842150451

long imageTotalBytes = _texture->textureHeight * _texture->textureWidth * 4;

_texture->_textureData = new GLubyte[imageTotalBytes];

char pixelInfo[3];
int c = 0;
while(c < imageTotalBytes)
{
_texture->_textureData[c] = (GLubyte)pixelInfo[2];
_texture->_textureData[c - 1] = (GLubyte)pixelInfo[1];
_texture->_textureData[c - 2] = (GLubyte)pixelInfo[0];
_texture->_textureData[c - 3] = 255; //Manually filling alpha

c += 4;
}