save the image

save the image

Page 1 of 1

1 Replies - 6910 Views - Last Post: 13 November 2007 - 03:58 PM Rate Topic: -----

#1 aamir_mustafa2007@msn.com  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 03-July 07

save the image

Post icon  Posted 13 November 2007 - 09:26 AM

I have redefined the code as follow for save event
Private Sub SaveToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
		Dim sdlg As New SaveFileDialog()

		With sdlg

			.Title = "Export Image File"
			.Filter="jpg|*.jpg|gif|*.gif|tga|*.tga|bmp|*.bmp|raw|*.raw|emf|*.emf|wmf|*.wmf|png|*.png|cdr|*.cdr|wpg|*.wpg|wmz|*.wmz|tif|*.tif|pcz|*.pcz"

			End With

	   	 If sdlg.ShowDialog = Windows.Forms.DialogResult.OK Then

			Select Case sdlg.FilterIndex

				'Because the base for FilterIndex is 1 not 0
				Case 1
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Jpeg)

				Case 2
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Gif)

				Case 3
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Bmp)

				Case 4
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Png)
				Case 5
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Icon)
				Case 6
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Tiff)
				Case 7
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Wmf)
				Case 8
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Exif)
				Case 9
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Emf)
			End Select
End If
			End Sub

I have two forms Form1(MDI Form) and Form2 which has picturebox on it.
Form1 contains a ToolStripMenu and ToolStripBar.File menu has two sub menus Open and Exit and similarly Toolbar has two buttons Open and save, OpenDialogue is on the Form1
Form2 contains ToolStripMenu and ToolStripBar.File menu has a sub menus Save and and similarly Toolbar has one button save, SaveDialogue is on the Form2
Above code works fine for save menu and save button on form2 but it does not work for save button on Form1,plz tell me that how can do that to save properly through save button on form1.
Similarly I have another problem concern to merging menus and toolbar buttons
Before loading the image I need only two sub menus open and exit and one button open on toolbar on form1 because I have nothing to save
But after when I load the image I need save sub menu and save button, I want to merge them with each other, when image loaded there should be only one menu on form1 and form2’s save menu should merge into File menu of form1 and file menu of form2 should disappear from there.
Similarly I want to do that with save button on form2 that it should merge with open button on form2 and save button and toolbar should disappear from form2.
Plz kindly tell me how can I do that in Visual Basic.net 2005
thanks

Is This A Good Question/Topic? 0
  • +

Replies To: save the image

#2 aceofspades686  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 6
  • View blog
  • Posts: 334
  • Joined: 08-October 07

Re: save the image

Posted 13 November 2007 - 03:58 PM

Well, the easiest way would be to change that to a public sub instead of a private (or create a new public sub that calls the private sub if you want to keep that as private for some reason). Then you would be able to call the public sub from the other form, something like this:

Public Sub SaveToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
		Dim sdlg As New SaveFileDialog()

		With sdlg

			.Title = "Export Image File"
			.Filter="jpg|*.jpg|gif|*.gif|tga|*.tga|bmp|*.bmp|raw|*.raw|emf|*.emf|wmf|*.wmf|png|*.png|cdr|*.cdr|wpg|*.wpg|wmz|*.wmz|tif|*.tif|pcz|*.pcz"

			End With

			If sdlg.ShowDialog = Windows.Forms.DialogResult.OK Then

			Select Case sdlg.FilterIndex

				'Because the base for FilterIndex is 1 not 0
				Case 1
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Jpeg)

				Case 2
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Gif)

				Case 3
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Bmp)

				Case 4
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Png)
				Case 5
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Icon)
				Case 6
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Tiff)
				Case 7
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Wmf)
				Case 8
					Me.PictureBox1.Image.Save(sdlg.FileName,ImageFormat.Exif)
				Case 9
					Me.PictureBox1.Image.Save(sdlg.FileName, ImageFormat.Emf)
			End Select
End If
			End Sub


Then in Form1:
Form2.SaveToolStripMenuItem_Click_1

Where you want to call the image save procedure. I'm writing this cold so you may have to play around with it some to get it working properly, but that should get you started.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1