Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problem with a texture.

Started by Shakti Apr 24, 2004 at 9:46 AM 4 replies 600+ views
Original Post
Shakti
Shakti
I have a problem with a texture and my own fileformat. The texture in question is the one used in tutorial 10 at NeHe. I try to convert it to my own format using this function:
for(int i=0, j=0; i<dataSize; i+=3, j+=4)
{
	if(image[0]->data[i] == R && image[0]->data[i+1] == G && image[0]->data[i+2] == B)
	{
		newData[j+3] = minA;
	}
	else
	{
		newData[j+3] = maxA;
	}
	newData[j] = image[0]->data[i];
	newData[j+1] = image[0]->data[i+1];
	newData[j+2] = image[0]->data[i+2];
}
 
R, G and B are values containing the color value that should be transparent. Problem is that when I have converted it this way and now try to load it it wont show properly. It will only show a grey box and the only part that is correct is at the very bottom. It works with all other textures but it is annoying if there is a bug in this function or something I have overseen so if somebody could help me i would be very happy! [edited by - Shakti on April 24, 2004 10:58:42 AM]
_DarkWIng_
_DarkWIng_
Are you sure you are using RGBA as format for new texture?

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Shakti
Shakti
Yes. It works with all other bmps I have tried it with but this one just buggers me.
djsteffey
djsteffey
make sure the bitmaps compression is 0
look in the bitmap info header for the variable compression
if it is something other than 0 then the bmp is compressed any you cant do a direct copy like that


"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA
Shakti
Shakti
Well I just checked in a hex editor and when I checked at offset 0x001E (where according to my source the unsigned int for compression is) and went to offset 0x0022 they were all 0s so I guess it isnt compressed.
Shakti
Shakti
I think I have located the problem to that piece of code I have there. Apparently it seems like this algo will not add an alpha channel that is good enough. Maybe it is my assumption that the size of the image is height*width*3 (without alphachannel) and height*width*4 with alpha channel. I dunno but something in the algo causes this to happen. I just tried with the texture used in tutorial 12 and its the same thing with that one. It seems like it adds some bytes (more or less, from case to case) and I have no idea why.

[edited by - Shakti on April 25, 2004 2:08:28 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.