Re: 10267 - Graphical Editor
Posted: Thu Apr 16, 2009 9:40 pm
Yes!! That certainly was a bad mistake... thank you for that!vahid sanei wrote:you should swap (x1 and x2) and( y1 and y2) hereCode: Select all
void K(int X1,int Y1, int X2, int Y2,char C){ int i; for(i=X1;i<X2;i++){V(i,Y1,Y2,C);} }

I believe this is not the case. If you take a look at the way I initialize the bitmap (B) I make sure it has two more rows and two more columns. I do that so as to have the margins initialized with '\0', a character I presume I will never receive as colour input. So every time the fill command checks the B[a] == oc condition, it will always find it to be false since no colour can be equal to '\0'. Think of the '\0's as a protective wall around the bitmap.vahid sanei wrote:i found another problem in your code
i think this functionshould check X -- > is >= 1 and <=mCode: Select all
void F(int X, int Y, char C) { char oc; oc = B[Y][X]; L(X,Y,C); if(C==oc){return;} // same colour if(B[Y+1][X]==oc){ F(X,Y+1,C); } if(B[Y][X-1]==oc){ F(X-1,Y,C); } if(B[Y][X+1]==oc){ F(X+1,Y,C); } if(B[Y-1][X]==oc){ F(X,Y-1,C); } }
and
Y is >=1 and <= n
You can find it here:
Code: Select all
void I(M,N){
int i,j;
c = M; r = N;
B = (char**)malloc((N+2)*sizeof(char *));
for(i=0;i<N+2;i++){ B[i] = (char *)malloc((M+2)*sizeof(char));}
for(i=0;i<N+2;i++){
for(j=0;j<M+2;j++){
if(i==0||i==N+1||j==0||j==M+1){B[i][j] = '\0';}
else{ B[i][j] = '0'; }
}
}
}
Again thanks for the answer, but still I get that terrible RE...
