函数调用实际code [英] function call with actual code
问题描述
我想要做的就是采取这种函数调用...
what I'm trying to do is take this function call...
assign_sum_to_pixel(¤t_pixel, sum);
和实际code,它调用这是该更换...
and replace it with the actual code that it calls which is this...
/*
* assign_ sum_ to_ pixel - Computes averaged pixel value in current_pixel
*/
static void assign_ sum_ to_ pixel (pixel *current_ pixel, pixel_ sum sum)
{
current_ pixel->red = (unsigned short) (sum.red/sum.num);
current_ pixel->green = (unsigned short) (sum.green/sum.num);
current_ pixel->blue = (unsigned short) (sum.blue/sum.num);
return;
}
我想出了是这样的...
What I came up with was this...
/*
* mysmooth1 - my smooth1
*/
char mysmooth1_descr[] = "my smooth1: My smooth1";
void mysmooth1(int dim, pixel *src, pixel *dst)
{
int i, j;
int ii, jj;
pixel_ sum sum;
pixel current_ pixel;
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j++)
{
initialize_ pixel_ sum (&sum);
for(ii = max(i-1, 0); ii <= min(i+1, dim-1); ii++)
for(jj = max(j-1, 0); jj <= min(j+1, dim-1); jj++)
accumulate_ sum(&sum, src[RIDX(ii, jj, dim)]);
{
***current_ pixel->red = (unsigned short) (sum.red/sum.num);
current_ pixel->green = (unsigned short) (sum.green/sum.num);
current_ pixel->blue = (unsigned short) (sum.blue/sum.num);***
***(These three lines above are the lines I inserted which is where the function call use to be)***
dst[RIDX(i, j, dim)] = return;
}
}
}
但是......由于某种原因,当我运行code将其不能工作给我这个错误
kernels.c:456: error: invalid type argument of â->â
kernels.c:457: error: invalid type argument of â->â
kernels.c:458: error: invalid type argument of â->â
kernels.c:459: warning: statement with no effect
在这里我添加了新的code ...这是正确
current_ pixel->red = (unsigned short) (sum.red/sum.num);
current_ pixel->green = (unsigned short) (sum.green/sum.num);
current_ pixel->blue = (unsigned short) (sum.blue/sum.num);
有人可以告诉我,如果我做错了什么......我是不是什么地方丢失括号?我不能正确初始化我的变量?再来不应该是底部等于为 DST [RIDX(I,J,DIM)]
任何帮助,意见,建议将不胜AP preciated。谢谢。
can someone tell me if I'm doing something wrong... Am I missing brackets somewhere? am I not initializing my variables correctly? is return not supposed to be at the bottom equaling to dst[RIDX(i, j, dim)]
any help, comments, suggestions would be greatly appreciated. Thank You.
推荐答案
您 current_pixel
是像素
,而previously你通过&放大器; current_pixel
,一个像素*
(指向像素)。所以,你现在需要使用 current_pixel.red
(以一个点),不可以 current_pixel-&GT;红
(带有右箭头),这需要在箭头的左手侧的指针;等等。
Your current_pixel
is a pixel
, while previously you passed ¤t_pixel
, a pixel *
(pointer to pixel). So, you now need to use current_pixel.red
(with a dot), not current_pixel->red
(with a "right-pointing arrow"), which needs a pointer on the left hand side of the arrow; and so forth.
这篇关于函数调用实际code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!