CSE-8A / PA8 / PA8.java
PA8.java
Raw
import java.awt.Color;

public class PA8 {

    // ------------------------------------------------------------------------
    // Tests
    // ------------------------------------------------------------------------


    public static void testHorizontalFlip()
    {
        Image img1 = new Image("res/pixel-heart.png");
        img1.explore();
        int w = img1.getWidth();
        int h = img1.getHeight();
        img1.flipHorizontalRect(0,0,(int)w/2 ,(int)h);
        img1.explore();

        //TODO : Add another test case

        Image img2 = new Image("res/cute_cat_and_dog_3.jpg");
        img2.explore();

        int a = img2.getWidth();
        int b = img2.getHeight();
        img2.flipHorizontalRect(0,0, (int)a, (int)b/2);
        img2.explore();

    }

    public static void testCustomFilter()
    {
//Filter on first image
//Starting inside image to out the right of image
        Image imgFilter1 = new Image("res/cat.jpg");
        imgFilter1.explore();

        int w = imgFilter1.getWidth();
        int h = imgFilter1.getHeight();

        imgFilter1.customFilter(100, 100, (int)w*2, (int)h/2);
        imgFilter1.explore();

//Filter on second image
//Regular inside Image alteration
        Image imgFilter2 = new Image ("res/crane.jpg");
        imgFilter2.explore();

        int a = imgFilter2.getWidth();
        int b = imgFilter2.getHeight();

        imgFilter2.customFilter(0, 0, (int)a/2, (int)b);
        imgFilter2.explore();

//Filter on 3rd Image
//Starting inside image to out of bound bottom 
        Image imgFilter3 = new Image ("res/dog.jpg");
        imgFilter3.explore();

        int c = imgFilter3.getWidth();
        int d = imgFilter3.getHeight();

        imgFilter3.customFilter(50, 50, (int)c/2, (int)d*2);
        imgFilter3.explore();


    }

    // ------------------------------------------------------------------------
    // Main Method
    // ------------------------------------------------------------------------

    public static void main(String[] args) {

        // testHorizontalFlip();

        // TODO: Call the test method for your custom filter

        testCustomFilter();

    }
}