[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3312
  • Last Modified:

Draw Signature Image using Javascript

hi, i use a PDA to view my personal website .
i want to let other people able to sign their signature in a given screen ...
the signature should be visible on screen ...
how can i do that by javascript?

if not javascript, any other method can recommend ?

thanks
0
chongkeng_woon
Asked:
chongkeng_woon
  • 2
  • 2
2 Solutions
 
viola123Commented:
hi,

this feature is impossible to be implemented using javascript, as it is only a client script language.

however, you can easily achieve this using .net (eg. c# or vb.net). roughly the code should be:

            private static Bitmap CreateImage( string sImageText )
            {
                  Bitmap bmpImage = new Bitmap( 1, 1 );

                  int iWidth = 0;
                  int iHeight = 0;

                  //Create a Font object
                  Font MyFont = new Font( "Verdana", 24, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point );

                  // Create a Graphics Class to measure the text width      
                  Graphics MyGraphics = Graphics.FromImage( bmpImage );

                  // Resize the bitmap, this is where the bitmap is sized.
                  iWidth = (int)MyGraphics.MeasureString( sImageText, MyFont ).Width;
                  iHeight = (int)MyGraphics.MeasureString( sImageText, MyFont ).Height;

                  // Create the bmpImage again with the correct size for the text and font.
                  bmpImage = new Bitmap( bmpImage, new Size( iWidth, iHeight ) );

                  // Apply the colors and draw the bitmap.
                  MyGraphics = Graphics.FromImage( bmpImage );
                  MyGraphics.Clear( Color.Navy );
                  MyGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                  MyGraphics.DrawString( sImageText, MyFont, new SolidBrush( Color.Red ), 0, 0 );
                  MyGraphics.Flush();

                  return( bmpImage );
            }
0
 
chongkeng_woonAuthor Commented:
i know only little about Microsoft .NET technology ....i developed software basically using Delphi ..by the way, you are right, it is impossible for  javascript do that ...however, i know that Java Applet can do that ...

how can .NET technology can do this on web? i just wonder where can i get any example from the web ? or even explaination ?

by the way, since i am viewing this website at PDA ...is the application developed by .NET compatible to all the PDA operating system ?

sorry for asking so many questions , i am still new to that .....

thanks
0
 
viola123Commented:
check this example, this is how to use .net to implement a PDA application

http://www.codeproject.com/netcf/PPCSignatureApp.asp
0
 
chongkeng_woonAuthor Commented:
finally, i did it by using javascript ...i change the
<td> bgcolor to black color in "onMouseMove" event ....it works fine in IE 6 ...

<td width=3px height=3px OnMouseOver="changecolor()">&nbsp;</td>

however, when i view it in PDA (running under Window CE) ....it doesn't work ..
the stylus seems like does not recognize the "OnMouseMove" event handler ..
it does not change the <td> bgcolor to "black"

what should be the event handler for stylus in order to do the "OnMouseMove" event?

thanks again



0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now