|
-
Sep 7th, 2002, 07:54 AM
#1
Thread Starter
Junior Member
ASP.NET and GDI+
Please,
I need help
What I want is:
Using ASP.NET, VB.NET and GDI+in the same aspx PAGE to be able to display a simple text using a text box, a button and ??? to place to display the text.
Thanks.
Best regards.
-
Sep 7th, 2002, 07:02 PM
#2
What do you need GDI for? Just add a button, a textbiox, and a label. Set the label text..That is all.
-
Sep 7th, 2002, 07:09 PM
#3
Thread Starter
Junior Member
ASP.NET GDI+
I don't need a Label because with GDI+ I have infinite posibilities to do with a text .
Best regards.
-
Sep 8th, 2002, 09:18 PM
#4
yay gay
but it will be a lot more time consuming
-
Sep 8th, 2002, 09:18 PM
#5
yay gay
and if many ppl go to ur page it will eat ur ram up all
-
Sep 8th, 2002, 09:59 PM
#6
PowerPoster
Is the text custom to every visitor? If it isn't, and is just changed every now and then, you might want to look into having the page create one graphic, store it on the server, and include that in the page. Whenever you want a new graphic created, you can schedule your app to do so, and overwrite the old one.
-
Sep 9th, 2002, 08:39 AM
#7
i think I see what you mean. Look into the Bitmap object. You can create a new Bitmap object, then use the graphics object DrawString to write text to it, and use Bitmap.Save to write it out to the response object. Here is a little mor ecomplex example
Code:
<%@ Page Language="VB" ContentType="image/jpeg" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script language="VB" runat="server">
Sub Page_Load(Sender as Object, E as EventArgs)
Dim rnd As New Random()
Dim strText As String
' create a font
Dim fnt As Font = New Font("Arial", 12, FontStyle.Bold)
' Load a bitmap based image from a file
Dim newBitmap As Bitmap = New Bitmap(Server.MapPath("back.jpg"))
' This line is for creating a blank bitmap.
'Dim newBitmap As Bitmap = New Bitmap(400,50,PixelFormat.Format32bppARGB)
' Bind the Bitmap to the graphics object
Dim g As Graphics = Graphics.FromImage(newBitmap)
' Get a random number to choose what text to show
Select Case rnd.Next(5)
Case 1
strText = "The place to be!"
Case 2
strText = "What did you expect this message to say?"
Case 3
strText = "How about a nice hot cup of STFU!"
Case 4
strText = "Proving Monkeys CAN fly!"
Case Else
strText = "D'oh!"
End Select
' get the length of the string in pixels
Dim tempg As Graphics = Graphics.FromImage(new Bitmap(1,1))
Dim StringLength As Integer = tempg.MeasureString(strText,fnt).Width
tempg.Dispose
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
' Draw the string to the Graphics object. Subtract the strings pixel length from the
' images width do determine postioning so that the lst character is always along the
' right edge of the image. Draw shadow first
g.DrawString(strText, fnt, New SolidBrush(Color.Black), newBitmap.Width - StringLength, 65)
g.DrawString(strText, fnt, New SolidBrush(Color.LightSteelBlue), newBitmap.Width - StringLength - 2, 63)
' Get an array of ImageEncoders..array item 1 is Jpeg.
Dim imgCodecs() As ImageCodecInfo = ImageCodecInfo.GetImageEncoders()
' Set quality Parameter for the Jpeg codec
Dim imgParams As EncoderParameters = New EncoderParameters(1)
Dim imgQuality As EncoderParameter = New EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 80)
' Set quality
imgParams.Param(0) = imgQuality
' Render BitMap Stream Back To Client
newBitmap.Save(Response.OutputStream,imgCodecs(1), imgParams)
fnt.Dispose()
g.Dispose()
End Sub
</script>
-
Sep 9th, 2002, 07:45 PM
#8
Thread Starter
Junior Member
ASP.NET and GDI+
Because it seams that is not possible to write in the same page the input and the output.Please help me with 2 aspx pages
First ask.aspx
1.Text box = Your text.
2. DropDownList = My size
3 Radio Button = Shdow : Yes No
3 .DropDownList = My TFF font
4. Button = Submit
Based on imput with GDI+ I will generate a GIF file.
How can I submit this info in the second answer.aspx
1.Label = My Size
2.Label = My Font
3. ?????? to use for display the gif file.
4 Button = Back
and when I am back I want to don't loose the info entered, the file created by the user to don't be destroyed by other user, and when I choose the final submit "This is what you want?" I need to drop all info in a database.
Please try to help me !
-
Sep 26th, 2002, 05:32 PM
#9
yay gay
i was just trying this ...i created a file pic.aspx and put the code there...puted the line of the picture a picture of the same folder of the aspx file...tryed but got an error about path2...*** does that mean?!?
-
Feb 22nd, 2003, 05:21 PM
#10
yay gay
how can i implement this?
........ in what file?
\m/  \m/
-
Feb 22nd, 2003, 05:23 PM
#11
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|