473,703 Members | 2,859 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert Graphic to image

I am trying to create an image from a graphics object. I would like to
create the image and use in the application without having to save to

If this isn't possible, please just tell me so I can quite looking.

Thank you

Nov 21 '05 #1
4 6866
"Kalvin" <kt***@streck.c om> schrieb:
I am trying to create an image from a graphics object. I would like to
create the image and use in the application without having to save to

I am not sure what you want to do. You can determine a 'Graphics' object
for an image using 'Graphics.FromI mage':

Dim b As New Bitmap(...) ' Take a look at the overloaded constructor.
Dim g As Graphics = Graphics.FromIm age(b)

Image data is stored in an image, whereas the 'Graphics' object serves as a
tool for manipulating an image.

M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
I am trying to create an image to put in a cell of the C1flexgrid
control. There isn't an image already there to get and draw on. I
would like to create a graphics object and draw the parts on it that I
want, then convert the graphic to an image to put into the cell. Here
is something I am trying but am getting errors with it:

Here I am just trying to get the procedure down for creating the image
before I start messing with trying to put it into the grid cell.

'***** CODE STARTS HERE *****
Dim NewFont As New Font(fg.Font.Fo ntFamily, fg.Font.Size / 2,
FontStyle.Regul ar)

Dim pic As Bitmap = New Bitmap(box.Widt h, box.Height _
, Imaging.PixelFo rmat.Format24bp pRgb)

g = Graphics.FromIm age(pic)
g.SmoothingMode = SmoothingMode.A ntiAlias

g.DrawString("H ", NewFont, Brushes.Blue, 0, 0)

Dim st As System.IO.Strea m

pic.Save(st, System.Drawing. Imaging.ImageFo rmat.Bmp)
Dim img As Image = Image.FromStrea m(st)

'**** END OF CODE ****

I keep getting told that st is nothing when I try to save to it, but
this a must inherit object.

Am I missing the boat completely here?

Nov 21 '05 #3
I think I found a solution, is this a bad idea for some reason?

If I use a MemoryStream:
Dim st As New System.IO.Memor yStream

then I don't get an error and it works.


Nov 21 '05 #4
"Kalvin" <kt***@streck.c om> schrieb:
I think I found a solution, is this a bad idea for some reason?

If I use a MemoryStream:
Dim st As New System.IO.Memor yStream

then I don't get an error and it works.

Sure, you can save the image to a memory stream instead of saving it to a

M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: curwen | last post by:
Hi, I have problem to create a well formed xsl-fo document using images dynamically generated from an http request using this tag: <fo:external-graphic content-type="content-type:image/gif" src="controller.jsp?page=test&mode=image" /> doesn't work (it says a ';' is missing) the controller.jsp is sending a gif image to the browser and is
by: Charax | last post by:
Is it possible to use CSS to define <hr> as a graphic image? FrontPage 2003 has apparently dropped the graphic hr from their themes and I am becoming more involved in using CSS, but would like to retain the automatic inclusion of a graphic in place of hr. I have a 300 px graphic I'd like to continue using, without a manual search and replace of <hr> on 300 web pages.... Thanks,
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me to use the above controls, example 1. The bottom two subroutines will print a graphic file, example...
by: ray well | last post by:
hi, i need to give the user the ability to extract a rectangular area of their choice from a graphic displayed in a picture box to the clipboard, so they can use it elsewhere. say the graphic has an image of a house with a door in it and the user is interested in the door. the rectangle is selected by placing the mouse on the upper left corner of the door, pressing down on the left mouse button, and draging it to the lower right...
by: André | last post by:
Hi, I try to create and render a graphic among other objects like e.g. tables, labels, buttons. The tables are not a problem, neither the graphic. My problem is that i can't render both together. With the code below, i only see the graphic, nothing else (no table, label, button). How can i see the table and below the table, the graphic?
by: tshad | last post by:
I have an aspx window that is going to open a window (javascript) and display a graphic. I want to resize the window to the size of the graphic before it actually displays - how do I do that? In my calling routine I have the following: *********************************** function OpenLogoPreviewWindow() { window.open('logoDisplay.htm','mywindow'); }
by: icepick72 | last post by:
On an academic note, I want to copy a Graphic to an Image (Bitmap). I have the Graphic object but not the origin image from which it originates; this is because I'm overriding the PrintDocument class OnPagePrint method which only provides me an e.Graphic (see code sample below). The FCL doesn't seem to natively support Graphic =(Image)Bitmap. I have tried BitBlt workaround in the source code to copy printer e.Graphic into the bmp...
by: Jonathan Wood | last post by:
I've figured out how to create an image on the fly on my Website. Once created, I write the image to the page using code like this: Bitmap bm = Response.ContentType = "image/jpeg"; bm.Save(Response.OutputStream, ImageFormat.Jpeg); The code I have does indeed display the graphic, but the page shows nothing else. I need to write the image to a location within my Web page.
by: Joe | last post by:
this file is drawn in VB.NET and input output goes by XmlSerializer. Therefore, simple output file looks like: <?xml version="1.0" encoding="utf-8"?> <DrawablePicture xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" BackColor="-1250856"> <DrawableRectangle LineWidth="2" X1="377" Y1="88" X2="323" Y2="130" ForeColor="-16777216" BackColor="-1" /> </DrawablePicture>
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.