473,503 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a bitmap from Graphics

Hello,

I have a function that accepts an Image as the input. Currently, I load a
bitmap in the calling class and pass that in. I'd like to create an overlay
with another image and then pass the resulting bitmap in to the
aforementioned function for it to finish everything.

The problem I'm having is that after I combine the two images, I am left
with a Graphics object. I can't do a g.DrawImage at this point. I know I can
save it to a file first, but I'd rather avoid that since once it is created
and used, it isn't needed anymore. Is there any way to get a bitmap out of
the Graphics object without saving it to a file first? If not, I can always
modify the function to accept two images instead of one, but I'd rather avoid
that if possible.

Thanks,
Frij
Sep 15 '06 #1
1 6306
The System.Drawing.Graphics class that is associated with a Device Context.
The Device Context is associated with a Window. In other words, every Window
(every UI element in Windows) has a Device Context associated with it so
that the Window can be drawn. So, it is the Windows that provides the Device
Context that provides a Graphics instance for drawing the Window. In other
words, you can't take a Graphics instance from one Device Context and use it
to draw on another Device Context.

When you combine 2 images, you are combining the contents of 2 Windows. Each
has its own Device Context. Now, if the new image is the same size as one of
the 2 images you are combining, you can draw using the Graphics instance
from the destination image. If the images is a different size, you have to
create a new image, with its own Device Context, and draw on that, using the
Graphics instance for that image.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

What You Seek Is What You Get.

"Frijoles" <Fr******@discussions.microsoft.comwrote in message
news:3C**********************************@microsof t.com...
Hello,

I have a function that accepts an Image as the input. Currently, I load a
bitmap in the calling class and pass that in. I'd like to create an
overlay
with another image and then pass the resulting bitmap in to the
aforementioned function for it to finish everything.

The problem I'm having is that after I combine the two images, I am left
with a Graphics object. I can't do a g.DrawImage at this point. I know I
can
save it to a file first, but I'd rather avoid that since once it is
created
and used, it isn't needed anymore. Is there any way to get a bitmap out of
the Graphics object without saving it to a file first? If not, I can
always
modify the function to accept two images instead of one, but I'd rather
avoid
that if possible.

Thanks,
Frij

Sep 16 '06 #2

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

Similar topics

0
1513
by: Webgour | last post by:
Hello, I'm tring to create an indexed image on the fly with the following : Bitmap bcodeBitmap = new Bitmap(50,50,PixelFormat.Format32bppArgb); Graphics objGraphics =...
9
3059
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks ...
3
1958
by: mark | last post by:
I want plot points on a cartesian surface with single pixels. I have been unable to find a graphics member which draws points. (Is there one?) I would like to create a bitmap one element wide and...
4
2736
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
1
1885
by: Jeff | last post by:
Hey ASP.NET 2.0 I'm wondering if it's possible to create dynamic transparent images in asp.net 2.0? This is some code (see below) from my web project. In this code below I create a...
8
1493
by: Robert Dufour | last post by:
I been trying to look for samplecodes on how to create a simple tif file. I found a lot of commercial and stuff but I would prefer to roll my own. I only need to put some formatted text in a tif...
2
2584
by: Peter Oliphant | last post by:
I want to create a new Bitmap which is a portion of an existing Bitmap. For example, if I have a Bitmap that is 100x100 in size I might want to create a new Bitmap that is equivalent to the one...
5
2558
by: =?Utf-8?B?QVRU?= | last post by:
I have a bitmap of 100X100. On the load, the bitmap is created by a function (createimage()). On my OnPaint, I draw the image back to the screen (e.Graphics.DrawImage( bitmap, destrect)). Now,...
1
2860
by: amyyoungblood | last post by:
I am trying to plot my pushpins manually, but when I go to create the bitmap, I get an error message. Has anyone gotten this message before? code: MapImage mapImages = render.GetMap(mapSpec);...
0
7188
marktang
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,...
0
7063
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...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
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...
0
5558
agi2029
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,...
1
4987
isladogs
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...
0
4663
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...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.