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
FroglegPosted Dec 29, 2010, 12:27 PM
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
iinfPosted Dec 29, 2010, 1:08 AM
FroglegPosted Dec 28, 2010, 1:37 AM
iinfPosted Dec 28, 2010, 12:15 AM
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)
{
}
}
FroglegPosted Dec 27, 2010, 4:46 PM