Hello,
I have created a complete PrintDocument and need to create an image from it.
How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 +
yPos, AStringFormat)
e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2,
TheHeight1 + (390 + yPos))
e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3,
TheHeight2 + (390 + yPos))
e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4,
TheHeight3 + (390 + yPos), AStringFormat)
Dim AnImage as Image
AnImage = CType(e.graphics, Image) does not work.
Any Suggestions?
Thanks,
Chuck 5 27108
* "Charles A. Lackman" <Ch*****@cet.com> scripsit: I have created a complete PrintDocument and need to create an image from it. How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos)) e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3, TheHeight2 + (390 + yPos)) e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4, TheHeight3 + (390 + yPos), AStringFormat)
Dim AnImage as Image
AnImage = CType(e.graphics, Image) does not work.
You will have to create a 'Graphics' object from a bitmap of appropriate
size:
\\\
Dim b As New Bitmap(...)
Dim g As Graphics = Graphics.FromImage(b)
g.SmoothingMode = ...
....
g.Dispose()
b.Save(...)
b.Dispose()
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Create a sub thats takes graphics as a parameter and put your drawing code
in it. For printing, pass the printer graphics object. For an image, create
a bitmap and pass Graphics.FromImage(bitmap). You can then save the bitmap
etc.
James
--
Create interactive diagrams and flowcharts with ERM Diagram at http://www.crainiate.net
Take the ERM Tour at http://www.flowchartcontrol.com
"Charles A. Lackman" <Ch*****@cet.com> wrote in message
news:e2**************@tk2msftngp13.phx.gbl... Hello,
I have created a complete PrintDocument and need to create an image from
it. How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos)) e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3, TheHeight2 + (390 + yPos)) e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4, TheHeight3 + (390 + yPos), AStringFormat)
Dim AnImage as Image
AnImage = CType(e.graphics, Image) does not work.
Any Suggestions?
Thanks,
Chuck
Hello,
Ok, I already have a sub that takes the graphics object
Public Sub MakeGraphic(ByVal AGraphic As Graphics)
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 +
yPos, AStringFormat)
e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2,
TheHeight1 + (390 + yPos))
e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3,
TheHeight2 + (390 + yPos))
e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4,
TheHeight3 + (390 + yPos), AStringFormat)
SaveBitMap = New Bitmap(ThePic.Width, ThePic.Height, e.Graphics)
SaveBitMap.Save("C:\Test1.jpg")
End sub
To do the Graphics.FromImage(Bitmap) where is the Bitmap coming from?
Doing the above makes a file with 88k or more but it is empty??
Thanks,
Chuck
"James Westgate [Crainiate]" <ja***@nospam.crainiate.com> wrote in message
news:OV*************@TK2MSFTNGP10.phx.gbl... Create a sub thats takes graphics as a parameter and put your drawing code in it. For printing, pass the printer graphics object. For an image,
create a bitmap and pass Graphics.FromImage(bitmap). You can then save the bitmap etc.
James
-- Create interactive diagrams and flowcharts with ERM Diagram at http://www.crainiate.net
Take the ERM Tour at http://www.flowchartcontrol.com
"Charles A. Lackman" <Ch*****@cet.com> wrote in message news:e2**************@tk2msftngp13.phx.gbl... Hello,
I have created a complete PrintDocument and need to create an image from it. How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390
+ yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos)) e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3, TheHeight2 + (390 + yPos)) e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4, TheHeight3 + (390 + yPos), AStringFormat)
Dim AnImage as Image
AnImage = CType(e.graphics, Image) does not work.
Any Suggestions?
Thanks,
Chuck
Thanks, It worked
Chuck
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2i************@uni-berlin.de... * "Charles A. Lackman" <Ch*****@cet.com> scripsit: I have created a complete PrintDocument and need to create an image from
it. How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390
+ yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos)) e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3, TheHeight2 + (390 + yPos)) e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4, TheHeight3 + (390 + yPos), AStringFormat)
Dim AnImage as Image
AnImage = CType(e.graphics, Image) does not work.
You will have to create a 'Graphics' object from a bitmap of appropriate size:
\\\ Dim b As New Bitmap(...) Dim g As Graphics = Graphics.FromImage(b) g.SmoothingMode = ... ... g.Dispose() b.Save(...) b.Dispose() ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
Dim objBitmap as bitmap = new bitmap(ThePic.Width, ThePic.Height)
MakeGraphic(Graphics.FromImage(objBitmap))
objBitmap.save("c:\test1.jp,Imaging.ImageFormat.Jp eg)
J
"Charles A. Lackman" <Ch*****@cet.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl... Hello,
Ok, I already have a sub that takes the graphics object
Public Sub MakeGraphic(ByVal AGraphic As Graphics) e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos)) e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3, TheHeight2 + (390 + yPos)) e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4, TheHeight3 + (390 + yPos), AStringFormat)
SaveBitMap = New Bitmap(ThePic.Width, ThePic.Height, e.Graphics) SaveBitMap.Save("C:\Test1.jpg") End sub
To do the Graphics.FromImage(Bitmap) where is the Bitmap coming from? Doing the above makes a file with 88k or more but it is empty??
Thanks, Chuck
"James Westgate [Crainiate]" <ja***@nospam.crainiate.com> wrote in message news:OV*************@TK2MSFTNGP10.phx.gbl... Create a sub thats takes graphics as a parameter and put your drawing
code in it. For printing, pass the printer graphics object. For an image, create a bitmap and pass Graphics.FromImage(bitmap). You can then save the
bitmap etc.
James
-- Create interactive diagrams and flowcharts with ERM Diagram at http://www.crainiate.net
Take the ERM Tour at http://www.flowchartcontrol.com
"Charles A. Lackman" <Ch*****@cet.com> wrote in message news:e2**************@tk2msftngp13.phx.gbl... Hello,
I have created a complete PrintDocument and need to create an image
from it. How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1,
390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos)) e.Graphics.DrawString(Line3.Text, FontLine3, TheBrush, Thelocation3, TheHeight2 + (390 + yPos)) e.Graphics.DrawString(Line4.Text, FontLine4, TheBrush, Thelocation4, TheHeight3 + (390 + yPos), AStringFormat)
Dim AnImage as Image
AnImage = CType(e.graphics, Image) does not work.
Any Suggestions?
Thanks,
Chuck
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mevar81 |
last post by:
Hello to everybody.I have a problem.I used a
TypeDescriptor to retrieve a TypeConverter to convert an
Image to a string.The problem is that it converts the
image to the string...
|
by: Scott Schluer |
last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG)
to a B&W photo?
Thanks,
Scott
|
by: Mathieu |
last post by:
Hi !
How may I concert Graphics to Bitmap or Save Graphics to file...
// Dim g as Graphics
// g = pictureBox1.CreateGraphics
// g.Save ????
I Just want to Save g (Graphics) in file C:\g.bmp
|
by: platinumhimani |
last post by:
-How to convert any image(8,16,24,32 or 64-bit) to 8-bit grayscale
-i have tried to convert a 24-bit image to grayscale using setpixel
and getpixel functions, in vb.net
but i am unable to save...
|
by: xhy_China |
last post by:
Hi,I want to ask three questions(in vs.net and C#):
1. how can I know whether a bitmap is an indexed or non-indexed?
2. how can I convert a indexed bitmap to non-indexed bitmap?
3. how can I...
|
by: alarock |
last post by:
hi,
I have performed some drawing using Vector image,DrawRectangle etc... and then i converted to raster Image(bitmap)
i found in the zoomed raster image(bitmap) the outer...
|
by: jt |
last post by:
hey guys..
can anybody suggest a code tht would save the graphics image saved in
C to jpg file.
is it available in the net.
plz tell the links.
|
by: raylopez99 |
last post by:
Beware newbies: I spent a day before I figured this out: copying a
bitmap (image) file to file is not quite like copying a text file--you
have to do some tricks (see below), like using a...
|
by: JOHNYKUTTY |
last post by:
i have to convert an image variable(system.drawing.bitmap orsystem.drawing.image or AForge.Imaging.Image) to Emgu.CV.Image type i have used the code below Image<Bgr, Byte> cvimage = new Image<Bgr,...
|
by: Mickle |
last post by:
here is my code, I was trying to convert arraybyte to bitmap after placing some value in array and convert it back to bitmap, actually i'm working with bilinear interpolation. i really appreciate...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |