Graphics.RotateTransform() Has No Effect On My Bitmap

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

I am trying to write code to rotate a graphic that I have. Here is the code
I am currently using:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.RotateTransform(90)
frogbitmap.Save(Server.MapPath("images/frog2.gif"), Imaging.ImageFormat.Gif)


However, the file that is output to frog2.gif is exactly the same as
frog.gif. I know that the problem is somewhere in my RotateTransform() code
because when I use the following code:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.DrawLine(New Pen(Color.HotPink, 10), -1, -1, 47, 47)
frogbitmap.Save(Server.MapPath("images/frog2.gif"), Imaging.ImageFormat.Gif)


The output frog2.gif has the pink line through it as I would expect. What is
it that I am not doing that I need to do with RotateTransform()? Thanks.
 
H

Herfried K. Wagner [MVP]

Nathan Sokalski said:
I am trying to write code to rotate a graphic that I have. Here is the code
I am currently using:
[...]
Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.DrawLine(New Pen(Color.HotPink, 10), -1, -1, 47, 47)

Create a new bitmap, then obtain the 'Graphics' object, apply the
transformation and use 'Graphics.DrawImage' to /draw/ the bitmap onto the
other bitmap to rotate it.
 
N

Nathan Sokalski

As I mentioned in my original message, I am trying to rotate the image. I
may have been unclear that I want to save it with the same name (I know I
wasn't doing that in my original code yet). However, when I create my Bitmap
from the same file that I try to Save it as, I recieve the following error:


[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +581
System.Drawing.Image.Save(String filename, ImageFormat format) +61
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273


The error is in the Save line which looks like:

frogbitmap.Save(Server.MapPath("images/frog2.gif"), Imaging.ImageFormat.Gif)

When the Bitmap is created from "images/frog.gif" everything is fine, but
when it is created from "images/frog2.gif" I recieve the error mentioned
above. The error message isn't much help, because everything on the web that
I could find for that error code was about databases. What can I do to allow
myself to save the Bitmap to the same file I created it from? Thanks.
 
K

Ken Tucker [MVP]

Hi,

Open the image with a filestream. Close the stream after you
load the image and you can save back to the same file.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim bm As Bitmap
Dim fs As New FileStream("C:\bliss.jpg", FileMode.Open)

bm = New Bitmap(fs)
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
fs.Close()

bm.Save("C:\bliss.jpg", ImageFormat.Jpeg)
Image1.ImageUrl = "C:\bliss.jpg"
End Sub

Ken
--------------------
Nathan Sokalski said:
As I mentioned in my original message, I am trying to rotate the image. I
may have been unclear that I want to save it with the same name (I know I
wasn't doing that in my original code yet). However, when I create my
Bitmap from the same file that I try to Save it as, I recieve the
following error:


[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +581
System.Drawing.Image.Save(String filename, ImageFormat format) +61
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273


The error is in the Save line which looks like:

frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)

When the Bitmap is created from "images/frog.gif" everything is fine, but
when it is created from "images/frog2.gif" I recieve the error mentioned
above. The error message isn't much help, because everything on the web
that I could find for that error code was about databases. What can I do
to allow myself to save the Bitmap to the same file I created it from?
Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Ken Tucker said:
Hi,

I think the bitmap class rotateflip method is what you are
looking for

Dim bm As Bitmap
bm = New Bitmap("C:\bliss.jpg")
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
bm.Save("C:\bliss2.jpg", Imaging.ImageFormat.Jpeg)

http://msdn.microsoft.com/library/d...lrfsystemdrawingimageclassrotatefliptopic.asp

Ken
 
N

Nathan Sokalski

That sounds and looks like it should work to me, but I am recieving an error
when creating the New Bitmap:

Invalid parameter used.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid parameter used.

Source Error:

Line 34: Dim frogbitmap As Bitmap
Line 35: Dim frogstream As New
IO.FileStream(Server.MapPath("images/frog2.gif"), IO.FileMode.Open)
Line 36: frogbitmap = New Bitmap(frogstream)
Line 37: 'Dim froggraphic As Graphics =
Graphics.FromImage(frogbitmap)
Line 38: 'frogbitmap.RotateFlip(RotateFlipType.Rotate90FlipNone)

Source File: C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb
Line: 36

Stack Trace:

[ArgumentException: Invalid parameter used.]
System.Drawing.Bitmap..ctor(Stream stream) +271
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:36
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273



Is there something wrong with my FileStream code? Do I have to do something
different when creating the Bitmap? Any help would be appreciated. Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Ken Tucker said:
Hi,

Open the image with a filestream. Close the stream after you
load the image and you can save back to the same file.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim bm As Bitmap
Dim fs As New FileStream("C:\bliss.jpg", FileMode.Open)

bm = New Bitmap(fs)
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
fs.Close()

bm.Save("C:\bliss.jpg", ImageFormat.Jpeg)
Image1.ImageUrl = "C:\bliss.jpg"
End Sub

Ken
--------------------
Nathan Sokalski said:
As I mentioned in my original message, I am trying to rotate the image. I
may have been unclear that I want to save it with the same name (I know I
wasn't doing that in my original code yet). However, when I create my
Bitmap from the same file that I try to Save it as, I recieve the
following error:


[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +581
System.Drawing.Image.Save(String filename, ImageFormat format) +61
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs
e) in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273


The error is in the Save line which looks like:

frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)

When the Bitmap is created from "images/frog.gif" everything is fine, but
when it is created from "images/frog2.gif" I recieve the error mentioned
above. The error message isn't much help, because everything on the web
that I could find for that error code was about databases. What can I do
to allow myself to save the Bitmap to the same file I created it from?
Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Ken Tucker said:
Hi,

I think the bitmap class rotateflip method is what you are
looking for

Dim bm As Bitmap
bm = New Bitmap("C:\bliss.jpg")
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
bm.Save("C:\bliss2.jpg", Imaging.ImageFormat.Jpeg)

http://msdn.microsoft.com/library/d...lrfsystemdrawingimageclassrotatefliptopic.asp

Ken
-------------------------
I am trying to write code to rotate a graphic that I have. Here is the
code I am currently using:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.RotateTransform(90)
frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)


However, the file that is output to frog2.gif is exactly the same as
frog.gif. I know that the problem is somewhere in my RotateTransform()
code because when I use the following code:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.DrawLine(New Pen(Color.HotPink, 10), -1, -1, 47, 47)
frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)


The output frog2.gif has the pink line through it as I would expect.
What is it that I am not doing that I need to do with
RotateTransform()? Thanks.
 
K

Ken Tucker [MVP]

Hi,

I would check that server.mappath is coming up with the right
path. Try putting the line where you create the stream in a try catch block
and response.write the exception to get more info on the error.

Ken
---------------------
Nathan Sokalski said:
That sounds and looks like it should work to me, but I am recieving an
error when creating the New Bitmap:

Invalid parameter used.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid parameter used.

Source Error:

Line 34: Dim frogbitmap As Bitmap
Line 35: Dim frogstream As New
IO.FileStream(Server.MapPath("images/frog2.gif"), IO.FileMode.Open)
Line 36: frogbitmap = New Bitmap(frogstream)
Line 37: 'Dim froggraphic As Graphics =
Graphics.FromImage(frogbitmap)
Line 38: 'frogbitmap.RotateFlip(RotateFlipType.Rotate90FlipNone)

Source File: C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb Line:
36

Stack Trace:

[ArgumentException: Invalid parameter used.]
System.Drawing.Bitmap..ctor(Stream stream) +271
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:36
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273



Is there something wrong with my FileStream code? Do I have to do
something different when creating the Bitmap? Any help would be
appreciated. Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Ken Tucker said:
Hi,

Open the image with a filestream. Close the stream after you
load the image and you can save back to the same file.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim bm As Bitmap
Dim fs As New FileStream("C:\bliss.jpg", FileMode.Open)

bm = New Bitmap(fs)
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
fs.Close()

bm.Save("C:\bliss.jpg", ImageFormat.Jpeg)
Image1.ImageUrl = "C:\bliss.jpg"
End Sub

Ken
--------------------
Nathan Sokalski said:
As I mentioned in my original message, I am trying to rotate the image.
I may have been unclear that I want to save it with the same name (I
know I wasn't doing that in my original code yet). However, when I
create my Bitmap from the same file that I try to Save it as, I recieve
the following error:


[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +581
System.Drawing.Image.Save(String filename, ImageFormat format) +61
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs
e) in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1273


The error is in the Save line which looks like:

frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)

When the Bitmap is created from "images/frog.gif" everything is fine,
but when it is created from "images/frog2.gif" I recieve the error
mentioned above. The error message isn't much help, because everything
on the web that I could find for that error code was about databases.
What can I do to allow myself to save the Bitmap to the same file I
created it from? Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Hi,

I think the bitmap class rotateflip method is what you are
looking for

Dim bm As Bitmap
bm = New Bitmap("C:\bliss.jpg")
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
bm.Save("C:\bliss2.jpg", Imaging.ImageFormat.Jpeg)

http://msdn.microsoft.com/library/d...lrfsystemdrawingimageclassrotatefliptopic.asp

Ken
-------------------------
I am trying to write code to rotate a graphic that I have. Here is the
code I am currently using:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.RotateTransform(90)
frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)


