D
David
Hi,
I am scanning an image and putting it into a picture box. (I am using WIA)
ImageFile img = (ImageFile)scanItem.Transfer(WIA.FormatID.wiaFormatJPEG);
string scanTime = DateTime.Now.ToFileTime().ToString();
string FileName = "c:\\tempimage_" + scanTime + ".jpg";
img.SaveFile(FileName);
pictureBox1.Image = Image.FromFile(FileName);
Refresh();
My picture box is inside a panel... the picturebox size mode is set to
AutoSize and the panel has autoscrolling. This is so that I can navigate
around the picture.
However, with the code above, I am now trying to grab hold of the picture to
upload it to a webservice... (The code below is AFTER putting the picture in
the picture box)
System.IO.BinaryReader br = new
System.IO.BinaryReader(System.IO.File.Open(FileName,
System.IO.FileMode.Open, System.IO.FileAccess.Read));
br.BaseStream.Position = 0;
byte[] buffer = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length));
ScanService.ScanService uploadScan = new Scan.ScanService.ScanService();
uploadScan.PutScanFile(buffer);
br.Close();
File.Delete(FileName);
but the file was locked by the picturebox (or appears to be more
specifically, the Image.FromFile, so I changed the pictureBox loading to...
using (Image tempImage = Image.FromFile(FileName))
{
pictureBox1.Image = tempImage;
Refresh();
}
Now, that seemed to unlock the image and I could upload it and later delete
the file. However, if I attempt to scroll the panel with the picturebox
inside it, I get an error on the Application.Run line in my program.cs,
saying "A parameter is not valid".
So, without the above using statement, my pic is still scrollable, but not
uploadable or deleteable. With the using statement, my pic is uploadable and
deleteable but not scrollable.
How do I get around this?
Thanks.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
I am scanning an image and putting it into a picture box. (I am using WIA)
ImageFile img = (ImageFile)scanItem.Transfer(WIA.FormatID.wiaFormatJPEG);
string scanTime = DateTime.Now.ToFileTime().ToString();
string FileName = "c:\\tempimage_" + scanTime + ".jpg";
img.SaveFile(FileName);
pictureBox1.Image = Image.FromFile(FileName);
Refresh();
My picture box is inside a panel... the picturebox size mode is set to
AutoSize and the panel has autoscrolling. This is so that I can navigate
around the picture.
However, with the code above, I am now trying to grab hold of the picture to
upload it to a webservice... (The code below is AFTER putting the picture in
the picture box)
System.IO.BinaryReader br = new
System.IO.BinaryReader(System.IO.File.Open(FileName,
System.IO.FileMode.Open, System.IO.FileAccess.Read));
br.BaseStream.Position = 0;
byte[] buffer = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length));
ScanService.ScanService uploadScan = new Scan.ScanService.ScanService();
uploadScan.PutScanFile(buffer);
br.Close();
File.Delete(FileName);
but the file was locked by the picturebox (or appears to be more
specifically, the Image.FromFile, so I changed the pictureBox loading to...
using (Image tempImage = Image.FromFile(FileName))
{
pictureBox1.Image = tempImage;
Refresh();
}
Now, that seemed to unlock the image and I could upload it and later delete
the file. However, if I attempt to scroll the panel with the picturebox
inside it, I get an error on the Application.Run line in my program.cs,
saying "A parameter is not valid".
So, without the above using statement, my pic is still scrollable, but not
uploadable or deleteable. With the using statement, my pic is uploadable and
deleteable but not scrollable.
How do I get around this?
Thanks.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available