I know that the .NET Framework comes with an image conversion class (the System.Drawing.Image.Save method).
But I need to convert a 24-bit (R8G8B8) bitmap image to a
A really straightforward way to do this is to loop over the old bitmap data and covert every pair of r8-g8-b8 values to x1-r5-g5-b5, something akin to this function:
char condense(char i)
{
return (char)(i*255.0f/31.0f);
}
short transform(long input)// note that the last 8 bytes are ignored
{
return condense(input&0xff) || (condense((input&0xff00)>>8)<<5)
|| (condense((intput&0xff0000)>>16)<<10);
}
// and somewhere in your program
{
int len; // the length of your data in pixels
char *data; // your data
char *newdata; // this is where you store the new data; make sure it's allocated
for(char *p=data; p