However, the file that is output to frog2.gif is exactly the same as
frog.gif. I know that the problem is somewhere in my RotateTransform()
code because when I use the following code:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.DrawLine(New Pen(Color.HotPink, 10), -1, -1, 47, 47)
frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)


The output frog2.gif has the pink line through it as I would expect.
What is it that I am not doing that I need to do with
RotateTransform()? Thanks.
 
N

Nathan Sokalski

I used the following line to verify that Server.MapPath is returning the
correct path, which it is:

System.Diagnostics.Debug.WriteLine(Server.MapPath("images/frog2.gif"))

However, it still gives me the same error as follows:

Invalid parameter used.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid parameter used.

Source Error:

Line 34: Dim frogstream As New
IO.FileStream(Server.MapPath("images/frog2.gif"), IO.FileMode.Open)
Line 35:
System.Diagnostics.Debug.WriteLine(Server.MapPath("images/frog2.gif"))
Line 36: frogbitmap = New Bitmap(frogstream)
Line 37: 'Dim froggraphic As Graphics =
Graphics.FromImage(frogbitmap)
Line 38: 'frogbitmap.RotateFlip(RotateFlipType.Rotate90FlipNone)

Source File: C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb
Line: 36

Stack Trace:

[ArgumentException: Invalid parameter used.]
System.Drawing.Bitmap..ctor(Stream stream) +271
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:36
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273



