Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am seeking help using a XML file that shows a signature and uses point refrences. I want to convert that XML file to a bmp file. I want to allow the user to enter a file name and location for new file and then create the bmp from the xml. I am very new to C# and need some help badly. Here is a sample of the signature file. Any help would be greatly appreciated. You can contact me at xxxxxxxxx@hotmail.com. Thx.

XML
<?xml version="1.0" encoding="utf-8"?>
<Signature>
    <Customer id="122180" name="GWENDA SMITH" numSegments="3">
        <Segment id="1" points="(14,103) (15,100) (16,97) (16,94) (16,91) (16,89) (16,86) (15,84) (13,86) (14,88) (14,91) (15,94) (18,96) (21,95) (23,95) (26,92) (27,89) (27,87) (26,84) (26,82) (26,86) (27,89) (27,92) (27,94) (27,98) (27,101) (27,103) (27,107) (25,112) (24,114) (21,115) (18,116) (16,116) (13,115) (10,114) (8,112) (4,111) (4,111) "/>
        <Segment id="2" points="(38,97) (37,99) (35,101) (35,103) (34,105) (33,107) (33,111) (31,114) (31,116) (33,116) (35,115) (38,114) (40,111) (43,109) (44,106) (43,109) (45,110) (48,110) (51,109) (54,108) (55,106) (55,103) (54,101) (55,104) (57,106) (59,107) (62,107) (64,106) (66,104) (67,102) (66,99) (63,98) (61,98) (61,101) (59,103) (59,107) (59,109) (59,112) (60,114) (62,116) (65,115) (67,111) (69,108) (71,107) (72,109) (74,111) (77,109) (79,107) (81,110) (83,110) (86,110) (88,109) (90,109) (93,108) (95,106) (93,104) (90,104) (87,105) (85,109) (84,112) (84,114) (87,115) (90,115) (92,115) (94,113) (96,110) (97,108) (99,103) (100,99) (101,96) (102,93) (102,90) (104,92) (104,94) (103,97) (102,100) (101,103) (100,106) (100,108) (99,110) (102,110) (105,109) (106,106) (108,108) (111,107) (113,106) (114,104) (111,103) (108,104) (105,106) (103,108) (101,112) (103,115) (107,115) (110,115) (112,114) (115,111) (116,109) (117,106) (116,109) (115,114) (115,116) (115,116) "/>
        <Segment id="3" points="(153,91) (151,91) (149,90) (146,91) (144,92) (141,93) (138,95) (137,98) (140,99) (142,99) (144,100) (146,100) (149,101) (152,102) (153,105) (153,108) (150,111) (146,113) (135,108) (144,108) (147,108) (150,108) (152,109) (153,107) (155,108) (157,108) (159,108) (161,110) (163,107) (164,105) (166,105) (169,106) (170,108) (170,111) (170,109) (172,109) (174,111) (176,113) (179,113) (180,111) (182,109) (183,106) (184,103) (183,106) (182,109) (182,111) (181,113) (184,114) (187,114) (189,111) (190,109) (191,106) (192,102) (192,97) (192,92) (192,88) (192,84) (193,89) (193,93) (193,98) (192,103) (192,107) (192,111) (192,114) (192,117) (199,106) (200,102) (200,98) (200,95) (201,97) (201,100) (202,104) (202,106) (202,109) (203,112) (203,114) (204,116) (205,113) (204,111) (204,108) (202,104) (200,100) (197,95) (193,91) (188,89) (183,88) (178,90) (173,92) (173,92) "/>
    </Customer>
</Signature>
Posted
Updated 16-Jul-11 17:44pm
v3
Comments
Dr.Walt Fair, PE 16-Jul-11 23:45pm    
Removed email. Please don't post your email address here. People will reply here if they can help.
Dr.Walt Fair, PE 16-Jul-11 23:47pm    
So exactly what problem are you having? However I question the approach of trying to draw the signature with line segments embedded in a string.
mtechniques 17-Jul-11 2:01am    
this is the way the data is being stored in the xml by a vendor. I want to create a bmp file of that signature and be able to add it to crystal reports, etc.
StM0n 17-Jul-11 6:53am    
Are the points connected, like are those lines or just points?
mtechniques 17-Jul-11 14:08pm    
they are lines that form a signature from a signature pad. The segments are started every time the user picks up the stylus up off the pad

You can use System.Drawing to do the following:

First, create an empty bitmap System.Drawing.Bitmap of appropriate size.

Using obtained bitmap instance, create and instance of the class System.Drawing.Graphics. Use its static factory method System.Drawing.Graphics.FromImage, pass your bitmap instance as a parameter. You got an instance of the Graphics object to draw on the bitmap.

Interpret your XML as a sequence of line segments and use segment data to draw on the bitmap canvas obtained on the previous step. Use methods System.Drawing.Graphics.DrawLine and/or System.Drawing.Graphics.DrawLines, etc.

See:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 17-Jul-11 16:40pm    
Sensible approach, my 5
Sergey Alexandrovich Kryukov 17-Jul-11 22:51pm    
Thank you, Espen.
--SA
I think using GraphicsPath[^], but otherwise proceed as outlined by SAKryukov, could be an efficient way to implement your solution.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 17-Jul-11 22:51pm    
That is yet another method I tried to cover by "etc.", via Graphics.DrawPath. My 5.
--SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900