cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 5576|回复: 17

中文显示的另一种点阵转换工具

[复制链接]
发表于 2010-8-20 15:10:04 | 显示全部楼层 |阅读模式
(其实是线阵)
用记事本保存在另存为"PicZipper.frm"

  1. VERSION 5.00
  2. Begin VB.Form PicZipper
  3. BorderStyle = 1 'Fixed Single
  4. Caption = "图片压缩"
  5. ClientHeight = 1800
  6. ClientLeft = 45
  7. ClientTop = 390
  8. ClientWidth = 2340
  9. BeginProperty Font
  10. Name = "宋体"
  11. Size = 10.5
  12. Charset = 134
  13. Weight = 400
  14. Underline = 0 'False
  15. Italic = 0 'False
  16. Strikethrough = 0 'False
  17. EndProperty
  18. LinkTopic = "Form1"
  19. MaxButton = 0 'False
  20. MinButton = 0 'False
  21. ScaleHeight = 1800
  22. ScaleWidth = 2340
  23. StartUpPosition = 3 '窗口缺省
  24. Begin VB.PictureBox Picture4
  25. AutoRedraw = -1 'True
  26. DrawWidth = 3
  27. Height = 855
  28. Left = 1440
  29. ScaleHeight = 14.023
  30. ScaleMode = 6 'Millimeter
  31. ScaleWidth = 14.023
  32. TabIndex = 7
  33. Top = 0
  34. Width = 855
  35. End
  36. Begin VB.PictureBox Picture3
  37. AutoRedraw = -1 'True
  38. DrawWidth = 3
  39. Height = 855
  40. Left = 480
  41. ScaleHeight = 14.023
  42. ScaleMode = 6 'Millimeter
  43. ScaleWidth = 14.023
  44. TabIndex = 6
  45. Top = 0
  46. Width = 855
  47. End
  48. Begin VB.CommandButton Command3
  49. Caption = "输入"
  50. BeginProperty Font
  51. Name = "宋体"
  52. Size = 9
  53. Charset = 134
  54. Weight = 400
  55. Underline = 0 'False
  56. Italic = 0 'False
  57. Strikethrough = 0 'False
  58. EndProperty
  59. Height = 255
  60. Left = 1320
  61. TabIndex = 5
  62. Top = 1440
  63. Width = 495
  64. End
  65. Begin VB.TextBox Text1
  66. BeginProperty Font
  67. Name = "宋体"
  68. Size = 9
  69. Charset = 134
  70. Weight = 400
  71. Underline = 0 'False
  72. Italic = 0 'False
  73. Strikethrough = 0 'False
  74. EndProperty
  75. Height = 270
  76. Left = 0
  77. TabIndex = 4
  78. Text = "Text1"
  79. Top = 1440
  80. Width = 1215
  81. End
  82. Begin VB.CommandButton Command2
  83. Caption = "重现"
  84. BeginProperty Font
  85. Name = "宋体"
  86. Size = 9
  87. Charset = 134
  88. Weight = 400
  89. Underline = 0 'False
  90. Italic = 0 'False
  91. Strikethrough = 0 'False
  92. EndProperty
  93. Height = 375
  94. Left = 960
  95. TabIndex = 3
  96. Top = 960
  97. Width = 855
  98. End
  99. Begin VB.CommandButton Command1
  100. Caption = "压缩"
  101. BeginProperty Font
  102. Name = "宋体"
  103. Size = 9
  104. Charset = 134
  105. Weight = 400
  106. Underline = 0 'False
  107. Italic = 0 'False
  108. Strikethrough = 0 'False
  109. EndProperty
  110. Height = 375
  111. Left = 0
  112. TabIndex = 2
  113. Top = 960
  114. Width = 855
  115. End
  116. Begin VB.PictureBox Picture2
  117. AutoRedraw = -1 'True
  118. BeginProperty Font
  119. Name = "宋体"
  120. Size = 9
  121. Charset = 134
  122. Weight = 400
  123. Underline = 0 'False
  124. Italic = 0 'False
  125. Strikethrough = 0 'False
  126. EndProperty
  127. Height = 375
  128. Left = 0
  129. ScaleHeight = 21
  130. ScaleMode = 3 'Pixel
  131. ScaleWidth = 21
  132. TabIndex = 1
  133. Top = 480
  134. Width = 375
  135. End
  136. Begin VB.PictureBox Picture1
  137. AutoRedraw = -1 'True
  138. BeginProperty Font
  139. Name = "宋体"
  140. Size = 9
  141. Charset = 134
  142. Weight = 400
  143. Underline = 0 'False
  144. Italic = 0 'False
  145. Strikethrough = 0 'False
  146. EndProperty
  147. Height = 375
  148. Left = 0
  149. ScaleHeight = 21
  150. ScaleMode = 3 'Pixel
  151. ScaleWidth = 21
  152. TabIndex = 0
  153. Top = 0
  154. Width = 375
  155. End
  156. End
  157. Attribute VB_Name = "PicZipper"
  158. Attribute VB_GlobalNameSpace = False
  159. Attribute VB_Creatable = False
  160. Attribute VB_PredeclaredId = True
  161. Attribute VB_Exposed = False
  162. Option Explicit

  163. Dim F(-10 To 23, -10 To 23) As Boolean
  164. Dim F2(-10 To 23, -10 To 23) As Boolean
  165. Dim a(1 To 1000, 1 To 4) As Integer, LoA As Integer
  166. Dim T(1 To 8, 1 To 2) As Integer

  167. Private Sub Command1_Click()
  168. Dim I As Integer, J As Integer, Tc As Integer, L As Integer
  169. Dim Flag As Boolean, MaxL As Integer, cL As Integer
  170. Dim aI As Integer, aJ As Integer, aT As Integer, aL As Integer
  171. Dim C As Integer

  172. Debug.Print "Begin Character=", Text1
  173. Debug.Print " I", " J", " T", " L"
  174. Command3_Click

  175. For I = 1 To 12
  176. For J = 1 To 12
  177. If Picture1.Point(I - 1, J - 1) = vbBlack Then
  178. F(I, J) = True
  179. Else
  180. F(I, J) = False
  181. End If
  182. F2(I, J) = F(I, J)

  183. If F(I, J) Then Picture3.PSet (I, J)

  184. Next J
  185. Next I

  186. LoA = 0
  187. Do
  188. MaxL = 0
  189. For I = 1 To 12
  190. For J = 1 To 12
  191. For Tc = 1 To 8
  192. cL = 13
  193. Do
  194. L = 0: Flag = True: cL = cL - 1
  195. For C = 0 To cL - 1
  196. If Not F(I + C * T(Tc, 1), J + C * T(Tc, 2)) Then
  197. Flag = False
  198. Exit For
  199. End If
  200. If F2(I + C * T(Tc, 1), J + C * T(Tc, 2)) Then L = L + 1
  201. Next C
  202. Loop Until Flag Or (cL = 1)

  203. If (L > MaxL) And Flag Then
  204. MaxL = L: aI = I: aJ = J: aT = Tc: aL = cL
  205. End If
  206. Next Tc
  207. Next J
  208. Next I

  209. If MaxL > 0 Then
  210. LoA = LoA + 1
  211. a(LoA, 1) = aI
  212. a(LoA, 2) = aJ
  213. a(LoA, 3) = aT
  214. a(LoA, 4) = aL
  215. For C = 0 To aL - 1
  216. F2(aI + C * T(aT, 1), aJ + C * T(aT, 2)) = False
  217. Next C

  218. Debug.Print a(LoA, 1), a(LoA, 2), a(LoA, 3), a(LoA, 4)
  219. End If
  220. Loop Until MaxL = 0

  221. Debug.Print "End LoA=", LoA

  222. End Sub

  223. Private Sub Command2_Click()
  224. Dim I As Integer

  225. Picture2.Cls
  226. Picture4.Cls
  227. For I = 1 To LoA
  228. Picture2.Line (a(I, 1), a(I, 2))-(a(I, 1) + T(a(I, 3), 1) * a(I, 4), a(I, 2) + T(a(I, 3), 2) * a(I, 4))
  229. Picture4.Line (a(I, 1), a(I, 2))-(a(I, 1) + T(a(I, 3), 1) * a(I, 4), a(I, 2) + T(a(I, 3), 2) * a(I, 4))
  230. Next I
  231. End Sub

  232. Private Sub Command3_Click()
  233. Picture1.Cls
  234. Picture1.Print Text1
  235. Picture3.Cls
  236. End Sub

  237. Private Sub Form_Load()
  238. Dim I As Integer, J As Integer

  239. T(1, 1) = -1: T(2, 1) = -1: T(3, 1) = -1
  240. T(1, 2) = -1: T(2, 2) = 0: T(3, 2) = 1
  241. T(4, 1) = 0: T(5, 1) = 0
  242. T(4, 2) = -1: T(5, 2) = 1
  243. T(6, 1) = 1: T(7, 1) = 1: T(8, 1) = 1
  244. T(6, 2) = -1: T(7, 2) = 0: T(8, 2) = 1

  245. For I = -10 To 23
  246. For J = -10 To 23
  247. F(I, J) = False
  248. F2(I, J) = False
  249. Next J
  250. Next I
  251. End Sub
