我的最终功能之一有问题。我的目标是太对待一张照片。我在标题中声明:
#define PICTURESIZE 1024
typedef unsigned char Picture[PICTURESIZE][PICTURESIZE];
typedef unsigned char LinearBlocPicture[PICTURESIZE*PICTURESIZE];
我将此标头包含在另一个文件中,其中只有一个功能:
LinearBlocPicture picture2BlocVector (Picture image){
LinearBlocPicture pictureModify;
int curseurLinearBlocPicture = 0;
unsigned char blocPixel[8][8];
unsigned char* bufferLinearBlocPicture;
int x,y,i,j,k;
for(y=0; y < 1024; y=y+8) {
for(x=0; x < 1024; x=x+8) {
for(j=0; j < 8; j++) {
for(i=0; i<8; i++) {
blocPixel[i][j] = image[x+i][y+j];
}
}
bufferLinearBlocPicture = bloc2Vector (blocPixel);
for (k=0; k<64; k++){
pictureModify[curseurLinearBlocPicture+k] = bufferLinearBlocPicture[k];
}
curseurLinearBlocPicture = curseurLinearBlocPicture + 64;
}
}
return pictureModify;
}
这个函数应用我的处理,问题来自返回值,以及预期返回什么。当我尝试编译时,我得到了这个:
First line error: ‘picture2BlocVector’ declared as function returning an array
Application.c: In function ‘picture2BlocVector’:
Last line: warning: return makes integer from pointer without a cast
Last line: warning: function returns address of local variable
我不明白为什么返回类型有问题,因为我正确声明了我的类型 LinearBlocPicture。指针问题来自我认为的这一行:
pictureModify[curseurLinearBlocPicture+k] = bufferLinearBlocPicture[k];
我不确定是否可以这样做。谢谢你的帮助。