Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create image with text wrapped to pre-defined area

Posted on 2008-11-03
1
Medium Priority
?
267 Views
Last Modified: 2011-09-20
I am very stuck with something I am trying to build where users load a JPG file from a template library, enter some text, select a font and font size and alignment and then they click submit. A new image is created with the user's text inserted in the correct font, size and position.

What I would like to do is to be able to wrap the form inputted text to a rectangular shape which has it's dimensions sourced from the database record relating to the template. The information I am thinking of storing is TOP co-ord, LEFT co-ord, Width and Height. This would create a rectangular shape for the text to be wrapped in.

I have a similar example of what I would like to do using Windows Forms (http://www.java2s.com/Code/CSharp/2D-Graphics/Textwrapverticalhorizontalandtrim.htm) but I do not know how to do it using asp.Net for a website or whether I can use the same methods.

I would be very grateful if anyone can help me get the correct code for what  I want to do. :)
MY CURRENT CODING
-----------------
Dim bitMapImage As Bitmap = New Bitmap(Server.MapPath("/imgs/templates/MothersDay.jpg"))
        Dim graphicImage As Graphics = Graphics.FromImage(bitMapImage)
        graphicImage.SmoothingMode = SmoothingMode.AntiAlias
        Dim oColor As System.Drawing.Color
        Dim sColor As String = Request("BackgroundColor")
        Dim sText As String = Request("Text")
        Dim sFont As String = Request("Font")
 
        Select sColor
            Case "red"
                oColor = Color.Red
            Case "green"
                oColor = Color.Green
            Case "navy"
                oColor = Color.Navy
            Case "orange"
                oColor = Color.Orange
            Case Else
                oColor = Color.Black
        End Select
 
 
        graphicImage.DrawString("Example Text Example Text Example Text", New Font("Arial", 20, FontStyle.Bold), SystemBrushes.WindowText, New Point(100, 250))
        bitMapImage.Save(Server.MapPath("/imgs/users/generated_image.jpg"), ImageFormat.Jpeg)

Open in new window

0
Comment
Question by:clearchannel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
clearchannel earned 0 total points
ID: 22869008
Solved this myself using similar properties to the window forms code


Dim font As New Font("Verdana", 20)
Dim rect As New Rectangle(10, 10, 200, 200)
graphicImage.DrawString(text, font, Brushes.Red, rect)

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question