みなさん、こんにちは!
このimage.bmpを取得しました。すべてのパディングを含めて読んだ場合、この結果が得られます。
画像を逆さまに読む以外に、ここで何が間違っているのですか?ウィキペディアやグーグルで親戚は見つかりません。24ピクセル幅の後、画像は8ピクセルでミラーリングされているようです。なぜ!?理解できません!?どうすればこれを修正できますか!?
WindowsでC++コードを使用してファイルを読み取り、BMPファイルを未加工で読み取っています。画像ファイルはモノクロです。ピクセルあたり1ビット。
ビットマップデータを表示するためのコード:
unsigned int count = 0; // Bit counting variable
unsigned char *bitmap_data = new char[size]; // Array containing the raw data of the image
for(unsigned int i=0; i<size; i++){ // This for-loop goes through every byte of the bitmap_data
for(int j=1; j<256; j*=2){ // This gives j 1, 2, 4, 8, 16, 32, 64 and 128. Used to go through every bit in the bitmap_data byte
if(count >= width){ // Checking if the row is ended
cout << "\n"; // Line feed
while(count > 32) count -=32; // For padding.
if(count < 24) i++;
if(count < 16) i++;
if(count < 8) i++;
count = 0; // resetting bit count and break out to next row
break;
}
if(i>=size) break; // Just in case
count++; // Increment the bitcounter. Need to be after end of row check
if(bitmap_data[i] & j){ // Compare bits
cout << (char)0xDB; // Block
}else{
cout << (char)' '; // Space
}
}
}
前もって感謝します!