|
-
Oct 10th, 2002, 01:24 AM
#1
Thread Starter
Hyperactive Member
Attach text to Image Via Java script
hey, i am a real newbie to Web design, i was wondering if it is possible to attach text to image via Java script, if it is possible, where can i find some examples?
regaurds
-
Oct 10th, 2002, 01:59 AM
#2
If you mean superimposing text upon an image, such that they become one image, using javascript, the answer is no.
-
Oct 10th, 2002, 08:26 AM
#3
Thread Starter
Hyperactive Member
ok.... what are the possible solutions for this... even without Java script...
-
Oct 10th, 2002, 09:02 AM
#4
Hyperactive Member
If you just want text over the image, you could do it with a layer that you place over the image that contains your text.
/Smirre
Visual Basic
C, C++
Java
Access
SQL Server
MCP, MCSD
-
Oct 10th, 2002, 12:12 PM
#5
Thread Starter
Hyperactive Member
well.... i want it to convert into a image file.. for example... i write sometin in a text box,and . and that text shud be in my theimage.gif file...
-
Oct 10th, 2002, 12:16 PM
#6
this may not be useful, but here is how to do it with asp .net
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>
-
Oct 11th, 2002, 12:34 PM
#7
Thread Starter
Hyperactive Member
thanks man... i dont know.. if i cna use it... wud this thing work with free site that support ASP?
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
|