//将像素数据保存到数组中对应的位置
dataOfBmp[index].rgbRed = pRgb[mixIndex].rgbRed; dataOfBmp[index].rgbGreen = pRgb[mixIndex].rgbGreen; dataOfBmp[index].rgbBlue = pRgb[mixIndex].rgbBlue; dataOfBmp[index].rgbReserved = pRgb[mixIndex].rgbReserved; index++; } }
if(bitInfoHead.biBitCount == 4) {
for(int i=0;i BYTE mixIndex= 0; k = i*l_width + j/2; mixIndex = pColorData[k]; if(j%2==0) {//低 mixIndex = mixIndex<<4; mixIndex = mixIndex>>4; } else {//高 mixIndex = mixIndex>>4; } dataOfBmp[index].rgbRed = pRgb[mixIndex].rgbRed; dataOfBmp[index].rgbGreen = pRgb[mixIndex].rgbGreen; dataOfBmp[index].rgbBlue = pRgb[mixIndex].rgbBlue; dataOfBmp[index].rgbReserved = pRgb[mixIndex].rgbReserved; index++; } } if(bitInfoHead.biBitCount == 8) { for(int i=0;i BYTE mixIndex= 0; k = i*l_width + j; mixIndex = pColorData[k]; dataOfBmp[index].rgbRed = pRgb[mixIndex].rgbRed; dataOfBmp[index].rgbGreen = pRgb[mixIndex].rgbGreen; dataOfBmp[index].rgbBlue = pRgb[mixIndex].rgbBlue; dataOfBmp[index].rgbReserved = pRgb[mixIndex].rgbReserved; index++; } } if(bitInfoHead.biBitCount == 16) { for(int i=0;i WORD mixIndex= 0; k = i*l_width + j*2; WORD shortTemp; shortTemp = pColorData[k+1]; shortTemp = shortTemp<<8; mixIndex = pColorData[k] + shortTemp; dataOfBmp[index].rgbRed = pRgb[mixIndex].rgbRed; dataOfBmp[index].rgbGreen = pRgb[mixIndex].rgbGreen; dataOfBmp[index].rgbBlue = pRgb[mixIndex].rgbBlue; dataOfBmp[index].rgbReserved = pRgb[mixIndex].rgbReserved; index++; } } } else//位图为24位真彩色 { int k; int index = 0; for(int i=0;i k = i*l_width + j*3; dataOfBmp[index].rgbRed = pColorData[k+2]; dataOfBmp[index].rgbGreen = pColorData[k+1]; dataOfBmp[index].rgbBlue = pColorData[k]; index++; } } printf(\像素数据信息:\\n\for (int i=0; i if (i%5==0) { printf(\ } showRgbQuan(&dataOfBmp[i]); } fclose(pfile); if (bitInfoHead.biBitCount<24) { free(pRgb); } free(dataOfBmp); free(pColorData); printf(\ }