I have this code to get the image file from the scanner and save it on local disk:
IntPtr img = (IntPtr)pics[i];
SetStyle(ControlStyles.DoubleBuffer, false);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint, true);
bmprect = new Rectangle(0, 0, 0, 0);
bmpptr = GlobalLock(img);
pixptr = GetPixelInfo(bmpptr);
Gdip.SaveDIBAs(@"C:\", bmpptr, pixptr);
The problem is here Gdip.SaveDIBAs(@"C:\", bmpptr, pixptr);
.the save dialog.
I want to discard this dialog and save file directly in my drive.
**Updated:**
public static bool SaveDIBAs(string picname, IntPtr bminfo, IntPtr pixdat)
{
SaveFileDialog sd = new SaveFileDialog();
sd.FileName = picname;
sd.Title = "Save bitmap as...";
sd.Filter =
"Bitmap file (*.bmp)|*.bmp|TIFF file (*.tif)|*.tif|JPEG file (*.jpg)|*.jpg|PNG file (*.png)|*.png|GIF file (*.gif)|*.gif|All files (*.*)|*.*";
sd.FilterIndex = 1;
return true;
}
for (int i = 0; i < pics.Count; i++)
{
IntPtr img = (IntPtr)pics[i];
SetStyle(ControlStyles.DoubleBuffer, false);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint, true);
bmprect = new Rectangle(0, 0, 0, 0);
bmpptr = GlobalLock(img);
pixptr = GetPixelInfo(bmpptr);
SaveDIBAs(@"C:\a.jpg", bmpptr, pixptr);
}
Gdip.SaveDIBAs(@"C:\", bmpptr, pixptr);
toGdip.SaveDIBAs(@"C:\a.jpg", bmpptr, pixptr);
– CroplandFileInfo fi = new FileInfo(filePath);
as the answer in the link suggests, thenGdip.SaveDIBAs(@"C:\" + fi.Name, bmpptr, pixptr);
– Cropland