|
-
Apr 14th, 2012, 11:09 AM
#1
Thread Starter
Hyperactive Member
Capture area of picturebox
Hi I have a picturebox that has other controls over it like labe and textbox and other image over it.
But when I take capture of that area, and save it as .jpg it shows only white image and labels, text, image is not included.
Here is my code for capture
Code:
Rectangle form = this.pictureBox1.Bounds;
using (Bitmap bitmap = new Bitmap(form.Width, form.Height))
{
using (Graphics graphic = Graphics.FromImage(bitmap))
{
pictureBox1.DrawToBitmap(bitmap, new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height));
}
bitmap.Save("D://test.jpg", ImageFormat.Bmp);
}
What is the correct code to do that?
Thanks,
Last edited by dr_aybyd; Apr 14th, 2012 at 11:13 AM.
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Apr 14th, 2012, 07:25 PM
#2
Thread Starter
Hyperactive Member
Re: Capture area of picturebox
I tried CopyFromScreen
But the problem now is, the image taken is not in position of a PictureBox.
Code:
private void button1_Click(object sender, EventArgs e)
{
Bitmap mImage;
{
Graphics myGraphics = this.CreateGraphics();
Size s = this.pictureBox1.Size;
mImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(mImage);
memoryGraphics.CopyFromScreen(this.pictureBox1.Location.X, this.pictureBox1.Location.Y, 0, 0, s);
}
mImage.Save("D://test.jpg", ImageFormat.Bmp);
}
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Apr 14th, 2012, 07:56 PM
#3
Thread Starter
Hyperactive Member
Re: Capture area of picturebox
What I want to achieve here is to take capture of generated ID Card which is in PictureBox1 to file and use it later into my report.
Last edited by dr_aybyd; Apr 14th, 2012 at 08:06 PM.
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|