Inverse inversion of emotic image and expression code in RTF

xiaoxiao2021-03-06  20

In the forum, the post is put on how to transform the inserted picture into a custom expression code in the RTF.

And reversible.

http://community.9cbs.net/expert/topic/3874/3874035.xml?temp=.2201197

First of all, I am very grateful to those who make suggestions and thank you for your friends. Since time is more urgent, the problem is solved. Now share with you.

I remember that inserting a picture in RichtextBox has a number of methods, only two ways in RichtextBox, one is inserted directly in the RichtextBox in the RichtextBox, and the two are embedded in OLECT. We discuss the previous kind, because the code is more, I directly provide the code project to everyone. This kind of thinking only about some solutions

RTF does not have a flag to identify the picture (there is still not found J), so put the picture into an expression code, can only locate the picture according to the characterization of the picture, but 71 pictures to find the character code is too much trouble. So first find the minimum signature of 71 pictures. For simplicity, we choose the picture to generate hexadecimal, select the first n byte, this N can represent 71 different pictures. Method is to compare one by one (available for selection Law) r Learn this N. Then we generate sequential files smile.bin, contain full pictures, picture signatures, and emotic code representative of each picture.

Positive conversion: When the message containing an expression picture, this RTF is very large because of the picture, this RTF is very large. We need to transfer the code of the picture to a custom expression code, such as "^ - ^" - ^ " :) ".

In RTF, the picture starts with Pict We can remove this part of the code and insert our custom expression code. Method is to find the top 500 bytes of PICT (500 is n, I am here) and smile.bin The picture signature is compared, the same picture is a bit different from the picture code that is different (I don't know if richtextbox is ghost), so a fuzzy factor, this factor is 28, different pictures may not be the same. After matching, you can find the expression code.

Reverse conversion: is to transform the expression code into an image, this conversion is simpler, as long as we find the corresponding image file in the RTF according to Smile.bin, but there is a problem, you can't be directly The RICHTextBox is displayed into the RTF code before the emotic code, because this is incomplete, it will lead an exception, which must be complete, so that the process of transformation must be responsible for the conversion of the picture to a RichTextBox.

In fact, if the RTF directly we customs label, then don't have to be troublesome. But after the RichtextBox is assigned, it will remove these it thinks useless tags (bitter)

If you have a better way, please tell me.

The effect is as follows:

转载请注明原文地址:https://www.9cbs.com/read-42807.html

New Post(0)