Anyone have code for 5x5x5 to 5x6x5 conversion...

Started by
6 comments, last by Mike 24 years, 3 months ago
...and the other way around.
Advertisement
To my knowledge, you don''t ever have to convert the rgb''s from 565 to 555 or vice versa, instead you check at the beginning which format the card is in, then shift the bits in your RGB macro or inline function the appropriate number of digits. Some people might convert the numbers, but I''ve never heard of it.

-----------------------------
"And I write and I write and I don't believe it's gonna change today"
- From Yellow Ledbetter by Pearl Jam

http://www.crosswinds.net/~uselessknowledge
my problem is that when I run my game on a computer with a 555 video card, everything looks correct. However, when I run my game on a computer that has a 565 video card, everthing looks horrible. I''m guessing it is because my graphics are saved in a 555 format. I need to convert the graphics I am loading as 555 images to 565 images.
all you gotta do is shift the R over by 1 bit for 565 and it''l look normal
Okay, so how do I take a 555 value, corectly get the r g and b values shift the r value one and then recombinded them into a 565 value. I''ve tried this several ways and I cannot get it to work. Some code would be nice.
ok here a piece of code to get the correct values for you to shift in 16 mode

	DDPIXELFORMAT		ddpf;	HRESULT				hResult;	RedShift=0;	GreenShift=0;	BlueShift=0;	ZeroMemory(&ddpf, sizeof(ddpf));	ddpf.dwSize=sizeof(DDPIXELFORMAT);	hResult = lpDDSurface->GetPixelFormat(&ddpf);	if (hResult !=DD_OK)		exit(0);	if (!FAILED (hResult)) 	{			    while(!(ddpf.dwRBitMask & 0x01L))		{	    	ddpf.dwRBitMask >>= 1;		    RedShift++;	    }		   		while(!(ddpf.dwGBitMask & 0x01L))	    {			ddpf.dwGBitMask >>= 1;			GreenShift++;		}				while(!(ddpf.dwBBitMask & 0x01L))	    {			ddpf.dwBBitMask >>= 1;			BlueShift++;	    }	}	return hResult;  


dont know how this code thing works hope it displayed it right

afte this code you have RedShift, GreenShift, BlueShift

when your putting the pixel use

buffer[23]=(r++RedShift / GreenShift++GreenShift / b ++ BlueShift)


(++ is the shift operand cause the code disapears if i use diouble <; there is a bar where it should be a or)
and it should work correctly on any card

hope it helps

Bruno Sousa aka Akura

Edited by - Akura on 1/9/00 11:30:59 AM
It's good to be an outcast, you don't need to explain what you do, you just do it and say you don't belong there.
Yes, what I was trying to say before is that you must first determine the pixel format, then have an rgb function or macro that shifts the correct amount, just like Akura said.
to speed up the process try packing two words in one dword and process them. or even better, use the SIMD (MMX) instructions. its quite easy really, all you do is put a p infront of the good ole asm operands. eg. pand, por and psrlw (packed shift right logical word) etc.

This topic is closed to new replies.

Advertisement