复制代码
 楼主| 发表于 2010-8-20 15:17:06 | 显示全部楼层
这种方法是用贪心算法尽量将画点转化为画线
虽然占用的存储空间多一些且存储每条线的四元数组中有3个都是淡疼的1~12(没法每个数位存一个)

但是,
毕竟,
图形机画一条线比画几个点快嘛!!


casiokingdom上的程序都是画线的!!!
发表于 2010-8-20 15:26:03 | 显示全部楼层
so long!
发表于 2010-8-20 15:44:06 | 显示全部楼层
怎么编成了工程软件?
 楼主| 发表于 2010-8-20 15:52:29 | 显示全部楼层
请某人贴各常用字符表,我来写转换后的List1,大约10000项左右
发表于 2010-8-20 16:14:54 | 显示全部楼层
 楼主| 发表于 2010-8-20 16:36:54 | 显示全部楼层
计算了一下,list中一项要10byte,而用贪污算法(大数加小数减大数得精度)得知一项可存储3条线(精度12^4^3)

于是分30000byte给字模,一共3000项,9000条线。
【平均】一个字顶多9条线,于是可以存储1000字。

而贪污算法得一项可以存储4个{1..1000},于是剩20000byte,2000项,只能存8000字,只有一章。。。
发表于 2010-8-20 19:57:18 | 显示全部楼层
有4000左右的字体库就能拿下大部分文章了
发表于 2010-8-20 21:41:52 | 显示全部楼层
我用的是9750,看你们玩好了(内存太小)
 楼主| 发表于 2010-8-21 13:30:53 | 显示全部楼层
