13 #include <QGraphicsScene>
28 for (
int i = 0; i <
image.width(); i++){
29 for (
int j = 0; j <
image.height(); j++){
115 int boundarypixel[6];
116 QImage image_tmp_clear;
117 QColor special_color_for_marking;
119 bool stop_inner_while;
133 stop_inner_while =
false;
146 for (n = 0; n < 6; n++) boundarypixel[n] = 0;
149 image_tmp_clear =
image;
152 &&(
point.toPoint().y() >= 0)
156 while (stop ==
false){
159 if (
point.toPoint().x() + i <
image.width() - 1){
180 x =
point.toPoint().x() + i;
181 y =
point.toPoint().y();
187 while (stop_inner_while ==
false){
189 if (qAlpha(
image.pixel(x - 1, y + 0)) ==
alpha){
190 boundarypixel[2] = 1;
193 boundarypixel[2] = 0;
195 if (qAlpha(
image.pixel(x + 0, y + 1)) ==
alpha){
196 boundarypixel[3] = 1;
199 boundarypixel[3] = 0;
201 if (qAlpha(
image.pixel(x + 1, y - 0)) ==
alpha){
202 boundarypixel[4] = 1;
205 boundarypixel[4] = 0;
207 if (qAlpha(
image.pixel(x + 0, y - 1)) ==
alpha){
208 boundarypixel[5] = 1;
211 boundarypixel[5] = 0;
214 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
215 if (zero_decision == 2) x--;
216 if (zero_decision == 3) y++;
217 if (zero_decision == 4) x++;
218 if (zero_decision == 5) y--;
219 if (zero_decision == 6) x--;
220 if (zero_decision == 7) x--;
221 if (zero_decision == 8) y--;
222 if (zero_decision == 9) y++;
223 if (zero_decision == 10) y++;
224 if (zero_decision == 11) x++;
225 if (zero_decision == 12) x--;
226 if (zero_decision == 13) y--;
227 if (zero_decision == 14) x++;
228 if (zero_decision == 15) y++;
231 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
235 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
239 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
243 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
247 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
251 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
255 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
259 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
263 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
267 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
271 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
275 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
279 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
283 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
288 for (n = 0; n < 6; n++) boundarypixel[n] = 0;
290 if ((x<0)||(y>
image.width()))
break;
294 image_tmp_clear.setPixel(x,y,special_color_for_marking.rgba());
296 if (break_condition ==
image.width()*
image.height()) stop_inner_while =
true;
297 if ((x == start_x)&&(y == start_y)) stop_inner_while =
true;
306 if ((x == start_x)&&(y == start_y)){
309 for (n = 0; n <
image.height(); n++){
311 for (k = 0; k <
image.width(); k++){
312 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()){
320 if (row_counter > 1){
321 for (k = 0; k <
image.width(); k++){
323 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) row_counter--;
325 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) on =
false;
327 if ((image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())&&
328 (image_tmp_clear.pixel(k+1,n) != special_color_for_marking.rgba()))
337 if (row_counter == 0) on =
false;
348 for (n = 0; n <
image.height(); n++){
349 for (k = 0; k <
image.width(); k++){
350 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())
379 for (j = 0; j <
image.height() -
point.toPoint().y(); j++){
384 image.setPixel(
point.toPoint().x() + i,
point.toPoint().y() + j, tmp.rgba());
385 if (
point.toPoint().x() + i <
image.width() - 1){
394 for (j = 0; j <
image.height() -
point.toPoint().y(); j++){
399 image.setPixel(
point.toPoint().x() + i,
point.toPoint().y() + j, tmp.rgba());
400 if (
point.toPoint().x() + i > - 1){
409 for (j = 1; j <
point.toPoint().y() + 1; j++){
414 image.setPixel(
point.toPoint().x() + i,
point.toPoint().y() - j, tmp.rgba());
415 if (
point.toPoint().x() + i <
image.width()-1){
424 for (j = 1; j <
point.toPoint().y()+1; j++){
429 image.setPixel(
point.toPoint().x() + i,
point.toPoint().y() - j, tmp.rgba());
430 if (
point.toPoint().x() + i > 0){
447 int boundarypixel[6];
448 QImage image_tmp_clear;
449 QColor special_color_for_marking;
451 bool stop_inner_while;
465 stop_inner_while =
false;
478 for (n = 0; n < 6; n++) boundarypixel[n] = 0;
481 image_tmp_clear =
image;
484 &&(
point.toPoint().y() >= 0)
488 while (stop ==
false){
491 if (
point.toPoint().x() + i <
image.width() - 1){
512 x =
point.toPoint().x() + i;
513 y =
point.toPoint().y();
519 while (stop_inner_while ==
false){
521 if (qAlpha(
image.pixel(x - 1, y + 0)) !=
alpha){
522 boundarypixel[2] = 1;
525 boundarypixel[2] = 0;
527 if (qAlpha(
image.pixel(x + 0, y + 1)) !=
alpha){
528 boundarypixel[3] = 1;
531 boundarypixel[3] = 0;
533 if (qAlpha(
image.pixel(x + 1, y - 0)) !=
alpha){
534 boundarypixel[4] = 1;
537 boundarypixel[4] = 0;
539 if (qAlpha(
image.pixel(x + 0, y - 1)) !=
alpha){
540 boundarypixel[5] = 1;
543 boundarypixel[5] = 0;
546 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
547 if (zero_decision == 2) x--;
548 if (zero_decision == 3) y++;
549 if (zero_decision == 4) x++;
550 if (zero_decision == 5) y--;
551 if (zero_decision == 6) x--;
552 if (zero_decision == 7) x--;
553 if (zero_decision == 8) y--;
554 if (zero_decision == 9) y++;
555 if (zero_decision == 10) y++;
556 if (zero_decision == 11) x++;
557 if (zero_decision == 12) x--;
558 if (zero_decision == 13) y--;
559 if (zero_decision == 14) x++;
560 if (zero_decision == 15) y++;
563 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
567 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
571 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
575 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
579 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
583 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
587 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
591 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
595 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
599 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
603 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
607 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
611 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
615 if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
619 if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
623 for (n = 0; n < 6; n++) boundarypixel[n] = 0;
625 if ((x<0)||(y>
image.width()))
break;
629 image_tmp_clear.setPixel(x,y,special_color_for_marking.rgba());
631 if (break_condition ==
image.width()*
image.height()) stop_inner_while =
true;
632 if ((x == start_x)&&(y == start_y)) stop_inner_while =
true;
641 if ((x == start_x)&&(y == start_y)){
644 for (n = 0; n <
image.height(); n++){
646 for (k = 0; k <
image.width(); k++){
647 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()){
655 if (row_counter > 1){
656 for (k = 0; k <
image.width(); k++){
658 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) row_counter--;
660 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) on =
false;
662 if ((image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())&&
663 (image_tmp_clear.pixel(k+1,n) != special_color_for_marking.rgba()))
672 if (row_counter == 0) on =
false;
683 for (n = 0; n <
image.height(); n++){
684 for (k = 0; k <
image.width(); k++){
685 if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())
715 for (j = 0; j <
image.height() -
point.toPoint().y(); j++){
720 if (
point.toPoint().x() + i <
image.width()-1){
729 for (j = 0; j <
image.height() -
point.toPoint().y(); j++){
734 if (
point.toPoint().x() + i > 0){
743 for (j = 1; j <
point.toPoint().y()+1; j++){
748 if (
point.toPoint().x() + i <
image.width()-1){
757 for (j = 1; j <
point.toPoint().y()+1; j++){
762 if (
point.toPoint().x() + i > 0){
796 for (
int i = 0; i <
image.width(); i++){
797 for (
int j = 0; j <
image.height(); j++){