IxiRancid Posted December 1, 2005 Posted December 1, 2005 OK, I got the WIA thingy working etc. Now I have a problem. My app scans predefined forms which contain a small square for a signature and a paraf. Signature is divided from the paraf with a thin black line. here's how the process goes: 1. scan a picture with a WIA compatible scanner 2. save entire A4 image in TIFF 3. again with WIA I crop the abovementioned square + save the Tiff and delete the original one, and load the crop into PictureBox 4. then I do this Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Dim g As Graphics = e.Graphics g.FillRectangle(System.Drawing.Brushes.White, 529, 0, 7, PictureBox1.Bottom) End Sub the dividing line of the square is gone :) then this: Dim img As Image img = PictureBox1.Image img.Save("C:\enaa.TIFF", ImageFormat.Tiff) It doesn't save the picture WITHOUT the dividing line (step 4. is ignored, although I see the picture after fillRectangle just as I want it!) The question? How can I save my image from PicBox as I see it, with the dividing line cleared? If you like I can post some sample pics. Quote
jo0ls Posted December 1, 2005 Posted December 1, 2005 The picturebox has an image property. It also has a surface like all controls that you can paint on. The two have nothing to do with each other. In your picturebox paint event you draw on the surface of the picturebox. There is no way to capture this drawing on the surface easily (need to capture the screen). The image property of the picturebox holds a bitmap and this is not effected by the drawing you did on the surface. What you should do is: load the cropped image into a bitmap create a graphics from the bitmap draw with the graphics onto the bitmap save the bitmap, set the picturebox.image property to the bitamp no need to do anything in the paint event. something like: dim bm as bitmap = bitmap.fromfile("cropped.tiff") dim g as graphics = graphics.fromimage(bm) g.FillRectangle(System.Drawing.Brushes.White, ????? ) bm.Save("C:\enaa.TIFF", ImageFormat.Tiff) picturebox1.image = bm Quote
IxiRancid Posted December 1, 2005 Author Posted December 1, 2005 Well, that's nice! I don't really even want to show the picture in the Box, so this is a fine solution. Didn't know about the surface and image below! Thanks! Quote
IxiRancid Posted December 1, 2005 Author Posted December 1, 2005 Ok, I tried it and had this error: <A generic error occurred in GDI+> went to this page KB article and then added a new save name for the file (& "1.TIFF"), the code as it follows: Dim bm As Bitmap = Bitmap.FromFile(usr_profile & "\desktop\" & imepriimek & ".TIFF") Dim g As Graphics = Graphics.FromImage(bm) g.FillRectangle(System.Drawing.Brushes.White, 529, 0, 7, bm.Height) bm.Save(usr_profile & "\desktop\" & imepriimek & "1.TIFF", ImageFormat.Tiff) and delete the original cropped file. Quote
Cags Posted December 1, 2005 Posted December 1, 2005 Just a cautionary notice, when using a Graphics object you should always remember to call the Dispose method when your done with it. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.