Is there anything I should check for in the IO.FileStream (named frogstream
in my code)? Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Ken Tucker said:
Hi,

I would check that server.mappath is coming up with the right
path. Try putting the line where you create the stream in a try catch
block and response.write the exception to get more info on the error.

Ken
---------------------
Nathan Sokalski said:
That sounds and looks like it should work to me, but I am recieving an
error when creating the New Bitmap:

Invalid parameter used.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid parameter used.

Source Error:

Line 34: Dim frogbitmap As Bitmap
Line 35: Dim frogstream As New
IO.FileStream(Server.MapPath("images/frog2.gif"), IO.FileMode.Open)
Line 36: frogbitmap = New Bitmap(frogstream)
Line 37: 'Dim froggraphic As Graphics =
Graphics.FromImage(frogbitmap)
Line 38: 'frogbitmap.RotateFlip(RotateFlipType.Rotate90FlipNone)

Source File: C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb
Line: 36

Stack Trace:

[ArgumentException: Invalid parameter used.]
System.Drawing.Bitmap..ctor(Stream stream) +271
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs
e) in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:36
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273



Is there something wrong with my FileStream code? Do I have to do
something different when creating the Bitmap? Any help would be
appreciated. Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Ken Tucker said:
Hi,

Open the image with a filestream. Close the stream after you
load the image and you can save back to the same file.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim bm As Bitmap
Dim fs As New FileStream("C:\bliss.jpg", FileMode.Open)

bm = New Bitmap(fs)
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
fs.Close()

bm.Save("C:\bliss.jpg", ImageFormat.Jpeg)
Image1.ImageUrl = "C:\bliss.jpg"
End Sub

Ken
--------------------
As I mentioned in my original message, I am trying to rotate the image.
I may have been unclear that I want to save it with the same name (I
know I wasn't doing that in my original code yet). However, when I
create my Bitmap from the same file that I try to Save it as, I recieve
the following error:


[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +581
System.Drawing.Image.Save(String filename, ImageFormat format) +61
WebApplication1.ImageNoCache.btnRotate_Click(Object sender, EventArgs
e) in C:\Inetpub\wwwroot\WebApplication1\ImageNoCache.aspx.vb:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1273


The error is in the Save line which looks like:

frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)

When the Bitmap is created from "images/frog.gif" everything is fine,
but when it is created from "images/frog2.gif" I recieve the error
mentioned above. The error message isn't much help, because everything
on the web that I could find for that error code was about databases.
What can I do to allow myself to save the Bitmap to the same file I
created it from? Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Hi,

I think the bitmap class rotateflip method is what you are
looking for

Dim bm As Bitmap
bm = New Bitmap("C:\bliss.jpg")
bm.RotateFlip(RotateFlipType.Rotate90FlipNone)
bm.Save("C:\bliss2.jpg", Imaging.ImageFormat.Jpeg)

http://msdn.microsoft.com/library/d...lrfsystemdrawingimageclassrotatefliptopic.asp

Ken
-------------------------
I am trying to write code to rotate a graphic that I have. Here is the
code I am currently using:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.RotateTransform(90)
frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)


However, the file that is output to frog2.gif is exactly the same as
frog.gif. I know that the problem is somewhere in my
RotateTransform() code because when I use the following code:


Dim frogbitmap As New
Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif")))
Dim froggraphic As Graphics = Graphics.FromImage(frogbitmap)
froggraphic.DrawLine(New Pen(Color.HotPink, 10), -1, -1, 47, 47)
frogbitmap.Save(Server.MapPath("images/frog2.gif"),
Imaging.ImageFormat.Gif)


The output frog2.gif has the pink line through it as I would expect.
What is it that I am not doing that I need to do with
RotateTransform()? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top