
February 11th, 2013, 09:53 AM
|
|
Contributing User
|
|
Join Date: Feb 2003
Location: New Jersey
Posts: 99

Time spent in forums: 10 h 51 m 12 sec
Reputation Power: 11
|
|
ASP.Net Creating Dynamic Images
I got the following tutorial for creating dynamic images from sitepoint and simply changed jpeg to gif. FillRectangle gives you a standard rectangle.
Does ASP.Net does have the following similar features as Adobe Fireworks:
Can you make a rounded rectangle?
Can you specify a matte?
Can you specify that you want that part of the button that doesn’t have color to be transparent?
Can you have a bevel and emboss effect to make a button have depth?
If any of these things are possible, how would they be done? Can you recommend a tutorial or a book that would help?
Thanks,
Robin
**************************************************
[code]
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack Then
Dim oBitmap As Bitmap = New Bitmap(468, 60)
Dim oGraphic As Graphics = Graphics.FromImage(oBitmap)
Dim oColor As System.Drawing.Color
Dim sColor As String = Request("BackgroundColor")
Dim sText As String = Request("Text")
Dim sFont As String = Request("Font")
Select Case sColor
Case "red"
oColor = Color.Red
Case "green"
oColor = Color.Green
Case "navy"
oColor = Color.Navy
Case "orange"
oColor = Color.Orange
Case Else
oColor = Color.Gray
End Select
Dim oBrush As New SolidBrush(oColor)
Dim oBrushWrite As New SolidBrush(Color.White)
oGraphic.FillRectangle(oBrush, 0, 0, 468, 60)
oGraphic.TextRenderingHint = TextRenderingHint.AntiAlias
Dim oFont As New Font(sFont, 13)
Dim oPoint As New PointF(5F, 5F)
oGraphic.DrawString(sText, oFont, oBrushWrite, oPoint)
'Response.ContentType = "image/gif"
'oBitmap.Save (Response.OutputStream, ImageFormat.gif)
oBitmap.Save(Server.MapPath("gen_img.gif"), ImageFormat.gif)
Response.Write("View the generated image <a target=""_blank"" href=""gen_img.gif"">here</a>")
End If
End Sub
</script>
<form runat="server">
<asp:TextBox runat="server" id="Text" />
<br><br>
<asp:dropdownlist runat="server" id="BackgroundColor">
<asp:ListItem Value="red">Red</asp:ListItem>
<asp:ListItem Value="green">Green</asp:ListItem>
<asp:ListItem Value="navy">Navy</asp:ListItem>
<asp:ListItem Value="orange">Orange</asp:ListItem>
</asp:dropdownlist>
<asp:dropdownlist runat="server" id="Font">
+ <asp:ListItem Value="Arial">Arial</asp:ListItem>
<asp:ListItem Value="Verdana">Verdana</asp:ListItem>
<asp:ListItem Value="Courier">Courier</asp:ListItem>
<asp:ListItem Value="Times New Roman">Times New Roman</asp:ListItem>
</asp:dropdownlist>
<br><br>
<asp:Button runat="Server" id="SubmitButton" Text="Generate Image" />
</form>
[code]
|