Search in sources :

Example 61 with Rectangle

use of java.awt.Rectangle in project screenbird by adamhub.

the class RecorderTest method testCompileAudio.

/**
     * Test of compileAudio method, of class Recorder.
     * 
     */
//@Test
@Test
public void testCompileAudio() throws IOException {
    log("compileAudio");
    Recorder instance = new Recorder(new TestMeasurable());
    instance.setCaptureRectangle(new Rectangle(200, 100));
    instance.recordAudio();
    while (instance.getSecondsTime() < 10) {
    }
    instance.stopRecordingAudio();
    instance.compileAudio();
}
Also used : Rectangle(java.awt.Rectangle) Test(org.junit.Test)

Example 62 with Rectangle

use of java.awt.Rectangle in project screenbird by adamhub.

the class RecorderTest method testHasAudioToCompile.

/**
     * Test of hasAudioToCompile method, of class Recorder.
     * 
     */
//@Test
@Test
public void testHasAudioToCompile() {
    log("hasAudioToCompile");
    Recorder instance = new Recorder(new TestMeasurable());
    instance.setCaptureRectangle(new Rectangle(200, 100));
    instance.recordVideo();
    while (instance.getSecondsTime() < 10) {
    }
    instance.stopVideo();
    boolean result = instance.hasAudioToCompile();
    assertNotNull(result);
}
Also used : Rectangle(java.awt.Rectangle) Test(org.junit.Test)

Example 63 with Rectangle

use of java.awt.Rectangle in project screenbird by adamhub.

the class ImageUtilTest method testMarkAndCompress.

/**
     * Test of markAndCompress method, of class ImageUtil.
     */
@Test
public void testMarkAndCompress() {
    System.out.println("markAndCompress");
    File imageFile = generateTestImageFile(new Rectangle(0, 0, 600, 600));
    String imageSource = imageFile.getAbsolutePath();
    float compressionQuality = 1.0F;
    boolean mark = true;
    String markImageSource = watermarkRealFile.getAbsolutePath();
    ImageUtil.markAndCompress(imageSource, compressionQuality, mark, markImageSource);
    assert imageFile.exists() : "Image was not created properly";
    MediaUtil.open(imageSource);
    mark = false;
    imageFile = generateTestImageFile(new Rectangle(0, 0, 600, 600));
    imageSource = imageFile.getAbsolutePath();
    ImageUtil.markAndCompress(imageSource, compressionQuality, mark, markImageSource);
    assert imageFile.exists() : "Image was not created properly";
    MediaUtil.open(imageSource);
}
Also used : Rectangle(java.awt.Rectangle) File(java.io.File) Test(org.junit.Test)

Example 64 with Rectangle

use of java.awt.Rectangle in project screenbird by adamhub.

the class ImageUtilTest method generateTestImageFile.

/**
     * Generates screenshot for JUnit testing
     * @return 
     *      File pointer to screen shot
     */
private File generateTestImageFile(Rectangle captureArea) {
    if (captureArea == null) {
        //Get full screen if no defined area of screen capture is defined
        captureArea = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    }
    try {
        BufferedImage bufferedImage = generateTestImage(captureArea);
        Iterator iter = ImageIO.getImageWritersByFormatName("jpeg");
        ImageWriter writer = (ImageWriter) iter.next();
        ImageWriteParam iwp = writer.getDefaultWriteParam();
        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
        iwp.setCompressionQuality(1.0F);
        File imageFile = generateTempFile("jpeg");
        FileImageOutputStream stream = new FileImageOutputStream(imageFile);
        //Set up file access
        writer.setOutput(stream);
        //Create image
        IIOImage image = new IIOImage(bufferedImage, null, null);
        //write image
        writer.write(null, image, iwp);
        //Close image stream
        stream.close();
        return imageFile;
    } catch (IOException e) {
        System.err.println(e);
    }
    return null;
}
Also used : FileImageOutputStream(javax.imageio.stream.FileImageOutputStream) Rectangle(java.awt.Rectangle) Iterator(java.util.Iterator) ImageWriter(javax.imageio.ImageWriter) IOException(java.io.IOException) ImageWriteParam(javax.imageio.ImageWriteParam) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) IIOImage(javax.imageio.IIOImage)

Example 65 with Rectangle

use of java.awt.Rectangle in project screenbird by adamhub.

the class ImageUtilTest method testAddMark.

/**
     * Test of addMark method, of class ImageUtil.
     */
@Test
public void testAddMark() throws Exception {
    System.out.println("addMark");
    BufferedImage bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    String markImageSource = watermarkRealFile.getAbsolutePath();
    float alpha = 1.0F;
    int mark_position = ImageUtil.MARK_CENTER;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    mark_position = ImageUtil.MARK_LEFT_BOTTOM;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    mark_position = ImageUtil.MARK_LEFT_TOP;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    mark_position = ImageUtil.MARK_RIGHT_BOTTOM;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    mark_position = ImageUtil.MARK_RIGHT_TOP;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    mark_position = ImageUtil.MARK_CENTER;
    alpha = 0.75F;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    alpha = 0.50F;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    alpha = 0.25F;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
    alpha = 0.0F;
    bufferedImage = generateTestImage(new Rectangle(0, 0, 400, 400));
    ImageUtil.addMark(bufferedImage, markImageSource, alpha, mark_position);
    MediaUtil.open(writeBufferedImageToFile(bufferedImage, generateTempFile("jpeg")));
}
Also used : Rectangle(java.awt.Rectangle) BufferedImage(java.awt.image.BufferedImage) Test(org.junit.Test)

Aggregations

Rectangle (java.awt.Rectangle)809 Point (java.awt.Point)201 Dimension (java.awt.Dimension)81 BufferedImage (java.awt.image.BufferedImage)68 Graphics2D (java.awt.Graphics2D)65 Color (java.awt.Color)48 Insets (java.awt.Insets)47 ArrayList (java.util.ArrayList)37 Font (java.awt.Font)29 Test (org.junit.Test)28 IOException (java.io.IOException)27 GraphicsConfiguration (java.awt.GraphicsConfiguration)23 Paint (java.awt.Paint)23 GradientPaint (java.awt.GradientPaint)22 FontMetrics (java.awt.FontMetrics)21 Graphics (java.awt.Graphics)21 Rectangle2D (java.awt.geom.Rectangle2D)21 Robot (java.awt.Robot)19 File (java.io.File)19 PeakResult (gdsc.smlm.results.PeakResult)18