如果这个问题重复出现,请接受我的歉意。我尝试用谷歌搜索,但找不到我正在寻找的答案。
如何将图像(BMP 或 JPEG)转换为其等效的 RTF 字符串值?然后,我会将这个值存储到数据库中,我可以从其中加载该字符串来显示图像。我正在使用第三方控件 (TX Text Control 10.1) 来显示图像。此 Tx Text 控件正在我的一个 VB 6 应用程序中使用。
任何帮助将不胜感激。
提前致谢
Please do accept my appology if this question is a repeated one. I have tried to google but I could not get the answere aI am looking for.
How do I get to convert an imgage (BMP or JPEG) in to its equivalent RTF string value? I will then store this value in to database from where I can load this string to display the image. I am using a third party control (TX Text Control 10.1) to display the image.This Tx Text control is in use in one of my VB 6 applications.
Any help will be much appreciated.
Thanks in advance
发布评论
评论(2)
该文章有点过时,但您应该从以下 RTF 规范部分开始:
http://msdn.microsoft.com/en-us/library/aa140283(v=office.10).aspx#rtfspec_24
它最终会看起来像这样(来自同一个文章):
大多数值,例如图像宽度和高度,可以在 VB6 中检索,但正如文章提到的,您需要使用像 GetDIBits 获取颜色的字节值。如果您不熟悉在 VB6 中使用 Declare 代码,快速谷歌一下可以找到很多示例,例如 这个,和这个,和这个。
The articale is slight dated, but here is the RTF specification section youshould start with:
http://msdn.microsoft.com/en-us/library/aa140283(v=office.10).aspx#rtfspec_24
It will end up looking something like this (from the same article):
Most of the values, such as image width and height, can be retrieved in VB6, but as the article mentions, you'll need to use a function like GetDIBits to get the byte values for the color. And if you are unfamilair with using Declare code in VB6, a quick google on it can find lots of examples like this , and this, and this.
如果您计划加载大量图像,那么我不会推荐这种方法,因为数据库的大小将会膨胀。最好将图像存储在共享文件夹中,然后将图像位置的链接存储在数据库内的文本字段中。
If you plan to load a lot of images then I wouldn't recommend this approach, as the size of your database is going to baloon. You would be much better storing the image in a shared folder and then storing a link to the image's location in a text field within your database.