Results 1 to 5 of 5
  1. #1
    yeah is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default morphingMovie.java code---help

    I'm writing a java assignment which is to make a movie of morphing pictures.
    below is what I wrote,however, it didn't work out.
    anybody could help me please?

    Java Code:
    public class MorphingMovie
    {
      public static void main(String[] args)
      {
        //Get the starting picture and ending picture for the morphing
        String fileName1=FileChooser.pickAFile();
        Picture startPicture=new Picture(fileName1); 
        String fileName2=FileChooser.pickAFile();
        Picture endPicture=new Picture(fileName2);
        
        /**If the starting picture and ending picture are not the same size, 
          * print an error message and do not proceed with the rest of the program
          */
        if(!(startPicture.getWidth()==endPicture.getWidth()&&startPicture.getHeight()==endPicture.getHeight()))
        {
          SimpleOutput.showInformation("Error-The two pictures chosen are not in the same size, please choose two pictues in same size");
        }
        
        else
        {
          
          //Input the number of intermediate stages for the morphing from the user 
          int numStages=SimpleInput.getIntNumber("Enter integer number of intermediate stages to morph");
          
          //Input the name of the directory in which to store the movie
          String directory=SimpleInput.getString("Enter the directory where to store the movie");
          
          //Create an array of Picture objects that will hold the sequence of pictures for the morphing
          Picture[] pictureSequence=new Picture[numStages+2];
          
          //Store the starting and ending pictures in the array.
          pictureSequence[0]=startPicture;
          pictureSequence[pictureSequence.length-1]=endPicture;
          
          //Create intermediate pictures in the array
          for(int k=1;k<pictureSequence.length-1;k++)
          {
            Picture intermediate=startPicture;
            intermediate.morphStage(startPicture,endPicture,numStages,k);
            pictureSequence[k]=intermediate;
          }
          
          //Create the first morphing movie
          FrameSequencer frameSequencer = new FrameSequencer(directory); 
          for (int i = 0; i < pictureSequence.length; i++) 
          {
            frameSequencer.addFrame(pictureSequence[i]); 
          }
          
          //Play the movie 
          MoviePlayer movie1=new MoviePlayer(directory);
          movie1.playMovie(numStages);
        }
      }
    }
    Last edited by quad64bit; 11-15-2012 at 08:45 PM.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: morphingMovie.java code---help

    Hello and welcome! Please use [code][/code] tags when posting code so we can easily read it!

    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: morphingMovie.java code---help

    P.S. You didn't tell us what the problem was!

  4. #4
    yeah is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default Re: morphingMovie.java code---help

    sorry i'm new here, don't know how to use tags; btw, the problem is the frame pictures are not pictureSequencer[k],but all startPicture.

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: morphingMovie.java code---help

    Does morphStage() return something or is the return type void? If if returns something, then perhaps you just aren't saving it.

    Also, Picture intermediate=startPicture;

    If I understand this line, it means every single frame is morphed from the starting frame rather than the frame before? Wouldn't you start with the start frame, but then work from startFrame+1 and so on? No idea how that method works.

Similar Threads

  1. Replies: 16
    Last Post: 01-31-2012, 09:36 PM
  2. Translate Vb.net code into Java code
    By Radu in forum New To Java
    Replies: 5
    Last Post: 04-12-2011, 10:27 AM
  3. Replies: 0
    Last Post: 02-21-2011, 12:50 PM
  4. Convert java code to midlet code
    By coldvoice05 in forum New To Java
    Replies: 1
    Last Post: 08-12-2009, 12:14 PM
  5. Convert java code to midlet code
    By coldvoice05 in forum Advanced Java
    Replies: 1
    Last Post: 08-09-2009, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •