// Draw the source parallelogram of an image into the parallelogram // defined by dest. Point[] has 3 Points, Top-Left, Top-Right and Bottom-Left. // The remaining point is inferred. public virtual void DrawImage(IToolkitImage image, Point[] src, Point[] dest) { int originX = dest[0].X; int originY = dest[0].Y; for (int i = 1; i < 3; i++) { if (originX > dest[i].X) { originX = dest[i].X; } if (originY > dest[i].Y) { originY = dest[i].Y; } } DotGNU.Images.Image gnuImage = (image as ToolkitImageBase).image; // Currently we only draw the first frame. Frame frame = gnuImage.GetFrame(0); frame = frame.AdjustImage(src[0].X, src[0].Y, src[1].X, src[1].Y, src[2].X, src[2].Y, dest[0].X - originX, dest[0].Y - originY, dest[1].X - originX, dest[1].Y - originY, dest[2].X - originX, dest[2].Y - originY); // Setup the new image and draw it. using (DotGNU.Images.Image newGnuImage = new DotGNU.Images.Image(gnuImage.Width, gnuImage.Height, gnuImage.PixelFormat)) { newGnuImage.AddFrame(frame); IToolkitImage newImage = Toolkit.CreateImage(newGnuImage, 0); DrawImage(newImage, originX, originY); } }
// Create a texture brush. public IToolkitBrush CreateTextureBrush (TextureBrush properties, IToolkitImage image, RectangleF dstRect, ImageAttributes imageAttr) { return(new DrawingTextureBrush (properties, image as DrawingImage, dstRect, imageAttr)); }
public override void DrawImage(IToolkitImage image, int x, int y) { Xsharp.Image ximage = (image as DrawingImage).GetNativeImage(); if (ximage != null) { graphics.DrawImage(x, y, ximage); } }
// Constructor. public DrawingTextureBrush(IToolkit toolkit, TextureBrush properties, IToolkitImage image, RectangleF dstRect, ImageAttributes imageAttr) : base(toolkit, Color.Black) { this.properties = properties; this.image = image as DrawingImage; this.dstRect = dstRect; this.imageAttr = imageAttr; }
// Copy image into this.image at x, y public override void DrawImage(IToolkitImage image, int x, int y) { DotGNU.Images.Image sourceImage = (image as ToolkitImageBase).image; Frame sourceFrame = sourceImage.GetFrame(0); DotGNU.Images.Image destImage = this.image.image; Frame destFrame =destImage.GetFrame(0); if (sourceFrame.PixelFormat != destFrame.PixelFormat) sourceFrame = sourceFrame.Reformat(destImage.PixelFormat); destFrame.Copy(sourceFrame, x, y); this.image.ImageChanged(); }
// Implement the IDisposable interface. public void Dispose() { if (toolkitImage != null) { toolkitImage.Dispose(); toolkitImage = null; } if (image != null) { image.Dispose(); image = null; frame = null; frameNum = 0; } }
// Get the toolkit image underlying this icon. internal IToolkitImage GetToolkitImage(Graphics graphics) { if (toolkitImage != null) { return(toolkitImage); } else if (image != null) { toolkitImage = graphics.ToolkitGraphics.Toolkit.CreateImage (image, frameNum); return(toolkitImage); } else { return(null); } }
// Draw an image. public override void DrawImage (IToolkitImage image, System.Drawing.Point[] src, System.Drawing.Point[] dest) { if ((src[1].X - src[0].X) == (dest[1].X - dest[0].X) && (src[2].Y - src[0].Y) == (dest[2].Y - dest[0].Y)) { // Draw a sub-image, without stretching the pixels. Xsharp.Image ximage = (image as DrawingImage).GetNativeImage(); if (ximage != null) { graphics.DrawImage(dest[0].X, dest[0].Y, ximage, src[0].X, src[0].Y, src[1].X - src[0].X, src[2].Y - src[0].Y); } } else { // Hard case: stretch the image before drawing it. base.DrawImage(image, src, dest); } }
// Draw an image at the coordinates public override void DrawImage(IToolkitImage image, int x, int y) { PostscriptImage psi = (image as PostscriptImage); String psImage; if (PostscriptLevel == 3) { psImage = psi.LevelThree; } else { psImage = psi.LevelTwo; } writer.WriteLine ("matrix currentmatrix " + "gsave " + "newpath " + "{0} {1} translate " + "0 0 moveto " + "{2} " + "grestore " + "setmatrix", x, y, psImage); }
public void DrawImage(IToolkitImage image, int x, int y) { throw new NotImplementedException(); }
public PortableGraphics(PortableToolkit parent, IToolkitImage image) { Toolkit = parent; DpiX = DpiY = 96.0f; // default Windows-like value Target = image; }
// Write an image at x, y taking into account the mask public override void DrawImage(IToolkitImage image, int x, int y) { (image as DrawingImage).Draw(hdc, x, y); }
// Create a texture brush. public override IToolkitBrush CreateTextureBrush (TextureBrush properties, IToolkitImage image, RectangleF dstRect, ImageAttributes imageAttr) { return null; }
// Create an IToolkitGraphics object from an image. public IToolkitGraphics CreateFromImage(IToolkitImage image) { return(new DrawingGraphicsImage(this, image)); }
// Create an IToolkitGraphics object from an image. public virtual IToolkitGraphics CreateFromImage(IToolkitImage image) { return(null); }
public DrawingGraphicsImage(IToolkit toolkit, IToolkitImage image) : base(toolkit, image) { }
// Draw an image. public override void DrawImage (IToolkitImage image, System.Drawing.Point[] src, System.Drawing.Point[] dest) { if((src[1].X - src[0].X) == (dest[1].X - dest[0].X) && (src[2].Y - src[0].Y) == (dest[2].Y - dest[0].Y)) { // Draw a sub-image, without stretching the pixels. Xsharp.Image ximage = (image as DrawingImage).GetNativeImage(); if(ximage != null) { graphics.DrawImage(dest[0].X, dest[0].Y, ximage, src[0].X, src[0].Y, src[1].X - src[0].X, src[2].Y - src[0].Y); } } else { // Hard case: stretch the image before drawing it. base.DrawImage(image, src, dest); } }
// Create an IToolkitGraphics object from an image. public virtual IToolkitGraphics CreateFromImage(IToolkitImage image) { return null; }
public IToolkitGraphics CreateFromImage(IToolkitImage image) { return(new PortableGraphics(this, image)); }
public IToolkitBrush CreateTextureBrush(TextureBrush properties, IToolkitImage image, RectangleF dstRect, ImageAttributes imageAttr) { throw new NotImplementedException(); }
public void DrawImage(IToolkitImage image, Point[] src, Point[] dest) { throw new NotImplementedException(); }
// Get the toolkit image underlying this icon. internal IToolkitImage GetToolkitImage(Graphics graphics) { if(toolkitImage != null) { return toolkitImage; } else if(image != null) { toolkitImage = graphics.ToolkitGraphics.Toolkit.CreateImage (image, frameNum); return toolkitImage; } else { return null; } }
// Draw an image at the coordinates public abstract void DrawImage(IToolkitImage image, int x, int y);
// Draw an image at the coordinates public override void DrawImage(IToolkitImage image, int x, int y) { PostscriptImage psi = (image as PostscriptImage); String psImage; if(PostscriptLevel == 3) { psImage = psi.LevelThree; } else { psImage = psi.LevelTwo; } writer.WriteLine ("matrix currentmatrix " + "gsave " + "newpath " + "{0} {1} translate " + "0 0 moveto " + "{2} " + "grestore " + "setmatrix", x, y, psImage); }
public DrawingGraphicsImage(IToolkit toolkit, IToolkitImage image) : base(toolkit, image) {}
// Create an IToolkitGraphics object from an image. public IToolkitGraphics CreateFromImage(IToolkitImage image) { return new DrawingGraphicsImage(this, image); }
public override void DrawImage(IToolkitImage image, int x, int y) { Xsharp.Image ximage = (image as DrawingImage).GetNativeImage(); if(ximage != null) { graphics.DrawImage(x, y, ximage); } }
// Create a texture brush. public IToolkitBrush CreateTextureBrush (TextureBrush properties, IToolkitImage image, RectangleF dstRect, ImageAttributes imageAttr) { return new DrawingTextureBrush (properties, image as DrawingImage, dstRect, imageAttr); }
protected ToolkitGraphicsImageBase(IToolkit toolkit, IToolkitImage image) : base(toolkit) { this.image = image as ToolkitImageBase; }
// Draw the source parallelogram of an image into the parallelogram // defined by dest. Point[] has 3 Points, Top-Left, Top-Right and Bottom-Left. // The remaining point is inferred. public virtual void DrawImage(IToolkitImage image, Point[] src, Point[] dest) { int originX = dest[0].X; int originY = dest[0].Y; for (int i = 1; i < 3; i++) { if (originX > dest[i].X) originX = dest[i].X; if (originY > dest[i].Y) originY = dest[i].Y; } DotGNU.Images.Image gnuImage = (image as ToolkitImageBase).image; // Currently we only draw the first frame. Frame frame = gnuImage.GetFrame(0); frame = frame.AdjustImage(src[0].X, src[0].Y, src[1].X, src[1].Y, src[2].X, src[2].Y, dest[0].X - originX, dest[0].Y - originY, dest[1].X - originX, dest[1].Y - originY, dest[2].X - originX, dest[2].Y - originY); // Setup the new image and draw it. using (DotGNU.Images.Image newGnuImage = new DotGNU.Images.Image(gnuImage.Width, gnuImage.Height, gnuImage.PixelFormat)) { newGnuImage.AddFrame(frame); IToolkitImage newImage = Toolkit.CreateImage(newGnuImage, 0); DrawImage( newImage, originX, originY); } }
// Create a texture brush. public override IToolkitBrush CreateTextureBrush (TextureBrush properties, IToolkitImage image, RectangleF dstRect, ImageAttributes imageAttr) { return(null); }
// Implement the IDisposable interface. public void Dispose() { if(toolkitImage != null) { toolkitImage.Dispose(); toolkitImage = null; } if(image != null) { image.Dispose(); image = null; frame = null; frameNum = 0; } }