Link to home
Start Free TrialLog in
Avatar of GEGAmbato
GEGAmbato

asked on

How to copy Clip of an Image to Clipboard C# Code in a WPF Application

This is the Code the Works in Window Forms Application (Non-WPF)
"TiffImage" is a picturebox Control
public Bitmap ImageClip;

pivate void CopyBlock()
{
    Point topLeft = new Point(Math.Min(pointStart.X, pointEnd.X), Math.Min(pointStart.Y, pointEnd.Y));
    int clipWidth = Math.Abs(pointEnd.X - pointStart.X + 1),
        clipHeight = Math.Abs(pointEnd.Y - pointStart.Y + 1);

    ImageClip = new Bitmap(clipWidth, clipHeight);
    Graphics Gra = Graphics.FromImage(ImageClip);
    Gra.DrawImage(TiffImage.Image, new Rectangle(0, 0, clipWidth, clipHeight),
                                           topLeft.X, topLeft.Y, clipWidth, clipHeight, GraphicsUnit.Pixel);
    Gra.Dispose();

    Clipboard.SetDataObject(ImageClip);
}

What is the Code to do this in WFP Application
ASKER CERTIFIED SOLUTION
Avatar of GEGAmbato
GEGAmbato

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial