public abstract void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination);
public abstract void Apply(object control, GraphicsHandler graphics);
public virtual void DrawImage(GraphicsHandler graphics, float x, float y) { DrawImage(graphics, x, y, Size.Width, Size.Height); }
public virtual void DrawImage(GraphicsHandler graphics, float x, float y, float width, float height) { DrawImage(graphics, new RectangleF(new Point(0, 0), Size), new RectangleF(x, y, width, height)); }
public abstract void Apply(GraphicsHandler handler, bool first);
public override void Apply(GraphicsHandler handler, bool first) { apply(handler, first); }
public virtual void DrawImage(GraphicsHandler graphics, int x, int y, int width, int height) { DrawImage(graphics, new Rectangle(new Point(0, 0), Size), new Rectangle(x, y, width, height)); }
public override void Apply(object control, GraphicsHandler graphics) { ((TextureBrushObject)control).Apply(graphics); }
public override void Apply(object control, GraphicsHandler graphics) { graphics.Control.Color = (Cairo.Color)control; graphics.Control.Fill(); }
public void Apply(Pen widget, GraphicsHandler graphics) { ((PenObject)widget.ControlObject).Apply(graphics); }
public override void DrawImage(GraphicsHandler graphics, Rectangle source, Rectangle destination) { // copy to a surface var surface = new Cairo.ImageSurface(Cairo.Format.Rgb24, source.Width, source.Height); unsafe { byte *destrow = (byte *)surface.DataPtr; fixed(byte *srcdata = this.Control) { byte *srcrow = srcdata + (source.Top * rowStride) + source.Left; for (int y = source.Top; y < source.Bottom; y++) { byte *src = (byte *)srcrow; uint *dest = (uint *)destrow; for (int x = source.Left; x < source.Right; x++) { * dest = colors [*src]; src++; dest++; } srcrow += rowStride; destrow += surface.Stride; } } } var context = graphics.Control; context.Save(); context.Rectangle(Generator.ConvertC(destination)); double scalex = 1; double scaley = 1; if (source.Width != destination.Width || source.Height != destination.Height) { scalex = (double)destination.Width / (double)source.Width; scaley = (double)destination.Height / (double)source.Height; context.Scale(scalex, scaley); } context.SetSourceSurface(surface, destination.Left, destination.Top); context.Fill(); context.Restore(); /* * if (graphics == null || graphics.Control == null || graphics.GC == null) * throw new Exception("WHAA?"); * using (var drawable = new Gdk.Pixmap(graphics.Control, source.Right+1, source.Bottom+1)) * using (var gc = new Gdk.GC(drawable)) * { * if (drawable.Colormap == null) * drawable.Colormap = graphics.Control.Colormap; * drawable.DrawIndexedImage(gc, 0, 0, source.Right+1, source.Bottom+1, Gdk.RgbDither.None, Control, this.rowStride, GetPmap()); * if (source.Width != destination.Width || source.Height != destination.Height) * { * // scale da shit * Gdk.Pixbuf pb = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, source.Width, source.Height); * pb.GetFromDrawable(drawable, drawable.Colormap, source.X, source.Y, 0, 0, source.Width, source.Height); * * Gdk.Pixbuf pbDest = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, destination.Width, destination.Height); * pb.Scale(pbDest, 0, 0, destination.Width, destination.Height, 0, 0, (double)destination.Width / (double)source.Width, * (double)destination.Height / (double)source.Height, Gdk.InterpType.Bilinear); * pb.Dispose(); * * * graphics.Control.DrawPixbuf(graphics.GC, pbDest, 0, 0, destination.X, destination.Y, destination.Width, destination.Height, Gdk.RgbDither.None, 0, 0); * pbDest.Dispose(); * } * else * { * // no scaling necessary! * graphics.Control.DrawDrawable(graphics.GC, drawable, source.X, source.Y, destination.X, destination.Y, destination.Width, destination.Height); * } * * }*/ }