[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

=?Utf-8?B?cm9kY2hhcg==?=

10/28/2004 3:33:00 PM

Hi,

Does anyone know how I can draw some images onto a
background image and then save the image to a file? I
thought an easy way would be to draw the images onto a
graphics object using the DrawImageMethod() then save it
but I can't figure out how to save the graphics object to
a file.

Bitmap myImg = new Bitmap(@"porche.jpg");
Graphics g = Graphics.FromImage(curBitmap);
g.DrawImage(myImg, 0, 0, myImg.Width, myImg.Height);

How can I save this Graphics object to a file?

Thanks,
Lachlan
2 Answers

=?Utf-8?B?cm9kY2hhcg==?=

10/28/2004 4:10:00 PM

0

It's ok I figured out that the Graphics object must work
on the actual image object passed into the constructor.
Code is below if anyone cares...


private void Form1_Load(object sender, System.EventArgs e)
{
Image bgImage = Image.FromFile(@"porche_bg.jpg");
Graphics g = Graphics.FromImage(bgImage);

Image imgToDraw = Image.FromFile(@"porche.jpg");
g.DrawImage(imgToDraw, 300, 150, imgToDraw.Width,
imgToDraw.Height);
g.Save();

bgImage.Save("porche_modified.jpg");
MessageBox.Show("Done!");
Application.Exit();
}


>-----Original Message-----
>Hi,
>
>Does anyone know how I can draw some images onto a
>background image and then save the image to a file? I
>thought an easy way would be to draw the images onto a
>graphics object using the DrawImageMethod() then save it
>but I can't figure out how to save the graphics object to
>a file.
>
>Bitmap myImg = new Bitmap(@"porche.jpg");
>Graphics g = Graphics.FromImage(curBitmap);
>g.DrawImage(myImg, 0, 0, myImg.Width, myImg.Height);
>
>How can I save this Graphics object to a file?
>
>Thanks,
>Lachlan
>.
>

James Westgate

10/28/2004 4:17:00 PM

0

You could also create a new bitmap object and get a handle from it using
Graphics.FromImage, then draw on that handle

James

--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.cra...

Take the ERM Tour at http://www.flowchartc...

"lachlan James" <anonymous@discussions.microsoft.com> wrote in message
news:1ca501c4bd08$82855260$a501280a@phx.gbl...
> It's ok I figured out that the Graphics object must work
> on the actual image object passed into the constructor.
> Code is below if anyone cares...
>
>
> private void Form1_Load(object sender, System.EventArgs e)
> {
> Image bgImage = Image.FromFile(@"porche_bg.jpg");
> Graphics g = Graphics.FromImage(bgImage);
>
> Image imgToDraw = Image.FromFile(@"porche.jpg");
> g.DrawImage(imgToDraw, 300, 150, imgToDraw.Width,
> imgToDraw.Height);
> g.Save();
>
> bgImage.Save("porche_modified.jpg");
> MessageBox.Show("Done!");
> Application.Exit();
> }
>
>
>>-----Original Message-----
>>Hi,
>>
>>Does anyone know how I can draw some images onto a
>>background image and then save the image to a file? I
>>thought an easy way would be to draw the images onto a
>>graphics object using the DrawImageMethod() then save it
>>but I can't figure out how to save the graphics object to
>>a file.
>>
>>Bitmap myImg = new Bitmap(@"porche.jpg");
>>Graphics g = Graphics.FromImage(curBitmap);
>>g.DrawImage(myImg, 0, 0, myImg.Width, myImg.Height);
>>
>>How can I save this Graphics object to a file?
>>
>>Thanks,
>>Lachlan
>>.
>>