?
Solved

Copy System.Drawing.Graphics Objects

Posted on 2004-08-27
4
Medium Priority
?
1,596 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
GrumbleBot earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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