@@ -200,23 +200,15 @@ private void initComponents(final boolean standalone) {
200200 heightLabel = new JLabel ();
201201 heightField = new JTextField ();
202202 compressionLabel = new JLabel ();
203- compressionBox = new JComboBox ();
203+ compressionBox = new JComboBox < String > ();
204204 fpsLabel = new JLabel ();
205205 fpsField = new JTextField ();
206206 originalSizeCheckBox = new JCheckBox ();
207- // streamingLabel = new JLabel();
208- // streamingGroup = new ButtonGroup();
209- // noPreparationRadio = new JRadioButton();
210- // fastStartRadio = new JRadioButton();
211- // fastStartCompressedRadio = new JRadioButton();
212-
213- // FormListener formListener = new FormListener();
214207
215208 setDefaultCloseOperation (WindowConstants .DO_NOTHING_ON_CLOSE );
216209 addWindowListener (new WindowAdapter () {
217210 public void windowClosing (WindowEvent e ) {
218211 setVisible (false );
219- // System.exit(0);
220212 }
221213 });
222214 registerWindowCloseKeys (getRootPane (), new ActionListener () {
@@ -345,7 +337,7 @@ void select(File file) {
345337 compressionLabel .setText ("Compression:" );
346338 compressionBox .setFont (font );
347339 //compressionBox.setModel(new DefaultComboBoxModel(new String[] { "None", "Animation", "JPEG", "PNG" }));
348- compressionBox .setModel (new DefaultComboBoxModel (new String [] { "Animation" , "JPEG" , "PNG" }));
340+ compressionBox .setModel (new DefaultComboBoxModel < String > (new String [] { "Animation" , "JPEG" , "PNG" }));
349341
350342 fpsLabel .setFont (font );
351343 fpsLabel .setText ("Frame Rate:" );
@@ -635,9 +627,6 @@ public boolean accept(File f) {
635627
636628 // Check on first image, if we can actually do pass through
637629 if (originalSize ) {
638- // This was using ImageIcon, which can't handle some file types.
639- // For 2.1, switching to ImageIO (which is used for movie
640- // generation anyway) [fry 131008]
641630 BufferedImage temp = readImage (imgFiles [0 ]);
642631 if (temp == null ) {
643632 return new RuntimeException ("Coult not read " + imgFiles [0 ].getAbsolutePath ());
@@ -690,6 +679,11 @@ protected void done() {
690679 }//GEN-LAST:event_createMovie
691680
692681
682+ /**
683+ * Read an image from a file. ImageIcon doesn't don't do well with some file
684+ * types, so we use ImageIO. ImageIO doesn't handle TGA files created by
685+ * Processing, so this calls our own loadImageTGA().
686+ */
693687 private BufferedImage readImage (File file ) throws IOException {
694688 // Make sure that we're using a ClassLoader that's aware of the ImageIO jar
695689 //Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -709,87 +703,21 @@ private BufferedImage readImage(File file) throws IOException {
709703 }
710704 }
711705 */
712-
706+
713707 if (image == null ) {
714708 String path = file .getAbsolutePath ();
709+ String pathLower = path .toLowerCase ();
715710 // Might be an incompatible TGA or TIFF created by Processing
716- if (path . toLowerCase () .endsWith (".tga" )) {
711+ if (pathLower .endsWith (".tga" )) {
717712 return loadImageTGA (file );
718713
719- } else if (path . toLowerCase () .endsWith (".tif " )) {
714+ } else if (pathLower . endsWith ( ".tif" ) || pathLower .endsWith (".tiff " )) {
720715 throw new IOException ("Try TGA or PNG images instead of TIFF." );
721716 }
722717 }
723718 return image ;
724719 }
725720
726-
727- /*
728- static public void selectFolder(final Frame parentFrame,
729- final String prompt,
730- // final String callbackMethod,
731- final File defaultSelection,
732- // final Object callbackObject,
733- final SelectCallback callback) {
734- // EventQueue.invokeLater(new Runnable() {
735- // public void run() {
736- File selectedFile = null;
737-
738- if (System.getProperty("os.name").contains("Mac")) {
739- FileDialog fileDialog =
740- new FileDialog(parentFrame, prompt, FileDialog.LOAD);
741- System.setProperty("apple.awt.fileDialogForDirectories", "true");
742- fileDialog.setVisible(true);
743- System.setProperty("apple.awt.fileDialogForDirectories", "false");
744- String filename = fileDialog.getFile();
745- if (filename != null) {
746- selectedFile = new File(fileDialog.getDirectory(), fileDialog.getFile());
747- }
748- } else {
749- JFileChooser fileChooser = new JFileChooser();
750- fileChooser.setDialogTitle(prompt);
751- fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
752- if (defaultSelection != null) {
753- fileChooser.setSelectedFile(defaultSelection);
754- }
755-
756- int result = fileChooser.showOpenDialog(parentFrame);
757- if (result == JFileChooser.APPROVE_OPTION) {
758- selectedFile = fileChooser.getSelectedFile();
759- }
760- }
761- //selectCallback(selectedFile, callbackMethod, callbackObject);
762- callback.select(selectedFile);
763- // }
764- // });
765- }
766- */
767-
768-
769- // static private void selectCallback(File selectedFile,
770- // String callbackMethod,
771- // Object callbackObject) {
772- // try {
773- // Class<?> callbackClass = callbackObject.getClass();
774- // Method selectMethod =
775- // callbackClass.getMethod(callbackMethod, new Class[] { File.class });
776- // selectMethod.invoke(callbackObject, new Object[] { selectedFile });
777- //
778- // } catch (IllegalAccessException iae) {
779- // System.err.println(callbackMethod + "() must be public");
780- //
781- // } catch (InvocationTargetException ite) {
782- // ite.printStackTrace();
783- //
784- // } catch (NoSuchMethodException nsme) {
785- // System.err.println(callbackMethod + "() could not be found");
786- // }
787- // }
788-
789-
790- // private void streamingRadioPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_streamingRadioPerformed
791- // prefs.put("movie.streaming", evt.getActionCommand());
792- // }//GEN-LAST:event_streamingRadioPerformed
793721
794722 /** variable frame rate. */
795723 private void writeVideoOnlyVFR (File movieFile , File [] imgFiles , int width , int height , double fps , QuickTimeWriter .VideoFormat videoFormat , /*boolean passThrough,*/ String streaming ) throws IOException {
@@ -831,7 +759,8 @@ private void writeVideoOnlyVFR(File movieFile, File[] imgFiles, int width, int h
831759 if (false ) {
832760 qtOut .writeSample (0 , f , duration );
833761 } else {
834- BufferedImage fImg = ImageIO .read (f );
762+ //BufferedImage fImg = ImageIO.read(f);
763+ BufferedImage fImg = readImage (f );
835764 g .drawImage (fImg , 0 , 0 , width , height , null );
836765 if (i != 0 && Arrays .equals (data , prevData )) {
837766 prevImgDuration += duration ;
@@ -870,65 +799,6 @@ private void writeVideoOnlyVFR(File movieFile, File[] imgFiles, int width, int h
870799 }
871800 }
872801
873- /** fixed framerate. */
874- /*
875- private void writeVideoOnlyFFR(File movieFile, File[] imgFiles, int width, int height, double fps, QuickTimeWriter.VideoFormat videoFormat, boolean passThrough, String streaming) throws IOException {
876- File tmpFile = streaming.equals("none") ? movieFile : new File(movieFile.getPath() + ".tmp");
877- ProgressMonitor p = new ProgressMonitor(MovieMaker.this, "Creating " + movieFile.getName(), "Creating Output File...", 0, imgFiles.length);
878- Graphics2D g = null;
879- BufferedImage imgBuffer = null;
880- QuickTimeWriter qtOut = null;
881-
882- try {
883- int timeScale = (int) (fps * 100.0);
884- int duration = 100;
885- qtOut = new QuickTimeWriter(videoFormat == QuickTimeWriter.VideoFormat.RAW ? movieFile : tmpFile);
886- qtOut.addVideoTrack(videoFormat, timeScale, width, height);
887- //qtOut.setSyncInterval(0,0);
888- if (!passThrough) {
889- imgBuffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
890- g = imgBuffer.createGraphics();
891- g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
892- }
893- for (int i = 0; i < imgFiles.length && !p.isCanceled(); i++) {
894- File f = imgFiles[i];
895- p.setNote("Processing " + f.getName());
896- p.setProgress(i);
897-
898- if (passThrough) {
899- qtOut.writeSample(0, f, duration);
900- } else {
901- BufferedImage fImg = ImageIO.read(f);
902- if (fImg == null) {
903- continue;
904- }
905- g.drawImage(fImg, 0, 0, width, height, null);
906- qtOut.writeFrame(0, imgBuffer, duration);
907- }
908- }
909- if (streaming.equals("fastStart")) {
910- qtOut.toWebOptimizedMovie(movieFile, false);
911- tmpFile.delete();
912- } else if (streaming.equals("fastStartCompressed")) {
913- qtOut.toWebOptimizedMovie(movieFile, true);
914- tmpFile.delete();
915- }
916- qtOut.close();
917- qtOut = null;
918- } finally {
919- p.close();
920- if (g != null) {
921- g.dispose();
922- }
923- if (imgBuffer != null) {
924- imgBuffer.flush();
925- }
926- if (qtOut != null) {
927- qtOut.close();
928- }
929- }
930- }
931- */
932802
933803 private void writeAudioOnly (File movieFile , File audioFile , String streaming ) throws IOException {
934804 File tmpFile = streaming .equals ("none" ) ? movieFile : new File (movieFile .getPath () + ".tmp" );
@@ -1085,7 +955,8 @@ private void writeVideoAndAudio(File movieFile, File[] imgFiles, File audioFile,
1085955 if (false ) {
1086956 qtOut .writeSample (1 , imgFiles [imgIndex ], vsDuration );
1087957 } else {
1088- BufferedImage fImg = ImageIO .read (imgFiles [imgIndex ]);
958+ //BufferedImage fImg = ImageIO.read(imgFiles[imgIndex]);
959+ BufferedImage fImg = readImage (imgFiles [imgIndex ]);
1089960 if (fImg == null ) {
1090961 continue ;
1091962 }
@@ -1268,12 +1139,11 @@ header[17] image descriptor (packed bits)
12681139 break ;
12691140 case RGB :
12701141 pixel = 0xFF000000 |
1271- is .read () | (is .read () << 8 ) | (is .read () << 16 );
1272- //(is.read() << 16) | (is.read() << 8) | is.read();
1142+ is .read () | (is .read () << 8 ) | (is .read () << 16 );
12731143 break ;
12741144 case ARGB :
12751145 pixel = is .read () |
1276- (is .read () << 8 ) | (is .read () << 16 ) | (is .read () << 24 );
1146+ (is .read () << 8 ) | (is .read () << 16 ) | (is .read () << 24 );
12771147 break ;
12781148 }
12791149 for (int i = 0 ; i < num ; i ++) {
@@ -1291,13 +1161,13 @@ header[17] image descriptor (packed bits)
12911161 case RGB :
12921162 for (int i = 0 ; i < num ; i ++) {
12931163 pixels [index ++] = 0xFF000000 |
1294- is .read () | (is .read () << 8 ) | (is .read () << 16 );
1164+ is .read () | (is .read () << 8 ) | (is .read () << 16 );
12951165 }
12961166 break ;
12971167 case ARGB :
12981168 for (int i = 0 ; i < num ; i ++) {
12991169 pixels [index ++] = is .read () |
1300- (is .read () << 8 ) | (is .read () << 16 ) | (is .read () << 24 );
1170+ (is .read () << 8 ) | (is .read () << 16 ) | (is .read () << 24 );
13011171 }
13021172 break ;
13031173 }
@@ -1347,7 +1217,7 @@ public void run() {
13471217 private JLabel aboutLabel ;
13481218 private JButton chooseImageFolderButton ;
13491219 private JButton chooseSoundFileButton ;
1350- private JComboBox <? > compressionBox ;
1220+ private JComboBox <String > compressionBox ;
13511221 private JLabel compressionLabel ;
13521222// private JRadioButton fastStartCompressedRadio;
13531223// private JRadioButton fastStartRadio;
0 commit comments