将文本输出为GIF或PNG,以便在电子书中使用 [英] Output text as GIF or PNG for use in eBook

查看:174
本文介绍了将文本输出为GIF或PNG,以便在电子书中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是创建可通过Blackberry上的Mobipocket阅读器阅读的电子书.问题是我的文本包含Blackberry不支持的UTF-8字符,因此显示为黑框.

My goal is to create an eBook that I can read with the Mobipocket reader on my Blackberry. The problem is that my text includes UTF-8 characters which are not supported on the Blackberry, and therefore display as black boxes.

该电子书将包含英语和旁遮普语单词的列表,以供参考,例如:

The eBook will contain a list of English and Punjabi words for reference, such as:

bait          ਦਾਣਾ
baked       ਭੁੰਨਿਆ
balance     ਵਿਚਾਰ

我曾经想到的是将列表写到HTML表中,然后将旁遮普语转换为GIF或PNG文件.然后将此HTML文件包含在eBook中.当前所有词都存在于访问数据库中,但可以很容易地导出为另一种形式,以输入到生成例程中.

One thought I had was to write the list to an HTML table with the Punjabi converted into a GIF or PNG file. Then include this HTML file in the eBook. All of the words currently exist in an access database, but could easily be exported to another form for input to the generation routines.

问题::使用VB,VBA或C#,编写例程来创建图像,然后在表格中输出包含英语单词和图像的HTML文件会有多么困难

QUESTION: Using VB, VBA or C#, how hard would it be to write a routine create the images and then output an HTML file containing the English words and images in a table

推荐答案

使用VB

Sub createPNG(ByVal pngString As String, ByVal pngName As String)

' Set up Font
Dim pngFont As New Font("Raavi", 14)

' Create a bitmap so we can create the Grapics object 
Dim bm As Bitmap = New Bitmap(1, 1)
Dim gs As Graphics = Graphics.FromImage(bm)

' Measure string.
Dim pngSize As SizeF = gs.MeasureString(pngString, pngFont)

' Resize the bitmap so the width and height of the text 
bm = New Bitmap(Convert.ToInt32(pngSize.Width), Convert.ToInt32(pngSize.Height))

' Render the bitmap 
gs = Graphics.FromImage(bm)
gs.Clear(Color.White)
gs.TextRenderingHint = TextRenderingHint.AntiAlias
gs.DrawString(pngString, pngFont, Brushes.Firebrick, 0, 0)
gs.Flush()


'Saving this as a PNG file
Dim myFileOut As FileStream = New FileStream(pngName + ".png", FileMode.Create)
bm.Save(myFileOut, ImageFormat.Png)
myFileOut.Close()
End Sub

这篇关于将文本输出为GIF或PNG,以便在电子书中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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