Solved

Copy System.Drawing.Graphics Objects

Posted on 2004-08-27
4
1,584 Views
Last Modified: 2011-09-20
Is there any way to copy (as in BitBlt), from one Graphics object to another without resorting to API calls?
0
Comment
Question by:eternal_21
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
GrumbleBot earned 500 total points
ID: 11918058
I think this should help. Not sure exactly what you need. This will copy the pixels from 0,0 - 50,50 of the bitmap in the picturebox and display it on the form at location 0,0. You could also copy it to anothe bitmap or picturebox.

      Graphics g = CreateGraphics();
      Bitmap myBitmap = (Bitmap) pictureBox1.Image;

      RectangleF cloneRect = new RectangleF(0, 0, 50, 50);
      PixelFormat format = myBitmap.PixelFormat;
      Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format);
      g.DrawImage(cloneBitmap, 0, 0);

hope this helps.
Good luck
0
 
LVL 10

Author Comment

by:eternal_21
ID: 11920529
This is a good example of copying from a Bitmap to a Graphics object... but I need to go from one Graphics object to another.
0
 
LVL 3

Expert Comment

by:GrumbleBot
ID: 11921508
sorry about that. Hmm I'm pretty sure that the only way you will be able to do what you want is using BitBlt and get the hDC fo the graphics object. Here is an example in VB. Should be easy to modify to C#.

Sorry I couldn't help more. Hopefully there is an expert out there that has a easier way to do this.

Good luck
0
 
LVL 3

Expert Comment

by:GrumbleBot
ID: 11921513
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question