[問題] fseek
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
LINUX
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
NO
問題(Question):
fseek的語法問題, 與BMP讀檔相關
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
if(Used_Colors_Number == 0) {
temp=(img->width*3)%4;
if(temp)
temp=4-temp;
for( i=(img->height-1) ; i>=0 ; i-- ) {
for( j=0 ; j<img->width ; j++ )
{
fscanf(fptr, "%c%c%c",&img->RGB[(i*width+j)*3+0],
&img->RGB[(i*width+j)*3+1], &img->RGB[(i*width+j)*3+2]);
}
fseek(fptr,temp,1);
}
}
else {
for( i=0 ; i<Used_Colors_Number ; i++ ) {
fscanf(fptr, "%c%c%c",&((Used_Color+i)->B), &((Used_Color+i)->G),
&((Used_Color+i)->R));
fseek(fptr,1,1);
}
temp=(width)%4;
for( i=(height-1) ; i>=0 ; i-- ) {
for( j=0 ; j<width ; j++ )
{
fscanf(fptr, "%c",&Pixel);
img->RGB[(i*width+j)*3+0] = Used_Color[Pixel].B;
img->RGB[(i*width+j)*3+1] = Used_Color[Pixel].G;
img->RGB[(i*width+j)*3+2] = Used_Color[Pixel].R;
}
fseek(fptr,temp,1);
}
}
補充說明(Supplement):
不懂的是, 為什麼fseek他那樣寫,
因為我上網查fseek沒人在第三個位置填入1,
我知道他fseek是怕圖檔一行超過4byte倍數的規定,
超過的部分想要用這個移,
但是我看不懂她為什麼第三個位置寫入1, 而且temp再換行的時候都不用加減運算@@
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.175.128.7
推
08/19 16:52, , 1F
08/19 16:52, 1F
→
08/19 16:53, , 2F
08/19 16:53, 2F
→
08/19 16:53, , 3F
08/19 16:53, 3F
→
08/19 16:54, , 4F
08/19 16:54, 4F
→
08/19 16:55, , 5F
08/19 16:55, 5F
→
08/19 16:58, , 6F
08/19 16:58, 6F
→
08/19 16:59, , 7F
08/19 16:59, 7F
→
08/19 17:07, , 8F
08/19 17:07, 8F
→
08/19 17:10, , 9F
08/19 17:10, 9F
→
08/19 17:17, , 10F
08/19 17:17, 10F
→
08/19 17:17, , 11F
08/19 17:17, 11F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章