Commit 3083cfe8 authored by angermue's avatar angermue

Improvement of PodcastCreator.java for providing smooth animations including annotations.

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@39 0463f305-d864-43cb-8a47-61cf597d4139
parent 46534b0a
// TeleTeachingTool - Presentation Recording With Automated Indexing
//
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universitt Mnchen
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit�t M�nchen
//
// This file is part of TeleTeachingTool.
//
......@@ -141,7 +141,37 @@ public class GraphicsContext extends JComponent implements MessageConsumer {
// does not allow getGraphics() :-(
return memImage.getScaledInstance(prefs.framebufferWidth, prefs.framebufferHeight, Image.SCALE_FAST);
}
/**
* Creates screenshot of current graphics contect including annotations, whiteboard pages, and the cursor.
*
* @see PodcastCreator#createPodcast
* @see GraphicsContext#getScreenshotWithoutAnnotations
*/
public BufferedImage getScreenshot() {
//Create a buffered image using the default color model
BufferedImage screenshot = new BufferedImage(prefs.framebufferWidth, prefs.framebufferHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = screenshot.getGraphics();
if (isWhiteboardEnabled()) {
//Create whiteboard page
g.setColor(Color.WHITE);
g.fillRect(0, 0, prefs.framebufferWidth, prefs.framebufferHeight);
} else {
//Draw desktop
g.drawImage(memImage, 0, 0, null);
}
paintAnnotations((Graphics2D)g); //Paint annotation
// display cursor
if (showSoftCursor) {
int x0 = cursorX - hotX, y0 = cursorY - hotY;
Rectangle r = new Rectangle(x0, y0, cursorWidth, cursorHeight);
if (r.intersects(new Rectangle(0,0,screenshot.getWidth(),screenshot.getHeight()))) {
g.drawImage(softCursor, x0, y0, null);
}
}
return screenshot;
}
//MODMSG : changed return type to BufferedImage
public BufferedImage getScreenshotWithoutAnnotations() {
BufferedImage screenshot;
......
// TeleTeachingTool - Presentation Recording With Automated Indexing
//
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universitt Mnchen
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit�t M�nchen
//
// This file is part of TeleTeachingTool.
//
......@@ -23,7 +23,10 @@
package ttt;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
......@@ -155,7 +158,90 @@ public class ImageCreator {
return set.toArray(new String[0]);
}
/**
* Convenience method that returns a scaled instance of the provided {@code
* BufferedImage}.
*
* http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
*
* @param image
* the original image to be scaled
* @param targetWidth
* the desired width of the scaled instance, in pixels
* @param targetHeight
* the desired height of the scaled instance, in pixels
* @param hint
* one of the rendering hints that corresponds to {@code
* RenderingHints.KEY_INTERPOLATION} (e.g. {@code
* RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR}, {@code
* RenderingHints.VALUE_INTERPOLATION_BILINEAR}, {@code
* RenderingHints.VALUE_INTERPOLATION_BICUBIC})
* @param higherQuality
* if true, this method will use a multi-step scaling technique
* that provides higher quality than the usual one-step technique
* (only useful in downscaling cases, where {@code targetWidth}
* or {@code targetHeight} is smaller than the original
* dimensions, and generally only when the {@code BILINEAR} hint
* is specified)
* @return a scaled version of the original {@code BufferedImage}
*/
public static BufferedImage getScaledInstance(BufferedImage image,
int targetWidth, int targetHeight, Object hint,
boolean higherQuality)
{
int type = (image.getTransparency() == Transparency.OPAQUE) ? BufferedImage.TYPE_INT_RGB
: BufferedImage.TYPE_INT_ARGB;
BufferedImage ret = (BufferedImage) image;
int w, h;
if (higherQuality)
{
// Use multi-step technique: start with original size, then
// scale down in multiple passes with drawImage()
// until the target size is reached
w = image.getWidth();
h = image.getHeight();
} else
{
// Use one-step technique: scale directly from original
// size to target size with a single drawImage() call
w = targetWidth;
h = targetHeight;
}
do
{
if (higherQuality && w > targetWidth)
{
w /= 2;
if (w < targetWidth)
{
w = targetWidth;
}
}
if (higherQuality && h > targetHeight)
{
h /= 2;
if (h < targetHeight)
{
h = targetHeight;
}
}
BufferedImage tmp = new BufferedImage(w, h, type);
Graphics2D g2 = tmp.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
g2.drawImage(ret, 0, 0, w, h, null);
g2.dispose();
ret = tmp;
} while (w != targetWidth || h != targetHeight);
return ret;
}
public static void main(String args[]) {
listFormats();
}
}
......@@ -51,16 +51,16 @@ public class LameEncoder {
}
/**Checks whether lame is available.
* @return True if lame is available.
/**Checks whether lame is available
* @return True if lame is available
* */
public static boolean isLameAvailable() {
return Exec.getCommand(LAME) != null;
}
/**Allows converting audio files using lame.
* @return True: Conversion succeeded.<br>False: Canceled by user.
/**Allows converting audio files using lame
* @return True: Conversion succeeded.<br>False: Canceled by user
*/
public static boolean convertAudioFile(File inFile, File outFile, String options, boolean batch) throws Exception {
......@@ -129,8 +129,8 @@ public class LameEncoder {
}
/**Allows converting audio files using lame determining suitable options automatically.
* @return True: Conversion succeeded.<br>False: Canceled by user.
/**Allows converting audio files using lame determining suitable options automatically
* @return True: Conversion succeeded.<br>False: Canceled by user
*/
public static boolean convertAudioFile(File inFile, File outFile, boolean batch) throws Exception {
......
This diff is collapsed.
......@@ -142,22 +142,6 @@ public class PostProcessorPanel extends GradientPanel {
}
if (PodcastCreator.isCreationPossible(recording)) {
mp4CheckBox.setToolTipText("generate a mp4 podcast of this recording");
if (recording.getExistingFileBySuffix("html").isDirectory() == false) {
mp4CheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent event) {
try {
//if there is no html script it must be created before creating the podcast
if (mp4CheckBox.isSelected()) {
if (PostProcessorPanel.this.recording.getExistingFileBySuffix("html").isDirectory() == false) {
htmlCheckBox.setSelected(true);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
} else {
mp4CheckBox.setToolTipText("generating a mp4 podcast requires ffmpeg, mp4box, and an audio file");
mp4CheckBox.setSelected(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment