Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        void buildImage()
        {
            if (busy)
            {
                return;
            }
            if (imagePixelated != null && (imagePixelated.Width == rect.Width && imagePixelated.Height == rect.Height))
            {
                return;
            }

            imagePixelated = null;
            this.Invalidate();

            new System.Threading.Thread(new System.Threading.ThreadStart(delegate() {
                ImageCreator newImage = new ImageCreator(rect.Width, rect.Height);
                for (int y = 0; y < newImage.Height; y++)
                {
                    for (int x = 0; x < newImage.Width; x++)
                    {
                        double sx = x / (double)newImage.Width;
                        double sy = y / (double)newImage.Height;

                        sx *= source.Width;
                        sy *= source.Height;

                        sx = Math.Max(0, sx);
                        sy = Math.Max(0, sy);

                        sx = Math.Min(sx, source.Width - 1);
                        sy = Math.Min(sy, source.Height - 1);

                        newImage.SetPixel(x, y, source.GetPixel((int)sx, (int)sy));
                    }
                }
                if (newImage.Width == rect.Width && newImage.Height == rect.Height)
                {
                    // Create image
                    Image tmp = newImage.Image;

                    lock (this) {
                        imagePixelated = newImage;
                    }
                    this.Invalidate();
                }
                else
                {
                    busy = false;
                    buildImage();
                }
            })).Start();
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Eyedropper_MouseUp(object sender, MouseEventArgs e)
        {
            if (state == State.Moving)
            {
                offset.X      = originaloffset.X + (e.X - originalMouse.X);
                offset.Y      = originaloffset.Y + (e.Y - originalMouse.Y);
                state         = State.Idle;
                timer.Enabled = true;
            }
            else if (state == State.Picking)
            {
                Color color = imagePixelated.GetPixel(e.X - rect.X, e.Y - rect.Y);

                ColorPicker cp = new ColorPicker();
                cp.Color = color;
                cp.Show();
                cp.Focus();

                this.Close();
            }
        }