Esempio n. 1
0
        private void animeView_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            float elapsedTime = 0;
            int   i           = -1;

            for (i = 0; i < animeCells.Count; i++)
            {
                elapsedTime += animeCells[i].durationMilliseconds;
                if (playTime <= elapsedTime)
                {
                    break;
                }
            }

            if (i < 0 || animeCells.Count <= i)
            {
                return;
            }

            AnimeCell cell = animeCells[i];

            if (!composedImageDict.ContainsKey(cell.key))
            {
                return;
            }

            Bitmap bmp  = composedImageDict[cell.key];
            SizeF  size = BitmapHandler.GetFittingSize(bmp, animeView.Width, animeView.Height);
            float  ox   = (animeView.Width - size.Width) * 0.5f;
            float  oy   = (animeView.Height - size.Height) * 0.5f;

            e.Graphics.DrawImage(bmp, ox, oy, size.Width, size.Height);
        }
Esempio n. 2
0
        private void refSkeletonCanvas_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            if (refSkeletonAnnotation == null)
            {
                return;
            }

            var size = BitmapHandler.GetFittingSize(refSkeletonAnnotation.bmp, refSkeletonCanvas.Width, refSkeletonCanvas.Height);

            refSkeletonCanvasTransform = new Matrix();
            refSkeletonCanvasTransform.Scale(size.Width / refSkeletonAnnotation.bmp.Width, size.Height / refSkeletonAnnotation.bmp.Height);

            e.Graphics.Transform = refSkeletonCanvasTransform;

            e.Graphics.DrawImage(refSkeletonAnnotation.bmp, Point.Empty);

            int radius = 10;

            foreach (JointAnnotation joint in refSkeletonAnnotation.joints)
            {
                Brush brush = JointBrush(joint.name, jointNameTextBox.Text, jointBrushDict);
                e.Graphics.FillEllipse(brush, joint.position.X - radius, joint.position.Y - radius, 2 * radius, 2 * radius);
            }

            if (refSkeletonNearestJoint != null)
            {
                e.Graphics.FillEllipse(Brushes.Red, refSkeletonNearestJoint.position.X - radius, refSkeletonNearestJoint.position.Y - radius, 2 * radius, 2 * radius);
            }
        }
Esempio n. 3
0
        private void DrawAnimeCells(Graphics g, Dictionary <string, Bitmap> imageDict, List <AnimeCell> cells, List <AnimeCell> addingCells, AnimeCell prevCell, List <AnimeCell> selectCells, int fw, int fh)
        {
            g.Clear(Color.White);

            int gw = fw / cellGridWidth;
            int gh = cells.Count / gw + (cells.Count % gw >= 1 ? 1 : 0);

            int idx = 0;

            for (int gy = 0; gy < gh; gy++)
            {
                for (int gx = 0; gx < gw; gx++)
                {
                    Rectangle rect = new Rectangle(gx * cellGridWidth, gy * cellGridHeight, cellWidth, cellHeight);

                    if (idx >= cells.Count)
                    {
                        continue;
                    }

                    g.FillRectangle(Brushes.LightGray, rect);
                    if (imageDict.ContainsKey(cells[idx].key))
                    {
                        Bitmap bmp  = imageDict[cells[idx].key];
                        SizeF  size = BitmapHandler.GetFittingSize(bmp, cellWidth, cellHeight);
                        float  ox   = (cellWidth - size.Width) * 0.5f;
                        float  oy   = (cellHeight - size.Height) * 0.5f;
                        g.DrawImage(bmp, rect.X + ox, rect.Y + oy, size.Width, size.Height);
                    }

                    idx++;
                }
            }

            foreach (var cell in selectCells)
            {
                if (prevCell != null && !cells.Contains(cell))
                {
                    continue;
                }
                int       i    = cells.IndexOf(cell);
                int       gx   = i % gw;
                int       gy   = i / gw;
                Rectangle rect = new Rectangle(gx * cellGridWidth, gy * cellGridHeight, cellWidth, cellHeight);
                g.DrawRectangle(cellHighlightPen, rect);
            }

            if (prevCell == null || cells.Contains(prevCell))
            {
                int i = prevCell == null ? -1 : cells.IndexOf(prevCell);
                i += 1;
                int       gx   = i % gw;
                int       gy   = i / gw;
                Rectangle rect = new Rectangle(gx * cellGridWidth, gy * cellGridHeight, 3, cellGridHeight);
                g.FillRectangle(Brushes.Black, rect);
            }
        }
Esempio n. 4
0
 private void referenceImageView_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.Clear(Color.White);
     if (composition.referenceImage != null)
     {
         SizeF size = BitmapHandler.GetFittingSize(composition.referenceImage, referenceImageView.Width, referenceImageView.Height);
         float ox   = -0.5f * (size.Width - referenceImageView.Width);
         float oy   = -0.5f * (size.Height - referenceImageView.Height);
         e.Graphics.DrawImage(composition.referenceImage, ox, oy, size.Width, size.Height);
     }
 }
Esempio n. 5
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            if (an == null)
            {
                return;
            }
            if (an.bmp == null)
            {
                return;
            }

            transform = new Matrix();
            var fitSize = BitmapHandler.GetFittingSize(an.bmp, pictureBox1.Width, pictureBox1.Height);

            transform.Scale(fitSize.Width / an.bmp.Width, fitSize.Height / an.bmp.Height);

            e.Graphics.Transform = transform;

            e.Graphics.Clear(Color.White);

            // bmp
            e.Graphics.DrawImage(an.bmp, Point.Empty);
            // joints
            foreach (JointAnnotation joint in an.joints)
            {
                e.Graphics.FillEllipse(Brushes.Orange, new RectangleF(joint.position.X - 5, joint.position.Y - 5, 10, 10));
            }
            // nearestJoint
            if (nearestJoint != null)
            {
                e.Graphics.FillEllipse(Brushes.Red, new RectangleF(nearestJoint.position.X - 5, nearestJoint.position.Y - 5, 10, 10));
            }
            // selectJoint
            if (selectJoint != null)
            {
                e.Graphics.FillEllipse(Brushes.Yellow, new RectangleF(selectJoint.position.X - 5, selectJoint.position.Y - 5, 10, 10));
            }
        }