Saturday, March 31, 2012
System.Drawing.Drawing2D.GraphicsPath in ASP.Net
Can I use GraphicsPath class in ASP.Net page? There's other way to do this?
thanks a lotEduardo Rosa wrote:
> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do this
?
> thanks a lot
>
What's your goal?
//Rutger
You can create graphic images from any .NET code.
The question then becomes "what do you do with the image?"
In ASP.NET the most obvious thing would be to point an image control to it.
MyImageControl.ImageURL="myImage.gif"
or
MyIMageContro.ImageURL="myImageGeneratorPage.aspx"
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Eduardo Rosa" <eddr5000@.yahoo.com.br> wrote in message
news:e0mB7CGkEHA.1996@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do
> this?
> thanks a lot
>
thanks a lot, I was just curious...
System.Drawing.Drawing2D.GraphicsPath in ASP.Net
Can I use GraphicsPath class in ASP.Net page? There's other way to do this?
thanks a lotEduardo Rosa wrote:
> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do this?
> thanks a lot
What's your goal?
//Rutger
You can create graphic images from any .NET code.
The question then becomes "what do you do with the image?"
In ASP.NET the most obvious thing would be to point an image control to it.
MyImageControl.ImageURL="myImage.gif"
or
MyIMageContro.ImageURL="myImageGeneratorPage.aspx"
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Eduardo Rosa" <eddr5000@.yahoo.com.br> wrote in message
news:e0mB7CGkEHA.1996@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Can I use GraphicsPath class in ASP.Net page? There's other way to do
> this?
> thanks a lot
thanks a lot, I was just curious...
System.drawing.image
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."
Does anyone know what I can do about these issues?Try also
graphicOrig.Dispose();
--Daniel
http://staff.newtelligence.com/danielf/
--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image
Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."
Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:
string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.F ileName); // fileUpload is
the id of fileupload html control
Zeeshan
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.
graphicOrig.Dispose();
rectOrig.Dispose();
Zeeshan.
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
thanks
it worked !
"Zeeshan Muhammad" wrote:
> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> > Hi,
> > I have this question.
> > When I use the FileUpload WebControl to post an Image (= SourceFile) that
> > I
> > want to resize and write to the server, I keep getting this situation.
> > If that SourceFile is located in My Documents (as in "C:\Documents and
> > Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> > a
> > 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> > from
> > "C:\Folder\imgName".
> > What can I do about this ?
> > Actually I found a workaround, but this gives me an error as well...
> > I can save the PostedFile like this
> > PostedFile.SaveAs(imgPath + "DummyName");
> > After which I can do these steps without any problem
> > System.Drawing.Image srcImage =
> > System.Drawing.Image.FromFile(imgPath + DummyName);
> > Graphics graphicOrig = Graphics.FromImage(srcImage);
> > graphicOrig.CompositingQuality =
> > CompositingQuality.HighQuality;
> > graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> > graphicOrig.InterpolationMode =
> > InterpolationMode.HighQualityBicubic;
> > Rectangle rectOrig = new Rectangle();
> > graphicOrig.DrawImage(srcImage, rectOrig);
> > srcImage.Save(NewFileName, ImageFormat.Jpeg);
> > srcImage.Dispose();
> > The final srcImage is perfect, and everything I need but when I want to do
> > this
> > File.Delete(imgPath + dummyName);
> > I get the IOException that File cannot be deleted:
> > "The process cannot access the file 'ImgPAth\dummyName' because it is
> > being
> > used by another process."
> > Does anyone know what I can do about these issues?
>
thanks
it worked !
"Daniel Fisher(lennybacon)" wrote:
> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
System.drawing.image
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."
Does anyone know what I can do about these issues?Try also
graphicOrig.Dispose();
--Daniel
http://staff.newtelligence.com/danielf/
--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image
Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."
Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:
string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.FileName); // fileUpload is
the id of fileupload html control
Zeeshan
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.
graphicOrig.Dispose();
rectOrig.Dispose();
Zeeshan.
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
thanks
it worked !
"Zeeshan Muhammad" wrote:
> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
>
>
thanks
it worked !
"Daniel Fisher(lennybacon)" wrote:
> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
System.Drawing.Image.FromFile from URL?
http://www.domain.com/image.jpg instead of c:\image.jpg. ?
thanks!No, but you can use the WebClient or WebRequest classes to bring the
bytes to the local computer and then create the Image obect.
HTH,
Scott
http://www.OdeToCode.com
On 18 Sep 2004 09:23:29 -0700, jcharth@.hotmail.com (Joseph) wrote:
>can i create a system.drawing.Image from a url. using
>http://www.domain.com/image.jpg instead of c:\image.jpg. ?
>thanks!
As scott mentioned, you do not have any method that can directly read the
image from URL.
Use webclient and read it into a byte[] using DownloadData
then you Image class to load it
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"Joseph" <jcharth@.hotmail.com> wrote in message
news:2f2b8b0b.0409180823.2a6f2f18@.posting.google.com...
> can i create a system.drawing.Image from a url. using
> http://www.domain.com/image.jpg instead of c:\image.jpg. ?
> thanks!
System.Drawing.Image.FromFile from URL?
http://www.domain.com/image.jpg instead of c:\image.jpg. ?
thanks!No, but you can use the WebClient or WebRequest classes to bring the
bytes to the local computer and then create the Image obect.
HTH,
--
Scott
http://www.OdeToCode.com
On 18 Sep 2004 09:23:29 -0700, jcharth@.hotmail.com (Joseph) wrote:
>can i create a system.drawing.Image from a url. using
>http://www.domain.com/image.jpg instead of c:\image.jpg. ?
>thanks!
As scott mentioned, you do not have any method that can directly read the
image from URL.
Use webclient and read it into a byte[] using DownloadData
then you Image class to load it
--
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"Joseph" <jcharth@.hotmail.com> wrote in message
news:2f2b8b0b.0409180823.2a6f2f18@.posting.google.c om...
> can i create a system.drawing.Image from a url. using
> http://www.domain.com/image.jpg instead of c:\image.jpg. ?
> thanks!
System.Drawing.Image.Save() on Transparent GIF
app and rendering them by using
System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF).
I am confident that the transparency is working properly because if I save
the created image to the local hard disk and then view it in a web page or an
image editor, the transparency is correct. I can also view the transparency
on-the-fly in a Windows.Forms application.
Yet, when I render the image on-the-fly to the Response.OutputStream, I lose
the transparency and the background color is displayed in the page.
Has anyone got any ideas or experience in rendering transparent GIFs this way?
Thanks,
--
Dale Preston
MCAD C#
MCSE, MCDBAHello Dale,
From your description, you've programmatically create an transparent gif
image and flush it into ASP.NET page's response stream. However, you found
the output image lose the transparency, correct?
Based on my understanding, it is likely that the bits save into the
response stream is different from the expected transparent gif's binary
bits. I suggest you test through the following means:
1. first use your code to generate the gif and save it into a disk file(gif
file), make sure that the gif file is working as transparent one.
2. use ASP.NET code to write the gif file into response stream as below:
===============
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "image/gif"
Response.WriteFile("D:\temp\web_temp\images\duglogobigtextcolor.gif")
Response.End()
End Sub
===============
based on my test, the above code can correctly flush a correct transparent
gif out to client-side. If the above test also return a non-transparent
one, it seems the generated gif has some bits get corrupted.
Please feel free to let me know if you have any other finding or anything I
missed.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks, Steven. I was afraid you were going to say that. Our web
infrastructure policies don't generally allow web apps to write to the local
disk so that's going to be a problem. I may have to look for another
alternative.
The goal was to present an error message in a text bubble with the bubble
hook pointing to the form field with the improper value. The transparent GIF
seemed like just the ticket.
Do you have any other suggestions or know of articles or examples of
alternative methods for displaying text in a bubble like that on-the-fly?
I built my code following the examples in KB #319061 and
http://www.bobpowell.net/giftransparency.htm. Do you know if I would have
the same problem with a transparent PNG? If a PNG is a possibility, do you
know of any documentation on how to set the transparency in a PNG using .Net?
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Steven Cheng[MSFT]" wrote:
Quote:
Originally Posted by
Hello Dale,
>
From your description, you've programmatically create an transparent gif
image and flush it into ASP.NET page's response stream. However, you found
the output image lose the transparency, correct?
>
Based on my understanding, it is likely that the bits save into the
response stream is different from the expected transparent gif's binary
bits. I suggest you test through the following means:
>
1. first use your code to generate the gif and save it into a disk file(gif
file), make sure that the gif file is working as transparent one.
>
2. use ASP.NET code to write the gif file into response stream as below:
>
===============
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "image/gif"
>
>
Response.WriteFile("D:\temp\web_temp\images\duglogobigtextcolor.gif")
>
Response.End()
>
>
>
End Sub
===============
>
based on my test, the above code can correctly flush a correct transparent
gif out to client-side. If the above test also return a non-transparent
one, it seems the generated gif has some bits get corrupted.
>
Please feel free to let me know if you have any other finding or anything I
missed.
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Just FYI, Steven.
I was able to resolve my problem and, hopefully make my solution more robust
than it may have otherwise been.
The problem was that the Bitmap object I was drawing on using the Graphics
class seems to corrupt the palette by duplicating a single palette entry
which was, coincidentally, the transparent color.
While I was aware of the duplication, I was skipping the first occurrence
because no pixels pointed to it. The second occurrence was where all the
transparent pixels pointed and that is the entry I set the alpha to 0 on.
This issue did not cause any problems in Windows.Forms, in Paint Shop Pro, in
Microsoft Image Composer, or if I saved to disk and then opened the saved
file in a web page.
For some reason, though, it did create a problem when saving to the
Response.OutputStream because the method requires re-assigning the ImageType.
There should be an overload of the Save method that writes to a Stream
without having to pass the ImageType just as there is an overload that saves
to a file.
The bottom line is, I re-wrote my code to detect duplicate entries in the
palette, then modify all pixels that pointed to any of the duplicates so that
they point to the first occurrence of the color, and then modify all of the
remaining duplicate palette entries so that they are unique. With this done,
I was able to save my image to the Response.OutputStream with the
transparency working as expected.
Thanks again for your help.
Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:
Quote:
Originally Posted by
Thanks, Steven. I was afraid you were going to say that. Our web
infrastructure policies don't generally allow web apps to write to the local
disk so that's going to be a problem. I may have to look for another
alternative.
>
The goal was to present an error message in a text bubble with the bubble
hook pointing to the form field with the improper value. The transparent GIF
seemed like just the ticket.
>
Do you have any other suggestions or know of articles or examples of
alternative methods for displaying text in a bubble like that on-the-fly?
>
I built my code following the examples in KB #319061 and
http://www.bobpowell.net/giftransparency.htm. Do you know if I would have
the same problem with a transparent PNG? If a PNG is a possibility, do you
know of any documentation on how to set the transparency in a PNG using .Net?
--
Dale Preston
MCAD C#
MCSE, MCDBA
>
>
"Steven Cheng[MSFT]" wrote:
>
Quote:
Originally Posted by
Hello Dale,
From your description, you've programmatically create an transparent gif
image and flush it into ASP.NET page's response stream. However, you found
the output image lose the transparency, correct?
Based on my understanding, it is likely that the bits save into the
response stream is different from the expected transparent gif's binary
bits. I suggest you test through the following means:
1. first use your code to generate the gif and save it into a disk file(gif
file), make sure that the gif file is working as transparent one.
2. use ASP.NET code to write the gif file into response stream as below:
===============
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "image/gif"
Response.WriteFile("D:\temp\web_temp\images\duglogobigtextcolor.gif")
Response.End()
End Sub
===============
based on my test, the above code can correctly flush a correct transparent
gif out to client-side. If the above test also return a non-transparent
one, it seems the generated gif has some bits get corrupted.
Please feel free to let me know if you have any other finding or anything I
missed.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Dale,
Thanks for your followup.
I'm glad that you've figured out the problem and found a workable solution.
As always, welcome to post here when you need any help from us.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.