/* Depending on how you approach your problem decomposition, you * may want to rewrite some of these lines, move them inside loops, * or move them inside helper functions, etc. * * TODO: rewrite this comment. */ int main() { GWindow gw; gw.setTitle("Fauxtoshop"); gw.setVisible(true); cout << "Welcome to Fauxtoshop!" << endl; cout << "Enter name of image file to open (or blank to quiet): "; string img_name; getline(cin, img_name); cout << "Opening image file, may take a minute..." << endl; GBufferedImage img; while (!openImageFromFilename(img, img_name)) { cout << "Can't open the file, please enter again: "; getline(cin, img_name); } gw.setSize(img.getWidth(), img.getHeight()); gw.add(&img,0,0); string menu = "Which image filter would you like to apply?\n" " 1 - Scatter\n" " 2 - Edge detection\n" " 3 - \"Green screen\" with another image\n" " 4 - Compare image with another image"; cout << menu << endl; string choice_str = "Your choice: "; int choice = getInteger(choice_str, choice_str); switch(choice) { case 1: scatter(img); break; case 2: edge_detection(img); break; case 3: green_screen(img); break; } int row, col; getMouseClickLocation(row, col); return 0; }
int main() { GWindow gw; double length = 200; int requiredOrder = 3;//It would be better range 0 - 6; double gwWidth = 2 * length; double gwHeight = 2 * length ; gw.setSize(gwWidth, gwHeight); int currentOrder = 0; GPoint centerPt((gwWidth / 2), (gwHeight / 2)); buildH(gw, currentOrder, requiredOrder, centerPt, length, 0); return 0; }
/* Depending on how you approach your problem decomposition, you * may want to rewrite some of these lines, move them inside loops, * or move them inside helper functions, etc. * * TODO: rewrite this comment. */ int main() { GWindow gw; gw.setTitle("Fauxtoshop"); gw.setVisible(true); GBufferedImage img; while (true) { ifstream infile; cout << "Welcome to Fauxtoshop!" << endl; string prompt = "Enter the name of image file to open (or blank to quit):"; string filename= openFile(infile, prompt, img); if (filename == "") break; gw.setSize(img.getWidth(), img.getHeight()); gw.add(&img,0,0); int choice = chooseFilter(); dealWithImage(img, choice); saveImage(img); } /*int row, col; getMouseClickLocation(row, col);*/ return 0; }
void gbufferedImageTest() { GWindow gw; gw.setSize(900, 700); gw.setTitle("Test"); GButton* button1 = new GButton("Click Me 1"); gw.add(button1, 250, 80); //GButton* button2 = new GButton("Click Me 2"); //gw.addToRegion(button2, "NORTH"); GLabel* label = new GLabel("test!"); gw.add(label, 10, 60); std::cout << "About to construct GBufferedImage." << std::endl; GBufferedImage* img = new GBufferedImage(10, 80, 200, 250); std::cout << "Done constructing GBufferedImage." << std::endl; gw.add(img, 50, 50); // gw.addToRegion(img, "SOUTH"); gw.setVisible(true); // GBufferedImage* img2 = new GBufferedImage(20, 20); // img2->fill(GBufferedImage::createRgbPixel(255, 0, 255)); // Grid<int> grid = img2->toGrid(); // cout << "grid of pixels before: " << grid << endl; // for (int y = 4; y <= 18; y++) { // for (int x = 2; x <= 9; x++) { // grid[y][x] = GBufferedImage::createRgbPixel(0, 255, 0); // } // } // cout << "grid of pixels after: " << grid << endl; // img2->fromGrid(grid); // gw.add(img2, 350, 20); GBufferedImage* img3 = new GBufferedImage(); img3->load("rainbow.png"); cout << "adding the image!" << endl; gw.add(img3, 10, 20); // pause(2000); cout << "start toGrid" << endl; Grid<int> grid3 = img3->toGrid(); cout << "end toGrid, start rgb shit" << endl; for (int y = 0; y < grid3.height(); y++) { for (int x = 0; x < grid3.width(); x++) { int red, green, blue; GBufferedImage::getRedGreenBlue(grid3[y][x], red, green, blue); grid3[y][x] = GBufferedImage::createRgbPixel(green, red, blue); } } cout << "end rgb shit, start fromGrid" << endl; img3->fromGrid(grid3); cout << "end fromGrid" << endl; pause(2000); return; // fill img->fill(0xff00ff); // purple std::cout << "About to setRGB on GBufferedImage." << std::endl; for (int y = 2; y < img->getHeight() - 2; y++) { for (int x = 5; x <= img->getWidth() - 5; x++) { img->setRGB(x, y, 0xffcc33); } } std::cout << "Done setting RGB on GBufferedImage." << std::endl; border(img); pause(500); std::cout << "About to resize on GBufferedImage." << std::endl; img->resize(100, 50); border(img); pause(500); std::cout << "About to resize on GBufferedImage." << std::endl; img->resize(200, 80); border(img); pause(500); std::cout << "About to setRGB on GBufferedImage." << std::endl; for (int y = 10; y < img->getHeight() - 10; y++) { for (int x = 10; x <= img->getWidth() - 10; x++) { img->setRGB(x, y, 0xff33cc); } } border(img); std::cout << "About to remove other shit." << std::endl; pause(200); gw.remove(label); gw.remove(button1); //gw.removeFromRegion(button2, "NORTH"); pause(200); std::cout << "About to remove GBufferedImage." << std::endl; pause(200); gw.remove(img); // gw.removeFromRegion(img, "SOUTH"); pause(200); std::cout << "Test complete." << std::endl; std::cout << std::endl; }