From: Koichi KAMICHI Date: Tue, 22 Feb 2005 14:35:57 +0000 (+0000) Subject: Change box-shape judgement method. Fix gray color painting method. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=4d210d15e7124bfef55cc17a0b566583298af5bc;p=chise%2Fkage.git Change box-shape judgement method. Fix gray color painting method. --- diff --git a/kagecgi/kageic.c b/kagecgi/kageic.c index 9f05720..01179b8 100755 --- a/kagecgi/kageic.c +++ b/kagecgi/kageic.c @@ -39,13 +39,13 @@ void icPolygon(kPoint *poly, int number){ } void icBox(int x1, int y1, int x2, int y2){ - kageCanvas[y1][x1] = kGray; - kageCanvas[y2][x1] = kGray; - kageCanvas[y1][x2] = kGray; - kageCanvas[y2][x2] = kGray; + if(kageCanvas[y1][x1] == kWhite){ kageCanvas[y1][x1] = kGray; } + if(kageCanvas[y2][x1] == kWhite){ kageCanvas[y2][x1] = kGray; } + if(kageCanvas[y1][x2] == kWhite){ kageCanvas[y1][x2] = kGray; } + if(kageCanvas[y2][x2] == kWhite){ kageCanvas[y2][x2] = kGray; } } void icDot(int x, int y){ - kageCanvas[y][x] = kGray; + if(kageCanvas[y][x] == kWhite){ kageCanvas[y][x] = kGray; } } diff --git a/kagecgi/kagetool.c b/kagecgi/kagetool.c index dbe6ad6..046781e 100755 --- a/kagecgi/kagetool.c +++ b/kagecgi/kagetool.c @@ -354,90 +354,119 @@ void CalcOptions(const KGString *in, int *mitsudo, int *flag, double *yoko, doub int kari, mode; int tempShotai; int *buf, strokes; - + *flag = 0; - DrawBox(); - tempShotai = kShotai; - kShotai = kGothic; - drawGlyph(in, 1); - kShotai = tempShotai; - DotsWidth(&dlx1, &drx1); - DotsHeight(&dly1, &dry1); + int value; + buf = convertStroke(in->str, buf, &strokes); - //check left side - k = 0; - l = 0; - for(i = 0; i < pngWidth; i++){ - flg = 0; - for(j = 0; j < kWidth; j++){ - if(kageCanvas[i][dlx1 + j] != kWhite) flg = 1; - } - if(flg == 1){ - k++; + //check left side (NEW) + value = 200; + for(i = 0; i < strokes; i++){ + switch(buf[i * 11]){ + case 6: + case 7: + if(buf[i * 11 + 9] < value){ value = buf[i * 11 + 9]; } + case 2: + case 12: + case 3: + if(buf[i * 11 + 7] < value){ value = buf[i * 11 + 7]; } + case 1: + if(buf[i * 11 + 5] < value){ value = buf[i * 11 + 5]; } + if(buf[i * 11 + 3] < value){ value = buf[i * 11 + 3]; } } - else{ - if(k > l) l = k; - k = 0; + } + for(i = 0; i < strokes; i++){ + if((buf[i * 11] == 1 || buf[i * 11] == 3) && // stroke #1 and #3 + buf[i * 11 + 3] == value && + buf[i * 11 + 5] == value && + (buf[i * 11 + 6] - buf[i * 11 + 4]) > pngWidth * 0.9 / 4){ + *flag = *flag | FLAG_FLAT_LEFT; } } - if(k > l) l = k; - - if(l > pngWidth * 0.9 / 4) *flag = *flag | 1; - - //check right side - k = 0; - l = 0; - for(i = 0; i < pngWidth; i++){ - flg = 0; - for(j = 0; j < kWidth; j++){ - if(kageCanvas[i][drx1 - j] != kWhite) flg = 1; + + //check right side (NEW) + value = 0; + for(i = 0; i < strokes; i++){ + switch(buf[i * 11]){ + case 6: + case 7: + if(buf[i * 11 + 9] > value){ value = buf[i * 11 + 9]; } + case 2: + case 12: + case 3: + if(buf[i * 11 + 7] > value){ value = buf[i * 11 + 7]; } + case 1: + if(buf[i * 11 + 5] > value){ value = buf[i * 11 + 5]; } + if(buf[i * 11 + 3] > value){ value = buf[i * 11 + 3]; } } - if(flg == 1) k++; - else{ - if(k > l) l = k; - k = 0; + } + for(i = 0; i < strokes; i++){ + if(buf[i * 11] == 1 && + buf[i * 11 + 3] == value && + buf[i * 11 + 5] == value && + (buf[i * 11 + 6] - buf[i * 11 + 4]) > pngWidth * 0.9 / 4){ + *flag = *flag | FLAG_FLAT_RIGHT; } } - if(k > l) l = k; - if(l > pngWidth * 0.9 / 4) *flag = *flag | 2; - - //check upper side - k = 0; - l = 0; - for(i = 0; i < pngWidth; i++){ - flg = 0; - for(j = 0; j < kWidth; j++){ - if(kageCanvas[dly1 + j][i] != kWhite) flg = 1; + //check upper side (NEW) + value = 200; + for(i = 0; i < strokes; i++){ + switch(buf[i * 11]){ + case 6: + case 7: + if(buf[i * 11 + 10] < value){ value = buf[i * 11 + 10]; } + case 2: + case 12: + case 3: + if(buf[i * 11 + 8] < value){ value = buf[i * 11 + 8]; } + case 1: + if(buf[i * 11 + 6] < value){ value = buf[i * 11 + 6]; } + if(buf[i * 11 + 4] < value){ value = buf[i * 11 + 4]; } } - if(flg == 1) k++; - else{ - if(k > l) l = k; - k = 0; + } + for(i = 0; i < strokes; i++){ + if(buf[i * 11] == 1 && + buf[i * 11 + 4] == value && + buf[i * 11 + 6] == value && + (buf[i * 11 + 5] - buf[i * 11 + 3]) > pngWidth * 0.9 / 4){ + *flag = *flag | FLAG_FLAT_TOP; } } - if(k > l) l = k; - - if(l > pngWidth * 0.9 / 4) *flag = *flag | 4; - - //check bottom side - k = 0; - l = 0; - for(i = 0; i < pngWidth; i++){ - flg = 0; - for(j = 0; j < kWidth; j++){ - if(kageCanvas[dry1 - j][i] != kWhite) flg = 1; + + //check bottom side (NEW) + value = 0; + for(i = 0; i < strokes; i++){ + switch(buf[i * 11]){ + case 6: + case 7: + if(buf[i * 11 + 10] > value){ value = buf[i * 11 + 10]; } + case 2: + case 12: + case 3: + if(buf[i * 11 + 8] > value){ value = buf[i * 11 + 8]; } + case 1: + if(buf[i * 11 + 6] > value){ value = buf[i * 11 + 6]; } + if(buf[i * 11 + 4] > value){ value = buf[i * 11 + 4]; } } - if(flg == 1) k++; - else{ - if(k > l) l = k; - k = 0; + } + for(i = 0; i < strokes; i++){ + if(buf[i * 11] == 1 && + buf[i * 11 + 4] == value && + buf[i * 11 + 6] == value && + (buf[i * 11 + 5] - buf[i * 11 + 3]) > pngWidth * 0.9 / 4){ + *flag = *flag | FLAG_FLAT_BOTTOM; } } - if(k > l) l = k; - - if(l > pngWidth * 0.9 / 4) *flag = *flag | 8; + + DrawBox(); + tempShotai = kShotai; + kShotai = kGothic; + drawGlyph(in, 1); + kShotai = tempShotai; + DotsWidth(&dlx1, &drx1); + DotsHeight(&dly1, &dry1); //count black dots *mitsudo = 0; @@ -486,7 +515,7 @@ void CalcOptions(const KGString *in, int *mitsudo, int *flag, double *yoko, doub } //use user defined option if it exists - buf = convertStroke(in->str, buf, &strokes); + //buf = convertStroke(in->str, buf, &strokes); for(i = 0; i < strokes; i++){ if(buf[i * 11 + 0] % 10 == 0){ if(buf[i * 11 + 1] != 0) *yoko = (double)(buf[i * 11 + 1]) * 0.1;