Ken
-------------------------
"nobody" <nonenet@nonene tcom.net> wrote in message
news:ZAgic.1145 7$Dp7.9079@news svr31.news.prod igy.com...[color=blue]
>
> How do I save a PictureBox bitmap with changes
> drawn on the bitmap?
> This doesn't do it:
> PictureBox1.Ima ge.Save("key30. bmp")
>[/color]
Re: Saving a PictureBox bitmap with changes drawn...
"nobody" <nonenet@nonene tcom.net> schrieb[color=blue]
>
> How do I save a PictureBox bitmap with changes
> drawn on the bitmap?
> This doesn't do it:
> PictureBox1.Ima ge.Save("key30. bmp")[/color]
Do you really paint on the bitmap assigned to the Picturebox' Image property
or on the Picturebox?
Re: Saving a PictureBox bitmap with changes drawn...
Armin Zingler wrote:
[color=blue]
> "nobody" <nonenet@nonene tcom.net> schrieb
>[color=green]
>>How do I save a PictureBox bitmap with changes
>>drawn on the bitmap?
>>This doesn't do it:
>>PictureBox1.I mage.Save("key3 0.bmp")[/color]
>
>
> Do you really paint on the bitmap assigned to the Picturebox' Image property
> or on the Picturebox?[/color]
Here's what I got....
Dim GraphicsFun As System.Drawing. Graphics
GraphicsFun = PictureBox1.Cre ateGraphics
Dim aFont As New System.Drawing. Font("MS Sans Serif", 11, _ FontStyle.Bold)
Dim drawBrush As New _ System.Drawing. SolidBrush(Syst em.Drawing.Colo r.Black)
Dim drawFormat As New System.Drawing. StringFormat
Re: Saving a PictureBox bitmap with changes drawn...
"nobody" <nonenet@nonene tcom.net> schrieb[color=blue]
> Armin Zingler wrote:
>[color=green]
> > "nobody" <nonenet@nonene tcom.net> schrieb
> >[color=darkred]
> >>How do I save a PictureBox bitmap with changes
> >>drawn on the bitmap?
> >>This doesn't do it:
> >>PictureBox1.I mage.Save("key3 0.bmp")[/color]
> >
> >
> > Do you really paint on the bitmap assigned to the Picturebox' Image
> > property or on the Picturebox?[/color]
>
> Here's what I got....
>
> Dim GraphicsFun As System.Drawing. Graphics
> GraphicsFun = PictureBox1.Cre ateGraphics
> Dim aFont As New System.Drawing. Font("MS Sans Serif", 11, _
> FontStyle.Bold)
> Dim drawBrush As New _
> System.Drawing. SolidBrush(Syst em.Drawing.Colo r.Black)
> Dim drawFormat As New System.Drawing. StringFormat
>
> GraphicsFun.Dra wString("E", aFont, drawBrush, 20, 31, drawFormat)
>
> 'This draws on the picture, but when saved, it doesn't
> 'save what is drawn, just saves the original loaded from file.[/color]
You are directly drawing on the Picturebox, not on the image assigned to the
Image property. To draw on the image:
dim g as graphics
g = graphics.fromim age(PictureBox1 .image)
g.DrawString("E ", aFont, drawBrush, 20, 31, drawFormat)
g.dispose
If you didn't assign an image to the Image property, you must do it before.
Re: Saving a PictureBox bitmap with changes drawn...
Armin Zingler wrote:[color=blue]
> "nobody" <nonenet@nonene tcom.net> schrieb
>[color=green]
>>Armin Zingler wrote:
>>
>>[color=darkred]
>>>"nobody" <nonenet@nonene tcom.net> schrieb
>>>
>>>
>>>>How do I save a PictureBox bitmap with changes
>>>>drawn on the bitmap?
>>>>This doesn't do it:
>>>>PictureBox1 .Image.Save("ke y30.bmp")
>>>
>>>
>>>Do you really paint on the bitmap assigned to the Picturebox' Image
>>>property or on the Picturebox?[/color]
>>
>>Here's what I got....
>>
>>Dim GraphicsFun As System.Drawing. Graphics
>>GraphicsFun = PictureBox1.Cre ateGraphics
>>Dim aFont As New System.Drawing. Font("MS Sans Serif", 11, _
>>FontStyle.Bol d)
>>Dim drawBrush As New _
>>System.Drawin g.SolidBrush(Sy stem.Drawing.Co lor.Black)
>>Dim drawFormat As New System.Drawing. StringFormat
>>
>>GraphicsFun.D rawString("E", aFont, drawBrush, 20, 31, drawFormat)
>>
>>'This draws on the picture, but when saved, it doesn't
>>'save what is drawn, just saves the original loaded from file.[/color]
>
>
> You are directly drawing on the Picturebox, not on the image assigned to the
> Image property. To draw on the image:
>
> dim g as graphics
> g = graphics.fromim age(PictureBox1 .image)
> g.DrawString("E ", aFont, drawBrush, 20, 31, drawFormat)
> g.dispose
>
> If you didn't assign an image to the Image property, you must do it before.[/color]
I'm getting this error message below....
"An unhandled exception of type 'System.Excepti on' occurred in
system.drawing. dll
Additional information: A Graphics object cannot be created from an
image that has an indexed pixel format."
Re: Saving a PictureBox bitmap with changes drawn...
nobody wrote:
[color=blue]
> Armin Zingler wrote:
>[color=green]
>> "nobody" <nonenet@nonene tcom.net> schrieb
>>[color=darkred]
>>> Armin Zingler wrote:
>>>
>>>
>>>> "nobody" <nonenet@nonene tcom.net> schrieb
>>>>
>>>>
>>>>> How do I save a PictureBox bitmap with changes
>>>>> drawn on the bitmap?
>>>>> This doesn't do it:
>>>>> PictureBox1.Ima ge.Save("key30. bmp")
>>>>
>>>>
>>>>
>>>> Do you really paint on the bitmap assigned to the Picturebox' Image
>>>> property or on the Picturebox?
>>>
>>>
>>> Here's what I got....
>>>
>>> Dim GraphicsFun As System.Drawing. Graphics
>>> GraphicsFun = PictureBox1.Cre ateGraphics
>>> Dim aFont As New System.Drawing. Font("MS Sans Serif", 11, _
>>> FontStyle.Bold)
>>> Dim drawBrush As New _
>>> System.Drawing. SolidBrush(Syst em.Drawing.Colo r.Black)
>>> Dim drawFormat As New System.Drawing. StringFormat
>>>
>>> GraphicsFun.Dra wString("E", aFont, drawBrush, 20, 31, drawFormat)
>>>
>>> 'This draws on the picture, but when saved, it doesn't
>>> 'save what is drawn, just saves the original loaded from file.[/color]
>>
>>
>>
>> You are directly drawing on the Picturebox, not on the image assigned
>> to the
>> Image property. To draw on the image:
>>
>> dim g as graphics
>> g = graphics.fromim age(PictureBox1 .image)
>> g.DrawString("E ", aFont, drawBrush, 20, 31, drawFormat)
>> g.dispose
>>
>> If you didn't assign an image to the Image property, you must do it
>> before.[/color]
>
>
> I'm getting this error message below....
>
> "An unhandled exception of type 'System.Excepti on' occurred in
> system.drawing. dll
> Additional information: A Graphics object cannot be created from an
> image that has an indexed pixel format."[/color]
The line it goes to when the error occurs is....
g.DrawString("E ", aFont, drawBrush, 20, 31, drawFormat)
Re: Saving a PictureBox bitmap with changes drawn...
nobody wrote:[color=blue]
>
> How do I save a PictureBox bitmap with changes
> drawn on the bitmap?
> This doesn't do it:
> PictureBox1.Ima ge.Save("key30. bmp")
>[/color]
Re: Saving a PictureBox bitmap with changes drawn...
"nobody" <nonenet@nonene tcom.net> schrieb[color=blue]
>[color=green]
> > I'm getting this error message below....
> >
> > "An unhandled exception of type 'System.Excepti on' occurred in
> > system.drawing. dll
> > Additional information: A Graphics object cannot be created from an
> > image that has an indexed pixel format."[/color]
>
> The line it goes to when the error occurs is....
> g.DrawString("E ", aFont, drawBrush, 20, 31, drawFormat)[/color]
As the documentation of FromImage says, that certain formats are not
supported. Sorry. Do you have to have an indexed pixel format? Maybe you
could convert it to a Truecolor format to draw on it.
Comment