我也是9750

64K字模应该够,但是存长篇小说不够。

有9860的storage memory1.5m就好了

军训好了继续研究。。。
发表于 2010-8-23 12:08:05 | 显示全部楼层
我也是9750

64K字模应该够,但是存长篇小说不够。

有9860的storage memory1.5m就好了

军训好了继续研究。。。
GWHBOB 发表于 2010-8-21 13:30
能否提供exe格式的程序,frm打不开呀若9860在GIA中可读SD就没问题了
发表于 2010-8-23 14:24:59 | 显示全部楼层
ls,没用的,因为程序里不提供数据输出,建议LZ修改
发表于 2010-8-23 14:31:17 | 显示全部楼层
我也是9750

64K字模应该够,但是存长篇小说不够。

有9860的storage memory1.5m就好了

军训好了继续研究。。。
GWHBOB 发表于 2010-8-21 13:30
我也是9750

64K如果全部存入的话,512个字1KB

总共可以存512*64等于
....等于
等于  等于
  等于多少啊
等于32768字
这么少。。
发表于 2010-8-23 14:36:28 | 显示全部楼层
我也是9750

64K字模应该够,但是存长篇小说不够。

有9860的storage memory1.5m就好了

军训好了继续研究。。。
GWHBOB 发表于 2010-8-21 13:30

这怎么算的??
按LZ提供的方法,每一个汉字占用的空间不同,
 楼主| 发表于 2010-8-28 18:10:35 | 显示全部楼层
首先,字模,教9750如何写字的东西,每个字占用的空间不同。
我可以优化使找字模的o(n)=1

然后,文本,9750背下的课文
别指望9750list的存储效率。
实际操作(ranlist#):100行list=1000byte
(别指望虚数,有虚数后100行=2000byte)
而贪污算法得list一行可存储4个大于0,小于1001的数字
假设我们只有1000个字模,则1byte可存0.4个字,而电脑是0.5个,所以在识字量只有1000的情况下(肯定不认识囧炯冏炅),9750和电脑的存储效率大约相同。

下载 佣兵天下.txt(写得满好的),右键单击,属性,大小,5 110 962 bytes ,合5MB。(winrar压缩后2250kb,谁有空和它比算法?!)
 楼主| 发表于 2010-8-28 18:16:20 | 显示全部楼层
这个存储方法肯定要优化滴!!!!!
在不影响时间复杂度的前提下。

比如,线的开始和结束点需要存储共4个坐标(大于0小于12,贪污得一行可存3组)。可否适当安排线的顺序而使它们只用一个与前一个点的相对坐标储存呢?

当然,这样的话,pc端生成字模的时间复杂度会巨幅增加。。。
 楼主| 发表于 2010-8-28 18:19:04 | 显示全部楼层
现在主要问题是:
我也是9750

64K如果全部存入的话,512个字1KB

总共可以存512*64等于
....等于
等于  等于
  等于多少啊
等于32768字
这么少。。

看3万字(很乐观了),连一次电脑,
不如打印出来看算啦!!
发表于 2010-8-28 19:44:47 | 显示全部楼层
如果能有个简单快速的LZ类算法实现,就好办了

另:TI的8X+系列内存比较大,只是类B语言速度慢得太恐怖
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cnCalc计算器论坛

GMT+8, 2024-12-21 22:23 , Processed in 0.111254 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表