|

Introduction
This article discusses how to create and use a web browser (IE only) compatible ink or drawing control using the Microsoft Tablet PC SDK version 1.7. A sample pre-built control is provided for use and demonstration. Also, please read the disclaimer at the end in case you have any issues with this article.
Background
Having seen Microsoft's Tablet PC ink capabilities in action, I found it sad they didn't provide web or ASP.NET support of their ink libraries. That is until recently — with the release of the Tablet PC SDK version 1.7, Microsoft provides a way to create an ink user control that can be embedded in a webpage and interact with the web server via web scripting, etc.
There are several articles on the web (and a sample in the SDK) that talk about this new feature and how to build such a control. However, I found the documentation/articles to be lacking in some respect due to confusing presentation of how to deploy such an application. Furthermore, no complete source code (other than the sample in the SDK) is provided for evaluation. Only minor snippets are shown in the articles.
Thus, this article skips over the part on creating the control (you can refer to the reference websites below for that information) and instead focuses on:
- the deployment part using a sample demo control project, and
- possible (creative?) uses plus pros and cons for such a control.
The sample control is also pre-built with common drawing and inking features included so that you can use it as is, saving you time from having to write one up from scratch. Or you can also extend the control with additional properties & methods or modify the existing methods.
Reference Websites
Main References
Code Magazine article: Ink on the Web Mobile Ink Jots 3: Ink on the Web Microsoft Tablet PC - Creating a Redistributable Setup
Additional References
Creating Interactive Hand-Written Web Pages on Tablet PC
Code Magazine article: Introduction to Tablet PC Development Code Magazine article: Ink Recognition and Ink Analysis
Ink Control Overview
We'll begin the article from the point after creation of the user control. First, some brief points to mention:
- The control is a .NET windows form control (not an ASP.NET web control) that you can embed onto a webpage and have it run like a Java applet on the client side. Interaction with the server can be achieved through posting back to the server via JavaScript & a web form. You can also alternatively use the control in a windows form application. The control could also be extended to provide methods for communicating with a server by making use of the .NET Web Request & Response classes, or networking classes, etc.
- The control can be implemented with interaction between itself and the external environment by (1) placing code for interaction as components/controls within the control or (2) placing code for interaction as public methods that are a part of the control that can be called from the external environment. In terms of making the control web usable, option two provides better customization and extendability, and better resizing of the control. Thus, the sample control project uses option two.
Using the Control
Requirements
The following is required to run or execute the control on a browser client:
- .NET Framework 1.1 Runtime (or SDK) or greater.
- Internet Explorer (IE) 5.5 or greater
- Javascript enabled in browser (for interactivity features)
- Microsoft Ink Library version 1.7* or Windows XP Tablet PC w/ SP2 installed
- Mouse or other pointing device. A Windows XP Tablet PC system is recommended.
* You can get the Microsoft Ink Library version 1.7 by installing a custom Microsoft Ink version 1.7 library installer or from installing the Microsoft Tablet PC SDK version 1.7. Windows XP Tablet PC with Service Pack 2 also includes the library by default. Sadly, deploying the control over the web does not allow loading the reference libraries along with the control, unlike a windows form application where the Ink library can reside (without installation) in the same directory as the application. For developing & modifying the control, you will need to use the SDK (even if you have Windows XP Tablet PC w/ SP2).
Embedding & Loading the Control
To embed & load the control in a browser, you simply insert a special block of code utilizing the HTML object tag into a webpage. The tag should be similar to the following format (it worked for me, while some examples in the other articles didn't).
<object id="NameForObject" height="aValue" width="aValue"
classid="ControlDLLName.dll#ControlNamespaceName.ControlClassName"></object>
<!---->
With this code, the object will run upon the browser loading the webpage. You can't do much with it at this point, so you can go to the next step.
Interacting with the Control on the Client Side
To provide functionality between the control & the user, you can call the control's built-in methods. This, however, requires writing JavaScript wrapper functions that call the control's methods as in the following example:
function SetPenColor(pColor){
document.forms[0].NameForObject.SetPenColor(pColor);
}
The following code listing shows the available methods in the demo control. Not all are available for use over the web due to security restrictions, unless you add the website as a fully trusted site in Internet Explorer. NOTE: Not all methods were fully tested and some may not behave as you would expect.
public bool AntiAlias
public bool FitToCurve
public bool IgnorePressure
public void SetPenColor(string usrColor)
public void SetBackgroundColor(string usrColor)
public int PenTipStyle
public float PenWidth
public float PenHeight
public int Transparency
private bool SetToInkMode()
private bool SetToSelectMode()
private bool SetToDeleteMode()
public void ClearInk()
public bool CopyAsSerialInk()
public bool CopyAsBitmap()
public bool CutAsSerialInk()
public bool CutAsBitmap()
public bool Paste()
public void Shear(float x, float y)
public void ScaleInk(float x, float y)
public void Rotate(float degrees, int x, int y)
public void MoveInk(float x, float y)
public string InkToTextBestGuess()
public string InkToTextResults()
public string ReturnInkAsBase64Gif()
public byte[] ReturnInkAsGif()
public string ReturnInkAsBase64SerializedInk()
public byte[] ReturnInkAsSerializedInk()
public bool LoadInk(byte[] inkData)
public bool LoadInkFromBase64(string b64InkData)
public bool LoadBackgroundImage(string filePath)
protected void Dispose()
Interacting with the Control on the Server Side
To communicate with the web server, you can make a request to the server, sending the ink data along with it. And you may be able to retrieve information back to the control from the server reply (this part has not been tested nor implemented). A simple way to do so would be to make the control object part of a form and use JavaScript to submit the ink data (stored to a hidden form field) to the server. To pass the data over the web, it needs to be encoded as a Base 64 string since HTML does not handle binary data. Then you can decode and process the data on the server side. Unless you need to work in native Microsoft Ink format, you would generally pass the ink data as a GIF byte array since GIF is a standard image format, easy to process, and still be loaded back into an ink control. The following code snippets show how to send the control's ink data to the server as a GIF byte array.
First, implement the technique to retrieve the control's data and store it in a hidden form field.
<!---->
<input type="button" value="Save as GIF" name="SaveCmd" onclick="SaveAsGif()">
<input type=hidden name="SavedInkData" value="empty">
Then, implement the technique to send the data to the server as a Base 64 encoded string. The demo project includes a simple server processing sample that just decodes & outputs the GIF image to the browser. In practice, you could further manipulate the image, store to a database, write to file, or send somewhere via email.
function SaveAsGif(){
document.forms[0].SavedInkData.value =
document.forms[0].InkBoxCtrl.ReturnInkAsBase64Gif();
document.forms[0].submit();
}
Notes on Deploying the Demo Application and About the Source Files
The demo application was created in the simplest fashion, and is not a standard Visual Studio .NET web application. To deploy the demo, you need only copy it to your web server. No special Visual Studio .NET or IIS virtual directory setup is required. The server side script is available in ASP.NET or PHP, which means you can deploy this application to IIS with ASP.NET (or PHP) or any web server that supports PHP. Only the browser clients need to support the .NET Framework.
For any ASP.NET configuration files and settings that are needed in your case, you may use your existing configuration files or create them yourself by manually creating them or using Visual Studio .NET to generate them.
The source is a Visual Studio .NET 2003 C# control project.
NOTE: The control works fine when used in a web application like the one described here but there may be problems when using it in a Windows Form/Desktop application. I tried dropping the control into a Windows forms project and just compiling it and I got errors (or maybe I didn't add the control to the application correctly). So if you plan to use it in such projects, you may have to tweak the control to get it to work.
IIS Deployment Issues
You may encounter some problems when deploying to IIS, particularly IIS 6 on Windows 2003 Server. Here are some tips on resolving such problems. Try them in the specified order:
- Verify in IIS, that your application has "Script only" execute permissions under your Virtual Directory, Home Directory, or Directory settings. If you have it set to "Scripts and Executables" you will not be able to download the web ink control DLL. If you must use "Scripts and Executables" because you are using CGI, you may need to rethink how you plan to deploy this application. This method solved my IIS problem. Click here for more info.
- Verify that you are not using URLSCAN (from Microsoft) or something similar on IIS. If you are using such a tool, you must configure it to allow downloads of DLL files. Click here for Using URLScan on IIS.
- Try lowering your IIS server security settings, if necessary. Probably not a good idea though, and I don't think you will really need to do this.
- When all else fails & you really like using this control & you are not required to use IIS/ASP/ASP.NET, consider hosting the application on a non-IIS web server like Apache.
Apache Deployment Issues
Alessandro Torrisi pointed out a potential issue on Apache (whether running server on Windows or Linux, to be safe) where the ink control DLL was not loaded into the application. According to Alessandro, to fix this, just add "application/x-msdownload dll" in the "/etc/apache2/mime.types" file and restart apache.
Points of Interest
Summary of Pros & Cons
I think such a control has potential in some applications. The negative aspects are that the control runs in a Microsoft client environment only, it requires downloading & installing the Microsoft Ink library, and text recognition is available only for Tablet PCs. These aspects might deter people from using & deploying the control. However, there are some positive aspects of this control too, particularly in the possible uses that the control can provide as well as the option of using any server side platform (it need not be Microsoft). In summary, while the control may not be feasible for general public & corporate use, it may prove useful in certain specialized applications. Plus it's a fun thing to toy around with in your spare time.
Possible (Creative?) Use Cases
- Inking or drawing on the web, as an alternative to using a Java applet or Macromedia Shockwave/Flash implementation. A good example of a Shockwave version can be seen at Tutor.com's Live Homework Help information site. I used to be a Tutor.com tutor and they do have a very nifty web whiteboard interface.
- Provide ink & drawing support (via the control on the client side) to ASP.NET applications or web services running on the Mono open source .NET platform (and Microsoft .NET too).
- Provide drawing capabilities to non-Microsoft and legacy web server platforms:
- Java, J2EE, EJB, servlets, JSP
- PHP (sample provided in demo project), Perl, Python, Ruby
- Classic ASP, ColdFusion
- Standard HTML/DHTML web pages only, Microsoft HTA applications
- Interact/integrate with Macromedia Shockwave/Flash plugin or Java applet for more capabilities?
- Provide ink recognition processing on the server side using the control on web browser clients & a Tablet PC as the web or application server (even better if the clients were running on Tablet PC too of course).
- Use the control as inkable form fields:
- Each instance of the control replaces a textbox in a form & on submit, the server processes the ink data along with the other form data.
- Or use the control like a Tablet PC Input Panel & on click, the ink is converted to text & can then be copied & pasted to the appropriate fields. NOTE: this option is only available on Tablet PC systems.
- Support digital signatures over the web (as GIF image or MS Ink format). Though this might present some legality, security, & privacy issues.
- Implementing a non-realtime digital whiteboard for conferencing--after drawing on the board, a user submits the data to the server for intermediate storage. Then either periodically/automatically by the application or manually performed by receiving users, the users can get an updated snapshot of the shared board (or the submitted user's board) loaded into their boards from the server. This is just my thoughts & hasn't been tested. It may be tricky to implement, if possible at all. But if it is possible, this is a neat thing to do.
- Use this control along with AJAX to make nifty dynamic web applications?
- Customized ink applications using the control
- Extend control to return ink in bitmap, JPEG, and other formats
- Finally, can you provide other ideas?
Updated Features and Information - as of Oct. 27, 2007
- Added new methods to the ink control to load ink from base 64 encoded data and to load a background image (primarily for Windows forms applications only).
- Added client side code for backup & restore of ink functionality. Backup feature only backs up current ink and overwrites previous backup. Backup uses the same hidden form field
SavedInkData, so when you "Save" or send ink to server, current backup gets overwritten as well. You can modify it so that backup uses a different form field instead, etc. Restore simply loads ink from the current backup. NOTE: You may have to click "Restore" twice to get it to load the backup, that's what happens on my system for some reason.
- For debugging purposes, I added a textbox with the same name as hidden form field "
SavedInkData" so that you can see and modify the base 64 encoded version of ink data. By default, this new field is commented out. You can switch to this one instead of the hidden form field for debugging.
- I added a new web server script that takes a supplied image URL, downloads it (to the server), converts it to Base 64 text, and returns that to the browser/web client for use by the web ink control. Unfortunately, this new script is currently available for ASP.NET only, no PHP.
- I added a new client side feature of using
XmlHttpRequest to pass a URL of an image to the server and get back its Base 64 encoded version so that you can load it into the web ink control. Unfortunately, I couldn't get it to load in the ink control. In any case, this is a good sample of how you can use XmlHttpRequest to fetch data from server to load into your ink control, etc. I tried to use fetch from image URL, but you can fetch from database or file on server, etc. Also to note, I made use of my custom XmlHttpRequest library for this (but you can use XmlHttpRequest natively, for those of you who are proficient enough with it). See my other Code Project article titled "Web/HTTP Automation Libraries" for more information.
- See also my comment/forum post to this article for additional updates on web ink, web ink recognition, and IE and Firefox support.
Bugs
- Scrolling causes problems with accessing form elements & selecting text, etc. This might be a browser or .NET rendering problem. Therefore, if you use a lot of form controls or have a lot of content below or above the control, etc., it is recommended that the webpage be viewed in full screen browser mode OR in portrait orientation (for Tablet PCs only) to minimize scrolling. Otherwise, consider having less controls or content on the page.
- Not all implemented control methods are supported when running the control over the web & some don't necessarily work as intended, so be aware of that.
- Restore feature may require you to click twice to load ink from backup.
- Load Ink from URL feature currently not working with ink control. Kept in demo project as an example of how to attempt this.
Release History
- 06/27/2006 - Initial Release. Some future enhancements may include additional output formats & built-in web request/response methods for input/output of data between control and a server.
- 07/04/2006 - Updated article & download files to clarify some things.
- 11/11/2006 - Updated article with information on deployment issues with IIS.
- 10/27/2007 - Updated article and code for issues and new features.
Disclaimer
NOTE: This article and accompanying code are not entirely original. Rather, this article is intended to clarify and elaborate on the subject where the original articles seem to be lacking in detail. Additionally, source code (a compilation of code snippets from the original articles integrated together with my own code and extra functionality) and a demo application are provided for you to use freely. The original articles only provided code snippets, no complete code that you could use off the bat. Last, this article is intended to suggest and foster creative use of such an ink control beyond the standard Microsoft convention/platform.
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 73 (Total in Forum: 73) (Refresh) | FirstPrevNext |
|
|
 |
|
|
Hi. I'm trying to add functionality to the dll. I added my new function ( a copy of LoadBackgroundImage, called LoadBackgroundImage2), recompiled, and added the new dll to my webproject both as a reference in the main directory. I checked the Object Browser and the function (LoadBackgroundImage2) appears. I call LoadBackgroundImage (a function included in the original dll) from a javascript function, and it works perfectly. I call LoadBackgroundImage2 (the new function I created) and I get a javascript error "Object Expected".
What could the problem be? The reference is correct, the object browser sees the function, the dll is included (in addition to a standard reference) in the main directory of the project, but the javascript cannot access the server function. Is there something else I have to do to make the function accessible to the javascript?
Thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
It would be helpful if you provided some source code snippets of the function in question. Like how the function is implemented and how it is called from javascript.
"Object expected" would probably indicate incorrect referencing of the function or ink control, or invalid function arguments supplied.
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
i do NOT understand this - but as i was preparing the code samples to give you, the thing started working. i did NOT change anything else - maybe i didn't save it properly previously? who knows. anyway, i'm glad it worked now, thanks for your response!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
what's the lowest .net framework that I Microsoft.Ink is available in? Can I make changes to the dll using .Net framework 2.0?
Thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
This article's ink control based on MS Ink requires MS Ink library v1.7 installed.
I don't believe it is dependent on a particular .NET version though I haven't tested for that specifically. As long as the existing non-MS-Ink class(es) (methods and properties) used in the ink control didn't change between .NET 1.0/1.1 and .NET 2.0 (or .NET 3.0), then the control should work for any of those versions and you can edit it from any of those versions as well.
But you may need a version of Visual Studio .NET to edit the control as open source IDEs like SharpDevelop likely don't have the MS Ink integration with the IDE for you to effectively work on the project.
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
daluu,
Sorry to ask you a quesion about web ink architecture. I am looking for IE plug-in articles and try to figure out how to write FlashPlayer like IE plug-in. But I could not find any such article here.
Do you know if web ink a simply ActiveX control? I am trying to figure our what it takes to write such plug-in.
Really appreciate it. If you like to write me directly, my address: hlai@yahoo.com
henry
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Sorry, but unfortunately, I do no know how. The web ink control of this article makes use of IE's ActiveX capability and the .NET framework runtime to (down)load a .NET DLL as if it was like a Java applet. The whole process works like running a Java applet in IE through ActiveX. There is no special design to developing it, other than putting in HTML object tags to embed the DLL/applet into the webpage for (down)loading to the IE client.
What you wish to do is likely be more complex. Too bad Adobe and/or the open source community, doesn't have such a working sample for the public. Maybe you might find some articles here at CodeProject that might lead the way. Good luck on your endeavor.
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
I see that my article has received quite a few page views and quite a few visitors have made use of the ink control and provided feedback, code for new features, info on how to get the control to work in certain environments, etc.
So I was just wondering out of curiosity, for those of you who made or are making use of the control or are investigating it for possible use, how are you using or how do you plan to use the control in your application?
I would love to get your feedback.
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hello fellow developers, I am having a problem and I was hoping that someone could help me out...
I have a simple web application to draw onto an image of a truck. I have a list of items and when I click on one of them a new aspx page opens where among other things this embedded user control appears. The ink is stored in database and it all works well!
However sometimes the ink loading fails. The reason is that InkCtrl_Load() is not called every time the page is launched. This means that when LoadInkFromBase64() is called the inkOverlay object is null (since it is normally instantiated in the InkCtrl_Load()-function).
I open the page once and the ink is loaded as expected. I close it page and reopens it and then the inkOverlay object is null and the ink is not loaded correctly. If I keep doing that sometimes it works and soimetimes it fails although it fails more often.
Current workaround involves automatically reloading the entire page if the inkOverlay object is null. I included the java script method for that below. The script works but sometimes many many reloads are needed...
so the questions are
- Do you know when the InkCtrl_Load() is being called by CLR? - Does you have any idea why the InkCtrl_Load() is not called each time the page is loaded? Perhaps I do not dispose of the object properly (I call Dispose on the inkCtl when leaving the page). -Do you have any ideas?
I have tried many solutions but all of them fails :
1. Reinitate the InkOverlay in LoadInkFromBase64() if it is null --> NOK.
2. Initiate the InkOverlay in the usercontrol constructor (which is being called each time the page is loaded) --> NOK
I have the same errors on a Tablet PC
------------------------------------------- SCRIPT THAT RELOADS IF INK CANNOT BE LOADED ------------------------------------------- LoadInkFromBase64() returns true if all went well
function LoadInkFromHiddenField() { var ret;
var ink = document.forms[0]." + this.ClientID + "_HiddenFieldOrInk.value;";
if ( ink != null && ink.length > 0 ) { ret = document.forms[0].InkBoxCtrl.LoadInkFromBase64(document.forms[0]." + this.ClientID + "_HiddenFieldOrInk.value);"; if (ret != 'true') "; { document.forms[0].InkBoxCtrl.Dispose(); window.location.reload(); } } }
Thanks in advance for your help!
Henrik
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi again,
I solved it 
The java script method LoadInkFromHiddenField() has to be called after the entire page has been loaded i.e in the load event of the page (<body onload="LoadInkFromHiddenField()"...). Now the load event of the inkctrl has always been called when I load the ink.
Have a good one!
Henrik
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Just an FYI - DimDim has an open source edition that also runs on Windows that should provide whiteboard sharing for web meetings and conferencing.
It isn't a Microsoft .NET/ink solution but you can modify the source code to fit your needs.
http://dimdim.com/[^]
http://sourceforge.net/projects/dimdim/[^]
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi Daluu, there is a long time,I hope you are fine. I want to say you that I found the solution for the backgroundImage on the inkbox control, but I got a little problem,when I print a web page which contains an inkbox control, the ink is not print,we see only the backgroundImage. I make search and I find that we have to put this code: private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //inkbox is an InkOverLay control //inkBox.Renderer.Draw(e.Graphics, inkBox.Ink.Strokes); }
if I put this code in my dll inkAreaCtrl.dll like that:
private void PagePrint(object sender, System.Drawing.Printing.PrintPageEventArgs e) { // No antialiasing: use simple Renderer.Draw method // Print the label with the A // You need to adust for printer margins and margin in label int labelMarginX = 5; // pixels int labelMarginY = 3; // pixels PointF labelLocation = new PointF(labelA.Left + labelMarginX + e.MarginBounds.Left, labelA.Top + labelMarginY + e.MarginBounds.Top); e.Graphics.DrawString(labelA.Text, labelA.Font, new SolidBrush(Color.Black), labelLocation);
System.Drawing.Bitmap Img = ((System.Drawing.Bitmap)(this.BackgroundImage)); Rectangle rec = new Rectangle(0, 0, 400, 400); e.Graphics.DrawImage(Img, 0, 0, Img.Width, Img.Height); // Print the ink // First translate it so that it's within the print margins // Create a new transformation matrix System.Drawing.Drawing2D.Matrix transformation = new System.Drawing.Drawing2D.Matrix();
// Create an offset based on the margins. // IMPORTANT: Default printer units are 1/100 of an inch, so divide by 100 and // multiply by Dpi to get // true pixel dimensions. //System.Drawing.Point offset = // new System.Drawing.Point((int)(e.MarginBounds.Left * e.Graphics.DpiX / 100), // (int)(e.MarginBounds.Top * e.Graphics.DpiY / 100)); System.Drawing.Point offset = new System.Drawing.Point(0, 0); // Convert to ink coordinates inkBox.Renderer.PixelToInkSpace(e.Graphics, ref offset);
// Apply the translation to the transformation transformation.Translate(offset.X, offset.Y);
// Apply the transformation to the Renderer inkBox.Renderer.SetObjectTransform(transformation);
// Draw strokes to the printer graphics inkBox.Renderer.Draw(e.Graphics, inkBox.Ink.Strokes);
// Undo overlay's transformation inkBox.Renderer.SetObjectTransform(new System.Drawing.Drawing2D.Matrix());
}
public void imprimer() { printDocument.PrintPage += new PrintPageEventHandler(this.PagePrint); // print the page printDocument.Print(); }
when I call the function imprimer(), only the inkbox is printed with the ink,and the web page is not printed, how can I do to print ink in my my web page?
do you know a solution where I can create an image with ink and a backgroundImage?
thanks to help me
best regards, YOUNESS
modified on Tuesday, April 8, 2008 4:39 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
You can add the background image directly to the user control(in the resource file of the InkAreaCtrl). Of course t will always appear for all instances. For me that was ok since I only had one...
I solved the problem of printing by adding a property to the user control that extracts the background image + the ink as a jpeg. I then replaced the user control on the page with the generated jpeg image. All this is of course transparent to the user.
The code to generate the gif+ink is: (Im sure there r many ways to this)
public System.String ReturnImageAndInkAsSerializedBase64() { System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Mist work on clone since otherwise the ink becomes part of the background System.Drawing.Image copyOfBgImage = (System.Drawing.Image) this.BackgroundImage.Clone();
System.Drawing.Graphics g1 = System.Drawing.Graphics.FromImage(copyOfBgImage); Renderer r = new Renderer();
if (inkBox.Ink.Strokes.Count != 0) { r.Draw(g1, inkBox.Ink.Strokes); } copyOfBgImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] bitmapData = ms.ToArray();
copyOfBgImage.Dispose(); g1.Dispose();
return Convert.ToBase64String(bitmapData); }
Cheers
Henrik
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks for sharing the code, henkedude. This will be very useful to the community.
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi Daluu,
first, thanks for your answer about my last question. I try to use the function "SetToDeleteMode()" but it doesn't work, I got a trouble like that : This object does not manage this property or method do you have an idea to resolve it?
otherwise,is it possible to have a color cursor different to the color of the pen: that is to say I want to have a black cursor and the pen color is blank,it's possible?
Thanks,
Youness
modified on Friday, February 8, 2008 5:39 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
| |