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();
}
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);
}
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);
}
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;
}
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")));
}
Aggregations