Hi I have a little problem I have a program witch generate ephemerids of comets... and in some parts of this program i draw a points(orbit of comet) in picturebox. Background image of picturebox is a map of the sky. and now i want to save it in *.jpg, *.bitmap or *.tif file... I use a codeit`s a test code )
but saving process return error :/ why???
I try different code:
and it works, but saved files are without background image... I known why, but I don,t known how to save it with backgound.... :/
Please help... Or give me some link to information about it... thx
VB.NET:
...........[SIZE=2]
[/SIZE][SIZE=2][COLOR=#008000]Dim rysunek As System.Drawing.Graphics
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]rysunek = PictureBox1.CreateGraphics
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pioro [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Pen(Color.Blue)
[/SIZE][SIZE=2][COLOR=#008000]rysunek.DrawLine(pioro, 10, 10, 15, 15)
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] format [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Drawing.Imaging.ImageFormat
SaveFileDialog1.Filter = "Mapa bitowa | *.bmp| Plik JPEG | *.jpg| Plik TIFF | *.tif"
[/SIZE][SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] SaveFileDialog1.FilterIndex
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] 1
format = System.Drawing.Imaging.ImageFormat.Bmp
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] 2
format = System.Drawing.Imaging.ImageFormat.Jpeg
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] 3
format = System.Drawing.Imaging.ImageFormat.Tiff
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Select
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] SaveFileDialog1.ShowDialog() = DialogResult.OK [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2]PictureBox1.Image.Save(SaveFileDialog1.FileName, format)
[/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]
I try different code:
VB.NET:
.........
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] format [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Drawing.Imaging.ImageFormat
SaveFileDialog1.Filter = "Mapa bitowa | *.bmp| Plik JPEG | *.jpg| Plik TIFF | *.tif"
[/SIZE]
[SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] SaveFileDialog1.FilterIndex
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] 1
format = System.Drawing.Imaging.ImageFormat.Bmp
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] 2
format = System.Drawing.Imaging.ImageFormat.Jpeg
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] 3
format = System.Drawing.Imaging.ImageFormat.Tiff
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Select
[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] SaveFileDialog1.ShowDialog() = DialogResult.OK [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] bm [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Bitmap([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].PictureBox1.Width, [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].PictureBox1.Height)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] g [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Graphics = Graphics.FromImage(bm)
g.DrawLine(pioro, 10, 10, 200, 200)
[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2]g.Dispose()
bm.Save(SaveFileDialog1.FileName)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]Savefiledialog1.Dispose()
[/SIZE]
Please help... Or give me some link to information about it... thx
Last edited by a moderator: