Hi Friends, I am using following code for screen capture:
Bitmap bitmaptodisplayzoom = new Bitmap(SelectionRectangle.Height, SelectionRectangle.Width);
using (Graphics g = Graphics.FromImage(bitmaptodisplayzoom))
{
//new Point(319, 64), new Point(419,214)
g.CopyFromScreen(SourcePoint, new Point(0, 0), new Size(SelectionRectangle.Width, SelectionRectangle.Height));
}
new form2(bitmaptodisplayzoom);
form2.Show();
The image is generate successfully. But when I am passing it though the constructor to other form to display in picturebox, a box with red cross is shown on that form. Also please guide me how to continusly send screen captured image to display on another form in picturebox with the mouse move. The error which it is throiwng is "parameter not valid" and when I tried
bitmaptodisplayzoom.save("test.jpg");
it saves the first image successfully but after that gives generic gdi+ error. Please help
Loading

FroglegRank #1,020 · 1.9K reputationPosted Dec 27, 2010, 11:46 AM EST
iinf19 reputationPosted Dec 27, 2010, 7:15 PM EST
Form1_OnLoad()
{
Form form2 = new Form2(); //Sligthly modified code then the previous approach
form2.Show();
}
private void panelforImage_MouseMove(object sender, MouseEventArgs e)
{
using (Graphics g = Graphics.FromImage(bitmaptodisplayzoom)) //bitmaptodisplay zoom size is als0 300x 300
{
//new Point(319, 64), new Point(419,214)
g.CopyFromScreen(new Point(e.X, e.Y), new Point(0, 0), new Size(300, 300));
}
form2.toset = bitmaptodisplayzoom;
bitmaptodisplayzoom.Dispose();
}
Form2.cs:
public Image toset;
private void zoomwindow_Load(object sender, EventArgs e)
{
Thread th = new Thread(displayimage);
th.Start();
}
public void displayimage()
{
try
{
while (true)
{
Thread.Sleep(1000);
pictureBoxZoomView.Image = toset;
}
}
catch (Exception ezoom)
{
}
}
FroglegRank #1,020 · 1.9K reputationPosted Dec 27, 2010, 8:37 PM EST
iinf19 reputationPosted Dec 28, 2010, 8:08 PM EST
FroglegRank #1,020 · 1.9K reputationPosted Dec 29, 2010, 7:27 AM EST
Have a look at the differences, the main one being DoubleBufferPanel class that I added
Once that was done ,there was a DoubleBufferPanel created in the toolbox which I then replaced panelforimage