Drawing Rectangle on .Tiff image
-
i am trying to draw a rectganle on a .tiff image and then save the image. right now it's just saving a .tiif file nogthing on it. here is the code. your help is greatly appreciated. thanks:confused: g = picImage.CreateGraphics() Dim objBmp As Bitmap = New Bitmap(picImage.Size.Width, picImage.Size.Height, Imaging.PixelFormat.Format64bppPArgb) objBmp.FromFile(strPath & curF & ".tif") g.FromImage(objBmp) 'Sets the position of the mouse finishX = e.X finishY = e.Y up = New Point(finishX, finishY) 'Sets the value of rectangle, x, y, width, height position rect = New Rectangle(Math.Min(up.X, down.X), Math.Min(up.Y, down.Y), Math.Abs(up.X - down.X), Math.Abs(up.Y - down.Y)) 'draws and fills rectagnle g.DrawImage(objBmp, rect) 'New Rectangle(0, 0, objBmp.Width, objBmp.Height), 0, 0, objBmp.Width, objBmp.Height, GraphicsUnit.Pixel) g.DrawRectangle(Pens.Black, rect) g.FillRectangle(New SolidBrush(Color.White), rect) objBmp.Save(strPath & curF & "s" & ".tif", Imaging.ImageFormat.Tiff) g.Dispose() objBmp.Dispose() Zulfikar Ali
-
i am trying to draw a rectganle on a .tiff image and then save the image. right now it's just saving a .tiif file nogthing on it. here is the code. your help is greatly appreciated. thanks:confused: g = picImage.CreateGraphics() Dim objBmp As Bitmap = New Bitmap(picImage.Size.Width, picImage.Size.Height, Imaging.PixelFormat.Format64bppPArgb) objBmp.FromFile(strPath & curF & ".tif") g.FromImage(objBmp) 'Sets the position of the mouse finishX = e.X finishY = e.Y up = New Point(finishX, finishY) 'Sets the value of rectangle, x, y, width, height position rect = New Rectangle(Math.Min(up.X, down.X), Math.Min(up.Y, down.Y), Math.Abs(up.X - down.X), Math.Abs(up.Y - down.Y)) 'draws and fills rectagnle g.DrawImage(objBmp, rect) 'New Rectangle(0, 0, objBmp.Width, objBmp.Height), 0, 0, objBmp.Width, objBmp.Height, GraphicsUnit.Pixel) g.DrawRectangle(Pens.Black, rect) g.FillRectangle(New SolidBrush(Color.White), rect) objBmp.Save(strPath & curF & "s" & ".tif", Imaging.ImageFormat.Tiff) g.Dispose() objBmp.Dispose() Zulfikar Ali
And what are the values in rect ? Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
And what are the values in rect ? Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
i am getting the value from mouse. for example it could be anything. the thing is that when it saves it reduces the file size and if i open it it's just blank. Zulfikar Ali
-
i am getting the value from mouse. for example it could be anything. the thing is that when it saves it reduces the file size and if i open it it's just blank. Zulfikar Ali
Zulfikar Ali wrote: for example it could be anything Yes, but what IS it ? Did you step into the code and make sure it was something that should draw a decent rectangle ? Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002