bitmap image in asp.net c#

Posted by Jahi under ASP.NET on 2/16/2011 | Points: 10 | Views : 2942 | Status : [Member] | Replies : 2
This is the code in my webpage :


string MYNAME = "ANI";
string na1 = "jahi";
string na2 = "hafi";
string na3 = "sabi";
Bitmap BMP = new Bitmap(200, 200);
//string path = "../back.gif";
System.Drawing.Image IMG =System.Drawing.Image.FromFile(Server.MapPath("back.gif"));
Graphics GRP = Graphics.FromImage(IMG);
GRP.DrawEllipse(new Pen(Brushes.Blue), 50, 0, 20, 30);
Font FNT = new Font("Arial", 5);
GRP.DrawString(MYNAME, FNT, Brushes.Red, 55, 12);
GRP.DrawLine(new Pen(Brushes.Red), new Point(60, 30), new Point(20, 70));
GRP.DrawString(na1, FNT, Brushes.Red, 15, 80);
GRP.DrawEllipse(new Pen(Brushes.Blue), 10, 70, 20, 30);
GRP.DrawLine(new Pen(Brushes.Red), new Point(60, 30), new Point(60, 70));
GRP.DrawString(na2, FNT, Brushes.Red, 55, 80);
GRP.DrawEllipse(new Pen(Brushes.Blue), 50, 70, 20, 30);
GRP.DrawLine(new Pen(Brushes.Red), new Point(60, 30), new Point(100, 70));
GRP.DrawString(na3, FNT, Brushes.Red, 95, 80);
GRP.DrawEllipse(new Pen(Brushes.Blue), 90, 70, 20, 30);
GRP.Save();

Image1.ImageUrl = IMG;
IMG.Save("D:\\test.gif", System.Drawing.Imaging.ImageFormat.gif);



But this page contains error:

Error is:

Server Error in '/new Database2' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0029: Cannot implicitly convert type 'System.Drawing.Image' to 'string'

Source Error:

Line 88:
Line 89:
Line 90: Image1.ImageUrl = IMG;
Line 91: IMG.Save("D:\\test.gif", System.Drawing.Imaging.ImageFormat.gif);
Line 92:


Source File: c:\Documents and Settings\Capsule - 04\Desktop\tree creation\new Database2\product.aspx.cs Line: 90


Show Detailed Compiler Output:

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output


Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

\new Database2\product.aspx.cs(90,27): error CS0029: Cannot implicitly convert type 'System.Drawing.Image' to 'string'
c:\Documents and Settings\Capsule - 04\Desktop\tree creation\new Database2\product.aspx.cs(91,69): error CS0117: 'System.Drawing.Imaging.ImageFormat' does not contain a definition for 'gif'




Responses

Posted by: Madhu.b.rokkam on: 2/16/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Can you please brief your requirement also ??

Thanks and Regards
Madhu

Jahi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/16/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Try to save it in some other format and check if it gives the same error

Thanks
Karthik
www.f5Debug.net

Jahi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response