Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: convert image Formula
I want to convert a string of formula (such as a/b+c* sqrt d)to an image
Like what the following webpage does.
 
http://www.wolframalpha.com/input/?i=3%2F2%2B%285*%286%2F%284%2F%283%2F%282%2F1%29%29%29%29%29%2F4[^]
 
somebody provide an example or sth? thanks
 

(Is this a clear description?why no replys???)
Posted 12-Aug-12 4:15am
Edited 12-Aug-12 4:53am
v2
Comments
Wes Aday at 12-Aug-12 9:21am
   
So create a bitmap and draw the text on it. What are you having trouble with?
ChineseGuy at 12-Aug-12 9:58am
   
there are many factors to consider which makes me confused about draw from where
And the size of the number,sqrt,Fractional line depends how many numbers or something else are included................

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Converting anything in this way requires a little thinking in advance. You need to analyse the information you are converting and figure out how high and wide it might be. For example, showing a division operation such as:
    23
a = --
    10
requires first, two 'lines', each of which needs to be high enough to contain characters in the selected font. Secondly a 'line' high enough to contain a separator. The start of the expression "a = " should be positioned centred on the dividing line. The actual calculations would be based on the size of the image you wish to display and the size of the font being used for the characters, so assuming a font 10 px high by 8 px wide we would have something like:
moveto(32, 0) // position X, Y
write("23")
moveto(0, 6)
write("a = ")
moveto(32, 12)
lineto(48, 12)
moveto(32, 14)
write("10")
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 12 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100