Setup Menus in Admin Panel

Tekst på billede

Følgende kode lader dig sætte tekst på et billede i ASP.net vb. Dette kræver Web-versionen af Visual Studio Express.

Kode

Imports System.Web
Imports System.Web.Services
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Drawing.Text
Imports System.Data.SqlClient


Public Class Pilot
Implements System.Web.IHttpHandler


Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
'Retreive unique CallSign from query string.
Dim stringCallSign As String = context.Request.QueryString("ID")


'Load the Image to be written on.
Dim bitMapImage As Bitmap = New System.Drawing.Bitmap(context.Server.MapPath(stringAircraft))
Dim graphicImage As Graphics = Graphics.FromImage(bitMapImage)


'Set graphics quality to high.
graphicImage.SmoothingMode = SmoothingMode.HighQuality


'Write text.
graphicImage.DrawString(stringName, New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(8, 45))
graphicImage.DrawString(stringRank, New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(8, 57))
graphicImage.DrawString(stringCallSign, New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(395, 45))
graphicImage.DrawString(stringICAO, New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(8, 77))
graphicImage.DrawString(stringPhase, New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(8, 89))
graphicImage.DrawString("Altitude: " & stringAltitude, New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(8, 101))
graphicImage.DrawString("Network: " & stringNetwork, New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(340, 77))
graphicImage.DrawString(stringArrDistance & " nm to go", New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(340, 89))
graphicImage.DrawString("GS: " & stringGroundSpeed & " kts", New Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, New Point(340, 101))


'Set the content type
context.Response.ContentType = "image/Png"


'Save the new image to the response output stream.
bitMapImage.Save(context.Response.OutputStream, ImageFormat.Png)


'Clean house.
graphicImage.Dispose()
bitMapImage.Dispose()

 

http://forums.asp.net/t/1561843.aspx?Text+On+Image+w+VB+NET

http://www.developerfusion.com/article/2569/creating-images-on-the-fly-with-aspnet/

0 responses on "Tekst på billede"

Leave a Message

X