Example #1
0
 public FrameImage(FrameImage frameImage)
 {
     //image = new Image(frameImage.getWidthImage(),
     //        frameImage.getHeightImage(), frameImage.image.getType());
     image = (Image)frameImage.getImage().Clone();
     //Graphics g = image.getGraphics();
     //g.drawImage(frameImage.image, 0, 0, null);
     name = frameImage.name;
 }
Example #2
0
 public void add(FrameImage frameImage, double timeToNextFrame)
 {
     ignoreFrames.Add(false);
     frameImages.Add(frameImage);
     delayFrames.Add(timeToNextFrame);
 }
Example #3
0
        public FrameImage getFrameImage(String name)
        {
            FrameImage frameImage = new FrameImage(instance.frameImages[name]);

            return(frameImage);
        }
Example #4
0
        public void LoadFrame()// throws IOException
        {
            frameImages = new Dictionary <string, FrameImage>();
            StreamReader br = new StreamReader(framefile);
            //FileReader fr = new FileReader(framefile);
            //BufferedReader br = new BufferedReader(fr);

            String line = null;

            if (br.ReadLine() == null)
            {
                MessageBox.Show("No data");
                throw new IOException();
            }
            else
            {
                //fr = new FileReader(framefile);
                br = new StreamReader(framefile);

                while ((line = br.ReadLine()).Equals(""))
                {
                    ;
                }
                int n = Convert.ToInt32(line);

                for (int i = 0; i < n; i++)
                {
                    FrameImage frame = new FrameImage();
                    while ((line = br.ReadLine()).Equals(""))
                    {
                        ;
                    }
                    frame.setName(line);

                    while ((line = br.ReadLine()).Equals(""))
                    {
                        ;
                    }
                    string[] str  = line.Split(new char[] { ' ' });
                    string   path = str[1];

                    while ((line = br.ReadLine()).Equals(""))
                    {
                        ;
                    }
                    str = line.Split(new char[] { ' ' });
                    int x = Convert.ToInt32(str[1]);

                    while ((line = br.ReadLine()).Equals(""))
                    {
                        ;
                    }
                    str = line.Split(new char[] { ' ' });
                    int y = Convert.ToInt32(str[1]);

                    while ((line = br.ReadLine()).Equals(""))
                    {
                        ;
                    }
                    str = line.Split(new char[] { ' ' });
                    int w = Convert.ToInt32(str[1]);

                    while ((line = br.ReadLine()).Equals(""))
                    {
                        ;
                    }
                    str = line.Split(new char[] { ' ' });
                    int h = Convert.ToInt32(str[1]);

                    //Image imageData = ImageIO.read(new File(path));
                    Image imageData = Image.FromFile(path);
                    //Image image = imageData.getSubimage(x, y, w, h);
                    //Bitmap bitmap = new Bitmap(imageData);
                    //Bitmap copy = bitmap.Clone(new Rectangle(x, y, w, h), imageData.PixelFormat);

                    Bitmap bmp = new Bitmap(w, h);
                    Graphics.FromImage(bmp).DrawImage(imageData, new Rectangle(0, 0, w, h), new Rectangle(x, y, w, h), GraphicsUnit.Pixel);
                    Image image = (Image)bmp;
                    frame.setImage(image);
                    instance.frameImages.Add(frame.getName(), frame);
                }
            }

            br.Close();
        }