Let ASP.NET output graphics

zhaozj2021-02-16  53

<% @ Page language = "vb" debug = "true"%> <% @ import namespace = "system.drawing"%> <% @ import namespace = "system.drawing.imaging"%> <% @ import namespace = "system.drawing.drawing2d"%> <'' '' '' '' '' '' '' '' '' '' '' '' '' Lets ASP.NET Output Graphics. 'Ouyang East Oydj) Original. 'QQ: 2596812' e-mail: loved@vip.sina.com 'msn: xzskyweb@hotmail.com' Welcome everyone to contact me "'' '' '' '' ' '' '' '' '' '' '' '

DIM STRFILENAME AS STRING 'Declaration Variables, used for Image Path Dim i as system.drawing.image' Creating a .NET Frame Image Image Processing Object instance DIM IMGG1 AS INTEGER = CINT (INT (6 * RND ()) 1)) Generate 1-6 random number DIM oydj as string = IMGG1

StrfileName = "D: / O123 /" OYDJ "jpg" loaded image path, here Oydj represents randomly generated variables for generating random pictures i = system.drawing.Image.FromFile (STRFILENAME) DIM B As new system.drawing.bitmap (i.width, i.Height, Pixelformat.Format24bpprgb) Dimg AS graphics = graphics.fromimage (b) g.clear (color.blue) 'background color is blue

DIM SSS = Request.serverVariables ("remote_addr") G.drawImage (i, new point (0)) 'Here, the generation of characters, 9th Song Groid white, Pointf (160, 50) is on the screen coordinates G. DrawString (SSS, New Font ("Song", 9, FontStyle.Bold, New Solidbrush (Color.White), New Pointf (160, 50)) G.drawstring (SSS, New Font ("Song Body", 9 FontStyle.Bold, New Solidbrush (Color.White), New Pointf (161, 51))

Response.ContentType = "image / jpeg" 'specified output format is graphic B.Save (response.outputstream, imageformat.jpeg) B.dispose ()%>

Code demo

转载请注明原文地址:https://www.9cbs.com/read-23953.html

New Post(0)