Ejemplo n.º 1
0
        private void DrawImageFiltering(Graphics graphics, DataManipulator manipulator)
        {
            if (data.image == null || data.Points.Count < 3)
            {
                return;
            }

            float angle = manipulator.CalculateAngle() * (float)Math.PI / 180f;

            Color[,] colors = PrepareColorTable(data.colorMap, ref angle);
            colors          = ShearX(colors, angle);
            colors          = ShearY(colors, angle);
            colors          = ShearX(colors, angle);

            PointF point  = new PointF(data.BezierPoints[data.index, 0], data.BezierPoints[data.index, 1]);
            PointF center = new PointF(colors.GetLength(0) / 2, colors.GetLength(1) / 2);

            for (int i = 0; i < colors.GetLength(0); i++)
            {
                for (int j = 0; j < colors.GetLength(1); j++)
                {
                    if (colors[i, j] == Color.Transparent)
                    {
                        continue;
                    }
                    (float, float)vec = (i - center.X, j - center.Y);
                    graphics.DrawRectangle(new Pen(colors[i, j]), (int)(point.X + vec.Item1), (int)(point.Y + vec.Item2), 1, 1);
                }
            }
        }
Ejemplo n.º 2
0
 public Form1()
 {
     InitializeComponent();
     data              = new DataProvider(pictureBox1.Width, pictureBox1.Height, pictureBox2.Width, pictureBox2.Height);
     drawer            = new BitmapDrawer(data);
     manipulator       = new DataManipulator(data, drawer);
     checkBox1.Checked = true;
     pictureBox2.Image = data.miniature;
 }
Ejemplo n.º 3
0
        private void DrawImageWinForms(Graphics graphics, DataManipulator manipulator)
        {
            if (data.image == null || data.Points.Count < 3)
            {
                return;
            }

            PointF point = new PointF(data.BezierPoints[data.index, 0] - data.image.Width / 2, data.BezierPoints[data.index, 1] - data.image.Height / 2);

            graphics.TranslateTransform((float)(point.X + data.image.Width / 2), (float)(point.Y + data.image.Height / 2));

            graphics.RotateTransform(manipulator.CalculateAngle());

            graphics.TranslateTransform(-(float)(point.X + data.image.Width / 2), -(float)(point.Y + data.image.Height / 2));

            graphics.DrawImage(data.image, point);
        }
Ejemplo n.º 4
0
        private void DrawImageNaive(Graphics graphics, DataManipulator manipulator)
        {
            if (data.image == null || data.Points.Count < 3)
            {
                return;
            }

            DirectBitmap image  = data.directImage;
            PointF       point  = new PointF(data.BezierPoints[data.index, 0], data.BezierPoints[data.index, 1]);
            PointF       center = new PointF(image.Width / 2, image.Height / 2);
            float        angle  = manipulator.CalculateAngle() * (float)Math.PI / 180f;

            for (int i = 0; i < image.Width; i++)
            {
                for (int j = 0; j < image.Height; j++)
                {
                    (float, float)vec  = (i - center.X, j - center.Y);
                    (float, float)vec2 = (vec.Item1 * (float)Math.Cos(angle) - vec.Item2 * (float)Math.Sin(angle), vec.Item1 *(float)Math.Sin(angle) + vec.Item2 * (float)Math.Cos(angle));
                    graphics.DrawRectangle(new Pen(image.GetPixel(i, j)), (int)(point.X + vec2.Item1), (int)(point.Y + vec2.Item2), 1, 1);
                }
            }
        }