0 Replies - 1426 Views - Last Post: 14 August 2013 - 05:38 AM Rate Topic: -----

#1 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

Importing an image inside an ASP.NET dynamically created image

Posted 14 August 2013 - 05:38 AM

Okay so I am trying to create a portrait section for a game I am working on. The portrait section will be dynamic (because it will display the character's level) and will include 3 images:

  • the portrait (determined by values passed to the ASP.NET file)
  • the frame (not determined by values passed to the ASP.NET file)
  • the level number & level icon (determined by values passed to the ASP.NET file)


I was following a tutorial to learn how to generate images in ASP.NET on the fly, however, I can't seem to figure out how to import an image from another file and add it to the image I am creating. Below is the code I have so far:

<%@ Page ContentType = "image/gif"%>
<%@ Import Namespace = "System.Drawing" %>
<%@ Import Namespace = "System.Drawing.Imaging" %>

<script Runat = "Server">

Sub Page_Load

    'Create the image
    Dim objBitmap As Bitmap
    Dim objGraphics As Graphics

    objBitmap = New Bitmap(120, 120)

    objGraphics = Graphics.FromImage(objBitmap)

    'Add the graphics
    objGraphics.DrawLine(new Pen(Color.Red), 0, 0, 120, 120)

    'Save it
    objBitmap.Save(Response.OutputStream, ImageFormat.Gif)

    objBitmap.Dispose()
    objGraphics.Dispose()

End Sub

</Script>


TIA :)

Is This A Good Question/Topic? 0
  • +

Page 1 of 1