main(int argc, char **argv) { GrayImage gim; if(argc != 3) error("main: wrong command line architecture"); /* read PGM image */ read_pgm_image(&gim, argv[1]); write_pbm_image(&gim, argv[2]); }
void main(int argc, char **argv) { char ofn[100], nfn[100]; BinImage bim, rim; Rectangle rect; if(argc != 2) error("main: wrong command line architecture"); /* read color image */ strcpy(ofn, argv[1]); read_pbm_image(&bim, ofn); printf("input upper-left corner of rectangle:"); scanf("%d %d", &rect.ul.x, &rect.ul.y); printf("input size of rectangle:"); scanf("%d %d", &rect.width, &rect.height); if(rect.ul.x + rect.width > bim.width) { printf("Rectangle specified is out of range horizontally, " "will shrink its width\n"); rect.width = bim.width-rect.ul.x; } if(rect.ul.y + rect.height > bim.height) { printf("Rectangle specified is out of range vertically, " "will shrink its height\n"); rect.height = bim.height-rect.ul.y; } /* binarize manually */ cut_rectangle(&bim, &rim, &rect); /* write binarized image */ printf("input PBM file name:"); scanf("%s", nfn); if(strcmp(nfn+strlen(nfn)-4, ".pbm")) strcat(nfn, ".pbm"); write_pbm_image(&rim, nfn); }
bool QPpmHandler::write(const QImage &image) { return write_pbm_image(device(), image, subType); }