How do I save a PictureBox bitmap with changes
drawn on the bitmap?
This doesn't do it:
PictureBox1.Image.Save("key30.bmp") 8 10729
Hi,
Dim fs As New System.IO.FileStream("c:\key30.bmp", IO.FileMode.Open)
Dim bm As New Bitmap(fs)
fs.Close()
Dim g As Graphics = Graphics.FromImage(bm)
g.FillEllipse(Brushes.Red, 10, 10, 100, 100)
g.Dispose()
bm.Save("C:\key30.bmp", Imaging.ImageFormat.Bmp)
Ken
-------------------------
"nobody" <no*****@nonenetcom.net> wrote in message
news:ZA******************@newssvr31.news.prodigy.c om... How do I save a PictureBox bitmap with changes drawn on the bitmap? This doesn't do it: PictureBox1.Image.Save("key30.bmp")
Armin Zingler wrote: "nobody" <no*****@nonenetcom.net> schrieb
How do I save a PictureBox bitmap with changes drawn on the bitmap? This doesn't do it: PictureBox1.Image.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.CreateGraphics
Dim aFont As New System.Drawing.Font("MS Sans Serif", 11, _ FontStyle.Bold)
Dim drawBrush As New _ System.Drawing.SolidBrush(System.Drawing.Color.Bla ck)
Dim drawFormat As New System.Drawing.StringFormat
GraphicsFun.DrawString("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.
"nobody" <no*****@nonenetcom.net> schrieb Armin Zingler wrote:
"nobody" <no*****@nonenetcom.net> schrieb
How do I save a PictureBox bitmap with changes drawn on the bitmap? This doesn't do it: PictureBox1.Image.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.CreateGraphics Dim aFont As New System.Drawing.Font("MS Sans Serif", 11, _ FontStyle.Bold) Dim drawBrush As New _ System.Drawing.SolidBrush(System.Drawing.Color.Bla ck) Dim drawFormat As New System.Drawing.StringFormat
GraphicsFun.DrawString("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.
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.fromimage(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.
--
Armin
Armin Zingler wrote: "nobody" <no*****@nonenetcom.net> schrieb
Armin Zingler wrote:
"nobody" <no*****@nonenetcom.net> schrieb
How do I save a PictureBox bitmap with changes drawn on the bitmap? This doesn't do it: PictureBox1.Image.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.CreateGraphics Dim aFont As New System.Drawing.Font("MS Sans Serif", 11, _ FontStyle.Bold) Dim drawBrush As New _ System.Drawing.SolidBrush(System.Drawing.Color.B lack) Dim drawFormat As New System.Drawing.StringFormat
GraphicsFun.DrawString("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.
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.fromimage(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.
I'm getting this error message below....
"An unhandled exception of type 'System.Exception' occurred in
system.drawing.dll
Additional information: A Graphics object cannot be created from an
image that has an indexed pixel format."
nobody wrote: Armin Zingler wrote:
"nobody" <no*****@nonenetcom.net> schrieb
Armin Zingler wrote:
"nobody" <no*****@nonenetcom.net> schrieb
> How do I save a PictureBox bitmap with changes > drawn on the bitmap? > This doesn't do it: > PictureBox1.Image.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.CreateGraphics Dim aFont As New System.Drawing.Font("MS Sans Serif", 11, _ FontStyle.Bold) Dim drawBrush As New _ System.Drawing.SolidBrush(System.Drawing.Color.Bla ck) Dim drawFormat As New System.Drawing.StringFormat
GraphicsFun.DrawString("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. 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.fromimage(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.
I'm getting this error message below....
"An unhandled exception of type 'System.Exception' occurred in system.drawing.dll Additional information: A Graphics object cannot be created from an image that has an indexed pixel format."
The line it goes to when the error occurs is....
g.DrawString("E", aFont, drawBrush, 20, 31, drawFormat)
nobody wrote: How do I save a PictureBox bitmap with changes drawn on the bitmap? This doesn't do it: PictureBox1.Image.Save("key30.bmp")
Back to Delphi we go.
"nobody" <no*****@nonenetcom.net> schrieb I'm getting this error message below....
"An unhandled exception of type 'System.Exception' occurred in system.drawing.dll Additional information: A Graphics object cannot be created from an image that has an indexed pixel format."
The line it goes to when the error occurs is.... g.DrawString("E", aFont, drawBrush, 20, 31, drawFormat)
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.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Carl |
last post by:
In the application I'm writing, I'm modifying a windows bitmap using the
circle and line methods. Once the changes have been made, I would like to
save the bitmap with the changes. My problem is,...
|
by: yaya via DotNetMonster.com |
last post by:
Hi, I have a picture box with circles and rectangles, and I wana save all
the images into a jpg file, i tried
pictureBox1.Image.Save(@"c:\1.jpg");
but I got and error...
|
by: kalp suth via DotNetMonster.com |
last post by:
I want to create arrows using lines on a picture in the picture box.
On clicking the button "btnShowAll", the image is loaded and the lines drawn. "RGSShowAll()" calls "DrawObjs()" which does the...
|
by: Steve Marshall |
last post by:
Hi all,
I am converting an app which used a picturebox to draw graphs etc onto, then
saved them to a file. I can certainly draw things onto a picturbox in
VB.NET, but how do I save them to a...
|
by: Yash |
last post by:
Have used DrawLine() method to draw some lines in the picturebox (sort
of a barcode) in the picturebox paint event.
This diagram has to be saved as an image in bmp or tiff format.
But the problem...
|
by: The Confessor |
last post by:
I'm trying to develop a graphically-simple, gameplay-complex RPG, and I
decided to create a graphical Proof of Concept just to confirm that
graphics would be... well, simple.
Predictably,...
|
by: jamesjames |
last post by:
Hello, could anyone tell me how to save a bitmap from picturebox.image as a 24bpprgb bitmap?
picturebox.Image.Save(path, ImageFormat.Bmp) saves a 32bpprgb bitmap
and
Bitmap bmp =...
|
by: Nitin |
last post by:
Hi!
I've been trying to draw in a PictureBox and save the resulting image
to a Bitmap object that I save to a file on disk. Unfortunately, I
can't seem to get the elements that I'm drawing to...
|
by: vicky87.eie |
last post by:
I used a picture box to draw lines and rectangle using its graphics
object in paint event. Now i need to save those lines i have drawn and
print them. I need to know how to save them. I tried...
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |