SetPixel() 공개 메소드

public SetPixel ( int x, int y, System.Pixel colour ) : void
x int
y int
colour System.Pixel
리턴 void
예제 #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            int x = (int)((e.X - ClientRectangle.Left) / Image.ZoomScale);
            int y = (int)((e.Y - ClientRectangle.Top) / Image.ZoomScale);

            if (myMovingSelected)
            {
                if (myMovingLayer && myTempLayer == null && (x != myAnchorPos.X || y != myAnchorPos.Y))
                {
                    myTempLayer = new Layer(Image);
                    bool noSelection = mySelectedArea == 0;
                    for (int px = 0; px < Image.Width; ++px)
                    {
                        for (int py = 0; py < Image.Height; ++py)
                        {
                            if (noSelection || mySelectedPixels[px, py])
                            {
                                PixelSelect(px, py, CurrentLayer.Pixels[px, py] == Pixel.Empty);
                                myTempLayer.SetPixel(px, py, CurrentLayer.Pixels[px, py]);

                                if (!ModifierKeys.HasFlag(Keys.Control))
                                {
                                    CurrentLayer.SetPixel(px, py, Pixel.Empty);
                                }
                            }
                        }
                    }
                }

                UpdateMovedRect(x, y);
            }

            if (myDrawingPencil)
            {
                if (MouseButtons.HasFlag(MouseButtons.Left))
                {
                    DrawPencil(x, y, Image.CurrentPixel);
                }
                else
                {
                    DrawPencil(x, y, Pixel.Empty);
                }
            }

            if (mySelectingPixels || myDrawingBox)
            {
                UpdateBoxPreview(x, y);
            }
        }
예제 #2
0
        protected override void OnMouseMove( MouseEventArgs e )
        {
            int x = (int) ( ( e.X - ClientRectangle.Left ) / Image.ZoomScale );
            int y = (int) ( ( e.Y - ClientRectangle.Top ) / Image.ZoomScale );

            if ( myMovingSelected )
            {
                if ( myMovingLayer && myTempLayer == null && ( x != myAnchorPos.X || y != myAnchorPos.Y ) )
                {
                    myTempLayer = new Layer( Image );
                    bool noSelection = mySelectedArea == 0;
                    for ( int px = 0; px < Image.Width; ++px )
                    {
                        for ( int py = 0; py < Image.Height; ++py )
                        {
                            if ( noSelection || mySelectedPixels[ px, py ] )
                            {
                                PixelSelect( px, py, CurrentLayer.Pixels[ px, py ] == Pixel.Empty );
                                myTempLayer.SetPixel( px, py, CurrentLayer.Pixels[ px, py ] );

                                if( !ModifierKeys.HasFlag( Keys.Control ) )
                                    CurrentLayer.SetPixel( px, py, Pixel.Empty );
                            }
                        }
                    }
                }

                UpdateMovedRect( x, y );
            }

            if ( myDrawingPencil )
            {
                if ( MouseButtons.HasFlag( MouseButtons.Left ) )
                    DrawPencil( x, y, Image.CurrentPixel );
                else
                    DrawPencil( x, y, Pixel.Empty );
            }

            if ( mySelectingPixels || myDrawingBox )
                UpdateBoxPreview( x, y );
        }