/*********************************************** * * file d:\cips\pattern.c * * Functions: This file contains * main * * Purpose: * I use this program to create simple * patterns in images for illustrations. * * External Calls: * gpcips.c - my_clear_text_screen * imageio.c * * Modifications: * 31 March 1991 - created * 17 May 1993 - made this a command * line driven program. * 19 September 1998 - modified to work with * all I O routines in imageio.c. * ***********************************************/ #include "cips.h" #undef STUFF #define DEGREESPERRADIAN 57.29577952 short **out_image; main(argc, argv) int argc; char *argv[]; { char name[80]; char *cc; double da, db, dc, dd; int alpha, beta; int count, i, ie, ii, il, j, jj, le, l, ll, k, new_ie, new_il, set_i, set_j, square_size, w; int ok = 0; long cols, rows; struct tiff_header_struct image_header; struct bmpfileheader bmp_file_header; struct bitmapheader bmheader; if(argc < 4 ){ printf("\n usage: pattern file-name " "length width\n"); exit(-1); } strcpy(name, argv[1]); l = atoi(argv[2]); w = atoi(argv[3]); /************************************** * * Pre Processing * **************************************/ cc = strstr(argv[1], ".tif"); if(cc != NULL){ /* create a tif */ ok = 1; image_header.lsb = 1; image_header.bits_per_pixel = 8; image_header.image_length = l; image_header.image_width = w;; image_header.strip_offset = 1000; rows = image_header.image_length; cols = image_header.image_width; create_allocate_tiff_file(argv[1], &image_header); } /* ends tif */ cc = strstr(argv[1], ".bmp"); if(cc != NULL){ /* create a bmp */ ok = 1; bmheader.height = l; bmheader.width = w; rows = bmheader.height; cols = bmheader.width; create_allocate_bmp_file(argv[1], &bmp_file_header, &bmheader); } /* ends tif */ if(ok == 0){ printf("\nERROR input file neither tiff nor bmp"); exit(0); } out_image = allocate_image_array(l, w); /************************************** * * Processing * **************************************/ for(i=0; i0; i=i-2) make_rectangle(i-2, i, 0, 100, j++, out_image); for(i=50, j=50, k=1; i>0, j<100; i=i-2, j=j+2) make_rectangle(i, 100, j, j+2, k++, out_image); make_square(33, 33, 44, 7, out_image); /* depth file with four levels */ for(i=0; i4 && i<11 && j>4 && j<17) out_image[i][j] = 200; else out_image[i][j] = 0; } } for(i=0; i1 && i<17 && j>4 && j<11) out_image[i][j] = 200; } } /* make a rectangle with a hole in it */ for(i=0; i=5 && i<=8 && j>=5 && j<=18) out_image[i][j] = 200; } } for(i=0; i=15 && i<=18 && j>=5 && j<=18) out_image[i][j] = 200; } } for(i=0; i=5 && j<=8 && i>=5 && i<=18) out_image[i][j] = 200; } } for(i=0; i=15 && j<=18 && i>=5 && i<=18) out_image[i][j] = 200; } } /* make the entire area white with a black hole in it good for interior outline */ for(i=0; i=10 && i<=15 && j>=10 && j<=18) out_image[i][j] = 0; else out_image[i][j] = 200; } } /* make a square */ for(i=0; i=8 && i<=18 && j>=8 && j<=18) out_image[i][j] = 200; else out_image[i][j] = 0; } } /* make a square with a hole in it for closing practice */ for(i=0; i=8 && i<=13 && j>=8 && j<=13) out_image[i][j] = 200; else out_image[i][j] = 0; } } out_image[10][10] = 0; out_image[11][10] = 0; /* make 2 small squares illustrate closing and special closing */ for(i=0; i=8 && i<=13 && j>=8 && j<=9) out_image[i][j] = 200; if( i>=8 && i<=13 && j>=11 && j<=13) out_image[i][j] = 200; } } /* make a rectangle */ for(i=0; i=8 && i<=18 && j>=4 && j<=18) out_image[i][j] = 200; else out_image[i][j] = 0; } } /* make a block letter A */ for(i=0; i=10 && i<=20 && j>=10 && j<=50) out_image[i][j] = 200; for(i=0; i=40 && i<=50 && j>=10 && j<=50) out_image[i][j] = 200; for(i=0; i=10 && i<=90 && j>=10 && j<=20) out_image[i][j] = 200; for(i=0; i=10 && i<=90 && j>=40 && j<=50) out_image[i][j] = 200; /* make a broken line */ for(i=0; i=10 && i<=11 && j>=5 && j<=18) out_image[i][j] = 200; out_image[10][11] = 0; out_image[11][11] = 0; /* make two squares joined together */ for(i=0; i=5 && i<=15 && j>=5 && j<=9) out_image[i][j] = 200; if( i>=5 && i<=15 && j>=12 && j<=17) out_image[i][j] = 200; } } out_image[10][10] = 200; out_image[10][11] = 200; /* make a texture, checkerboard of 100-200 with each square the size given by the variable square_size I'll do this a little different and let the user specify the square size as the last parameter on the line. */ sqaure_size = atoi(argv[4]); ii=0; jj=0; set_i=0; set_j=0; for(i=0; i square_size){ jj = 0; set_j++; } } /* ends loop over j */ jj=0; set_j=0; ii++; if(ii > square_size){ ii = 0; set_i++; } } /* ends loop over i */ /* create a random image 0-255 */ for(i=0; i 10 && j < 30) || (j > 50 && j < 70) || (j > 90 && j < 99) ) out_image[i][j] = 200; else out_image[i][j] = 50; } } /* make a blank image that is not zero */ for(i=0; i