定義箇所をunsigned char screen[Y_SIZE][X_SIZE][3],compress[Y_SIZE][X_SIZE/4][3];,書き込みをfwrite(compress,1,(X_SIZE/4)*Y_SIZE*3,fp);としてみたのですが,保存されませんでした・・・
この黒色の部分を消したいのですが,どなたかご教授お願いします.
以下に,作成したプログラムを載せておきます.
#include <stdio.h>
#include <stdlib.h>
#define X_SIZE 1916/*画像の横サイズを定義*/
#define Y_SIZE 181/*画像の縦サイズを定義*/
unsigned char screen[Y_SIZE][X_SIZE][3],compress[Y_SIZE][X_SIZE][3];
int main()
{
FILE *fp;
unsigned char header[54];
char input_file[100],henkan_file[100];
/*画像ファイル読み込み*/
printf("処理を行う画像ファイル名:.(拡張子:bmp)\n---");
scanf("%s",input_file);
printf("処理を行う画像ファイル:「 %s 」.\n\n",input_file);
fp=fopen(input_file,"rb");
if((fp=fopen(input_file,"rb"))==NULL){
printf("画像ファイルが正常に開けませんでした.\n");
exit(1);
}
fread(header,1,54,fp);
fread(screen,1,X_SIZE*Y_SIZE*3,fp);
fclose(fp);
/*サイズ変更*/
int x,y,i;
for(i=0;i<3;i++){
for(y=0;y<Y_SIZE;y++){
for(x=0;x<X_SIZE/4;x++){
compress[y][x][i]= (screen[y][x*4+0][i] +screen[y][x*4+1][i] +screen[y][x*4+2][i] +screen[y][x*4+3][i]) /4;
}
}
}
/*画像ファイル保存*/
printf("保存する画像ファイル名:.(拡張子:bmp)\n---");
scanf("%s",henkan_file);
fp=fopen(henkan_file,"wb");
if((fp=fopen(henkan_file,"wb"))==NULL){
printf("画像ファイルが正常に開けませんでした.\n");
exit(1);
}
fwrite(header,1,54,fp);
fwrite(compress,1,X_SIZE*Y_SIZE*3,fp);
fclose(fp);
printf("画像ファイル「 %s 」を保存しました.\n",henkan_file);
printf("全ての作業が終了しました.\n");
return 0;
}