Reputation: 948
I'm trying to retrieve image drawn on Panel. The image is drawn from SDK for a fingerprint scanner. This is the code I am using to attempt fetching the scanned fingerprint from the panel.
int width = Convert.ToInt32(pnlRightThumb.Width);
int height = Convert.ToInt32(pnlRightThumb.Height);
Bitmap left_thumb = new Bitmap(width1, height);
pnlLeftThumb.DrawToBitmap(left_thumb, new Rectangle(0, 0, width1, height1));
left_thumb.Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Fingerprints", "left.bmp"), ImageFormat.Bmp);
So far, all I've been able to get is a white image.
Note: I cannot change the way the image is drawn, I can only attempt to fetch the drawn image from the Panel.
Upvotes: 0
Views: 80
Reputation: 2174
The key it's the way the image is drawn. If you can't controll it, I thing you have to do a snapshot of your panel,using Graphics object. Try something like this:
int width = Convert.ToInt32(pnlRightThumb.Width);
int height = Convert.ToInt32(pnlRightThumb.Height);
Bitmap left_thumb = new Bitmap(width1, height);
Graphics g = Graphics.FromImage(left_thumb);
Point panel_location;
panel_location=pnlRightThumb.PointToScreen(Point.Empty);
g.CopyFromScreen(panel_location.X, panel_location.Y, 0, 0, left_thumb.Size, CopyPixelOperation.SourceCopy);
left_thumb.Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Fingerprints", "left.bmp"), ImageFormat.Bmp);
Upvotes: 1