From: <ad...@hu...> - 2000-10-16 16:43:40
|
i will just include the code here so that no conversions are necessary... #include <stdio.h> #define GLubyte char #define GLushort short #define GLint int int main(void){ char whatever1[]={"sakjdhsskhjasjashaskdsakjasjas"}; char whatever2[]={"lhlkgjlkajdsflkfjlkjklfdaskfaf"}; //const GLubyte *src=_mesa_image_address(packing, srcImage, srcWidth, // srcHeight,srcFormat,srcType); // GLubyte *src=(GLubyte *)malloc(1024); GLubyte *src=(GLubyte *)whatever1; // GLushort *dst=(GLushort *)dstImage; // GLushort *dst=(GLushort *)malloc(1024); GLushort *dst=(GLushort *)whatever2; int f; GLushort val; GLint val32; GLint row; // for(row=0; row < dstHeight; row++){ // GLint col, col4; GLint col=4, col4=4; //rig some values so we don't over/underflow // for(col=col4=0; col < dstWidth; col++, col4 +=4){ //original ///* GLubyte r = src[col4 + 0]; GLubyte g = src[col4 + 1]; GLubyte b = src[col4 + 2]; GLubyte a = src[col4 + 3]; //printf("Datazzzz: (lsb)RGBA(msb)= 0x%x%x%x%x \n",a,b,g,r); dst[col] = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) ) | ((b & 0xf0) >> 4); //printf("Method 0: 0x%x \n",dst[col]); //*/ f++; f++; f++; f++; f++; f++; f++; f++; f++; // segment the assembler code for easier reading :)) //new1 ///* *(dst+col)= \ (((*(src+col4+3))&0xf0)<<8) | \ (((*(src+col4+2))&0xf0)>>4) | \ (((*(src+col4+1))&0xf0) ) | \ (((*(src+col4+0))&0xf0)<<4); //printf("Method 1: 0x%x \n",dst[col]); //*/ f++; f++; f++; f++; f++; f++; f++; f++; f++; // segment the assembler code for easier reading :)) //new2 ///* src+=col4; val =((*src)&0xf0)<<4; src++; val|=((*src)&0xf0); src++; val|=((*src)&0xf0)>>4; src++; val|=((*src)&0xf0)<<8; *(dst+col)=val; //save converted thing //printf("Method 2: 0x%x \n",dst[col]); src-=col4+3; //re-adjust src, this can be skipped outside this forloop by adjusting srcStride... //*/ f++; f++; f++; f++; f++; f++; f++; f++; f++; // segment the assembler code for easier reading :)) //new3 ///* val32=*( (GLint*)(src+col)); *(dst+col)= \ (( val32 & 0xf0000000)>>16) | \ (( val32 & 0x00f00000)>>20) | \ (( val32 & 0x0000f000)>>8 ) | \ (( val32 & 0x000000f0)<<4); //printf("Method 3: 0x%x \n",dst[col]); //*/ // }//inner // src +=srcStride; // dst =(GLushort *) ((GLubyte*) dst+dstRowStride); // }//outter return 0; };//end main |