如何从图片框读取墨水笔划 [英] How to read ink strokes from picturebox

查看:55
本文介绍了如何从图片框读取墨水笔划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,

我已经将文字"abc"转换为手写体....为此,我从sql数据库中调用了a,b,c的样本,最后使用Ink对象逐一渲染了它们,现在终于可以了在图片框上渲染..意味着我现在有三个笔画...我想对其进行裁剪操作...我有一个Inkoverlay对象,其中包含每个笔画信息(例如笔画数等).现在,当我看到尽管我已经在图片框上渲染了三个笔画,但是呈现的笔画的inkoverlay只显示了一个笔画数,现在我如何才能将所有笔画组合起来并保存在Inkoverlay类中呢……我无法获得每个笔画的边界框.我有如下代码段

hiii all,

I have converted the text say ''abc'' into my handwriting .... for this i have called the samples of a, b,c from my sql database, and finally render them one by one using Ink object , now finally they are render on picture box.. means i have three strokes now... i want to do clipp operation on them ... I have Inkoverlay object which contains the each stroke information (like stroke count etc) Now when i see the properties of inkoverlay of the rendered strokes it shows only one count of stroke although i have rendered three strokes on picture box now how can i combine all the strokes and preserve them in Inkoverlay class ... iam not able to get bounding boxes of each strokes. i have the code snippet as below

Dim mink As New Ink
            mink.Load(mByte)
            boundingBox = mink.Strokes.GetBoundingBox


昏暗的bytearr作为新的arraylist

bytearr.Add(mByte)(''iam一对一地从sqldatabase读取ecah字符的字节数'')


dim bytearr as new arraylist

bytearr.Add(mByte)(''iam reading mbyte from sqldatabase for ecah character one by one '')

byteink.Load(bytearr(0))
       Dim byteink1 As New Ink
       byteink1.Load(bytearr(1))
       'Next
       'byteink.Load(mByte)

       Dim rect1 As Rectangle
       Dim rect2 As Rectangle
       Dim rtf As Rectangle

       ' For Each Stroke In byteink.Strokes
       rect1 = byteink.GetBoundingBox
       rect2 = byteink1.GetBoundingBox
       ' Next
       rtf = New Rectangle(rect1.X + rect1.Width, rect2.Y, rect2.Width - rect1.X - rect1.Width + rect2.X, rect2.Height)
       ' rtf = New Rectangle(rect1.X, rect1.Y, rect2.Left - rect1.X, rect1.Height)
       mink.Clip(rtf)



这里的Mink包含基于兆字节的笔划信息,因此每次mink.strokes计数仅显示为1 ....但是我希望所有笔划信息在之后将它们全部呈现在图片框上


所以请帮我,如何将图片框上所有笔画的信息放入单个Inkoverlay对象中


关于
Zoya



here mink contains the information of stroke on the basis of mbyte so each time mink.strokes count appears as 1 only .... but i want all the strokes information aftr rendering all them on Picture box


so please help me out how can i get the information of all the strokes on picture box into single Inkoverlay object


with regards
Zoya

推荐答案

这毫无意义.类PictureBox保存像素图形,并且墨迹数据表示的矢量图形会丢失.像素(位图)图形不是墨水的合适容器.使用墨水对象本身,保存它.

而且,使用PictureBox甚至对于演示来说都是没有意义的.该控件的唯一价值就是以一种非常简单的方式呈现图像.当用于动态,动画或交互性内容(如水墨图像)时,它没有任何有用的功能;在这种情况下,它只会增加实现的麻烦,并且会浪费资源和性能,而没有任何有用的回报.

这是一个非常常见的错误,在CodeProject上已多次讨论.

我会解释该怎么做;请查看我过去的答案:
如何从旧图纸中清除面板 [ ^ ],
在C#中绘制矩形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [在mdi子表单之间画线 [在面板上捕获图形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [
It makes no sense whatsoever. The class PictureBox holds pixel graphics, and your vector graphics represented by the ink data get lost. Pixel (bitmap) graphics is not a proper container for the ink. Use the ink object itself, preserve it.

Moreover, the use of PictureBox makes no sense even just for presentation. The only value of this control is presenting an image in a very simple way; it presents no useful features when used for something dynamic, animated or interactive (like ink image); in such cases it only adds implementation hassles and eats up resources and performance without any useful return.

This is a very common mistake, discussed many times on CodeProject.

I''ll explain what to do instead; please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^].

For more detail in rendering of graphics, see my other answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].

—SA


这篇关于如何从图片框读取墨水笔划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