Esempio n. 1
0
        public override void FillRect(Geometry.Rectangle rect, Geometry.Color color)
        {
            CheckInFrame("FillRect");

            mGraphics.FillRectangle(new SolidBrush(Interop.Convert(color)),
                                    Interop.Convert(rect));
        }
Esempio n. 2
0
        public override void Clear(Geometry.Color color, Geometry.Rectangle destRect)
        {
            CheckInFrame("Clear");

            mGraphics.FillRectangle(
                new SolidBrush(Interop.Convert(color)), Interop.Convert(destRect));
        }
Esempio n. 3
0
        public override void DrawRect(Geometry.Rectangle rect, Geometry.Color color)
        {
            CheckInFrame("DrawRect");

            mGraphics.DrawRectangle(new Pen(Interop.Convert(color)),
                                    Interop.Convert(rect));
        }
Esempio n. 4
0
        public override void SetSourceSurface(SurfaceImpl surf, Geometry.Rectangle srcRect)
        {
            mImage.Dispose();

            mImage = new Bitmap(srcRect.Width, srcRect.Height);
            Graphics g = Graphics.FromImage(mImage);

            g.DrawImage((surf as Drawing_Surface).mImage,
                        new Rectangle(Point.Empty, Interop.Convert(srcRect.Size)),
                        Interop.Convert(srcRect), GraphicsUnit.Pixel);

            g.Dispose();

            System.Diagnostics.Debug.Assert(mImage != null);
        }
Esempio n. 5
0
        public override PixelBuffer ReadPixels(PixelFormat format, Geometry.Rectangle rect)
        {
            BitmapData data = mImage.LockBits(Interop.Convert(rect), ImageLockMode.ReadOnly,
                                              System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            if (format == PixelFormat.Any)
            {
                format = PixelFormat.BGRA8888;
            }

            PixelBuffer buffer = new PixelBuffer(format, rect.Size);

            byte[] bytes = new byte[4 * rect.Width * rect.Height];

            Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);

            mImage.UnlockBits(data);

            buffer.SetData(bytes, PixelFormat.BGRA8888);

            return(buffer);
        }
Esempio n. 6
0
 public override void SetClipRect(Geometry.Rectangle newClipRect)
 {
     mGraphics.SetClip(Interop.Convert(newClipRect));
 }
Esempio n. 7
0
        public override void FillRect(Geometry.Rectangle rect, Geometry.Gradient color)
        {
            CheckInFrame("FillRect");

            FillRect(rect, color.AverageColor);
        }
Esempio n. 8
0
 public override SurfaceImpl CarveSubSurface(Geometry.Rectangle srcRect)
 {
     return(new Drawing_Surface(mImage, Interop.Convert(srcRect)));
 }
Esempio n. 9
0
        private void Draw(SurfaceState s, SurfaceDrawInstance inst)
        {
            mDisplay.CheckInFrame("Surface.Draw");
            System.Diagnostics.Debug.Assert(mImage != null);

            Geometry.SizeF  displaySize    = s.GetDisplaySize(SurfaceSize);
            Geometry.PointF rotationCenter = s.GetRotationCenter(displaySize);

            Drawing_Display disp  = Display.Impl as Drawing_Display;
            Graphics        g     = disp.FrameGraphics;
            GraphicsState   state = g.Save();

            Geometry.PointF translatePoint = Origin.CalcF(s.DisplayAlignment, displaySize);

            if (displaySize.Width < 0)
            {
                translatePoint.X += displaySize.Width;
                rotationCenter.X += displaySize.Width;
            }
            if (displaySize.Height < 0)
            {
                translatePoint.Y += displaySize.Height;
                rotationCenter.Y += displaySize.Height;
            }

            if (s.RotationAngle != 0)
            {
                // translate to rotation point, rotate, and translate back.
                // System.Drawing rotates Clockwise!  So we must reverse the
                // rotation angle.
                g.TranslateTransform(-rotationCenter.X, -rotationCenter.Y, MatrixOrder.Append);
                g.RotateTransform(-(float)s.RotationAngleDegrees, MatrixOrder.Append);
                g.TranslateTransform(rotationCenter.X, rotationCenter.Y, MatrixOrder.Append);
            }

            g.TranslateTransform(inst.DestLocation.X - translatePoint.X,
                                 inst.DestLocation.Y - translatePoint.Y, MatrixOrder.Append);

            SetInterpolation(g);

            Geometry.Rectangle srcRect = inst.GetSourceRect(SurfaceSize);

            if (s.Color != Geometry.Color.White)
            {
                ImageAttributes imageAttributes = new ImageAttributes();

                ColorMatrix colorMatrix = new ColorMatrix(new float[][] {
                    new float[] { s.Color.R / 255.0f, 0.0f, 0.0f, 0.0f, 0.0f },
                    new float[] { 0.0f, s.Color.G / 255.0f, 0.0f, 0.0f, 0.0f },
                    new float[] { 0.0f, 0.0f, s.Color.B / 255.0f, 0.0f, 0.0f },
                    new float[] { 0.0f, 0.0f, 0.0f, (float)s.Alpha, 0.0f },
                    new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }
                });

                imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                g.DrawImage(mImage, Interop.Convert(DestRect(0, 0, srcRect, s.ScaleWidth, s.ScaleHeight)),
                            srcRect.X,
                            srcRect.Y,
                            srcRect.Width,
                            srcRect.Height,
                            GraphicsUnit.Pixel,
                            imageAttributes);
            }
            else
            {
                g.DrawImage(mImage, Interop.Convert(DestRect(0, 0, srcRect, s.ScaleWidth, s.ScaleHeight)),
                            srcRect.X,
                            srcRect.Y,
                            srcRect.Width,
                            srcRect.Height,
                            GraphicsUnit.Pixel);
            }

            g.Restore(state);
        }
Esempio n. 10
0
 protected Geometry.Rectangle DestRect(int dest_x, int dest_y, Geometry.Rectangle srcRect, double ScaleWidth, double ScaleHeight)
 {
     return(new Geometry.Rectangle(dest_x, dest_y,
                                   (int)(srcRect.Width * ScaleWidth),
                                   (int)(srcRect.Height * ScaleHeight)));
 }