Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy System.Drawing.Graphics Objects

Posted on 2004-08-27
4
Medium Priority
?
1,599 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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 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