Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1380 lines
34 KiB

  1. //
  2. // Copyright (c) 1997-1999 Microsoft Corporation.
  3. //
  4. #include "stdafx.h"
  5. #include "vdata.h"
  6. #include "extfunc.h"
  7. #include "ttfstruc.h"
  8. /* Smooth sort */
  9. #define SMOOTH 0x8000
  10. #define NOSMOOTH 0x4000
  11. #define BACKWARD 0x2000 /* NOSMOOTH is forward vector */
  12. #define FOREWARD 0x1000 /* NOSMOOTH is backward vector*/
  13. /* Curve Type */
  14. #define SPLINE_ATR 0x0001
  15. /* Smoothing anchor Point */
  16. #define SMOOTHANCHOR 0x0080
  17. /* Smoothing anchor point is based 90degree Rule */
  18. /* for turning */
  19. #define TURN_OU 1 /* �� */
  20. #define TURN_TOTSU 2 /* �� */
  21. #define sign(n) (n < 0 ? 1 : 0)
  22. #define LONGMIN 5
  23. int SmoothVector(int lstHdl,int tmpLst,int xinMesh,int yinMesh, int outMesh,struct SMOOTHPRM *prm,int fp);
  24. static int BindVector(int inLst,int outLst);
  25. static int BindPoint(int inLst,int outLst);
  26. static int DetectNoSmooth(int lsthdl);
  27. static void turnsort(struct VDATA *vp);
  28. static void generalsmooth(struct VDATA *vp);
  29. static int isturn(struct VDATA *vp);
  30. static int islong(struct VDATA *vp);
  31. static void longline(struct VDATA *vp);
  32. static int ZoomPoint(int lstHdl,int xinMesh,int yinMesh, int outMesh,int uFp);
  33. static int preproc1(int inLst,int outLst);
  34. static int diveachside(struct VDATA *vp,int outLst);
  35. static int divoneside(struct VDATA *vp,int outLst);
  36. static int divVec( int ilst, int olst, int divN);
  37. static int Smooth1(int inLst,int outLst,int weight1,int weight2,int weight3);
  38. static int Smooth2(int inLst,int outLst);
  39. int searchanchor(int sn,struct VDATA *sp,struct VDATA * *ep,int lim);
  40. static int smooth1sub(struct VDATA *vp,int np,int outLst,int w1,int w2,int w3);
  41. static int smooth2sub(struct VDATA *vp,int np,int outLst);
  42. int RemoveFp(int lstHdl,int outMesh,int uFp);
  43. static int BindLinears(int inLst,int outLst);
  44. static int DelZeroVec(int inLst,int outLst);
  45. int toTTFFrame(int lstH,struct BBX *bbx);
  46. static int lightSub(int inLst,int outLst);
  47. int SmoothLight(int ioLst,int tmpLst,int width,int height, int oWidth,int ufpVal);
  48. int ConvMesh(int lstH,int inMesh,int outMesh);
  49. static int
  50. straightCurve( int iLst, int oLst)
  51. {
  52. struct VHEAD *vhd;
  53. struct VDATA *vp;
  54. struct vecdata rel, nxtrel;
  55. int np;
  56. int sts;
  57. struct vecdata svd;
  58. if ( (sts = VDGetHead( iLst, &vhd))!=0)
  59. goto RET;
  60. VDNew(oLst);
  61. while ( vhd->next!=NIL) {
  62. /* No point data is not Allowed */
  63. /* Set Origin */
  64. vp = vhd->headp;
  65. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  66. goto RET;
  67. vp=vp->next;
  68. for ( np = 1; np < vhd->nPoints; np++,vp = vp->next) {
  69. if ( vp->vd.atr & SPLINE_ATR) {
  70. rel.x = vp->vd.x - vp->prev->vd.x;
  71. rel.y = vp->vd.y - vp->prev->vd.y;
  72. nxtrel.x= vp->next->vd.x - vp->vd.x;
  73. nxtrel.y= vp->next->vd.y - vp->vd.y;
  74. if ((long)rel.x*nxtrel.y==(long)rel.y*nxtrel.x){
  75. vp = vp->next;
  76. np++;
  77. svd = vp->vd;
  78. svd.atr &= ~SPLINE_ATR;
  79. if ((sts = VDSetData(oLst, &svd))!=0)
  80. goto RET;
  81. }
  82. else {
  83. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  84. goto RET;
  85. vp = vp->next;
  86. np++;
  87. if ( np >= vhd->nPoints)
  88. break;
  89. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  90. goto RET;
  91. }
  92. }
  93. else {
  94. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  95. goto RET;
  96. }
  97. }
  98. if(VDClose( oLst))
  99. goto RET;
  100. vhd = vhd->next;
  101. }
  102. return 0;
  103. RET:
  104. return -1;
  105. }
  106. /***********************************************************************
  107. * Smoothing Main
  108. */
  109. /* */ int
  110. /* */ SmoothVector(
  111. /* */ int lstHdl,
  112. /* */ int tmpLst,
  113. /* */ int xinMesh, /* Input Mesh Size*/
  114. /* */ int yinMesh,
  115. /* */ int outMesh, /* Output Mesh size */
  116. /* */ struct SMOOTHPRM *prm,
  117. /* */ int fp) /* Fixed Point sft-val */
  118. /*
  119. * reuturns : 0, -1
  120. * Remarks : ̃W[̓͂́A֊sǒʂ̃xN^
  121. * @_ƂB
  122. * @o͂́Ao̓bVɍA_͍ŁA
  123. * @x[XCAxAO͒Ȃ
  124. ***********************************************************************/
  125. {
  126. int sts;
  127. if (!prm)
  128. {
  129. sts = -1;
  130. goto RET;
  131. }
  132. if ( (sts = BindPoint( lstHdl, tmpLst))<0)
  133. goto RET;
  134. if ( (sts = DetectNoSmooth( tmpLst))<0)
  135. goto RET;
  136. if ( (sts = ZoomPoint( tmpLst, xinMesh, yinMesh, outMesh, fp))<0)
  137. goto RET;
  138. if ( (sts = preproc1( tmpLst, lstHdl))<0)
  139. goto RET;
  140. /* */
  141. if ( prm->UseConic) {
  142. if ( sts = divVec( lstHdl, tmpLst, 2))
  143. goto RET;
  144. if ( (sts = Smooth1( tmpLst, lstHdl, 1, 2, 1))<0)
  145. goto RET;
  146. if ( (sts = Smooth2( lstHdl, tmpLst))<0)
  147. goto RET;
  148. if ( sts = FitConic(tmpLst,lstHdl, prm->SmoothLevel, fp))
  149. goto RET;
  150. }
  151. else {
  152. if ( (sts = Smooth1( lstHdl, tmpLst, 1, 2, 1))<0)
  153. goto RET;
  154. if ( (sts = Smooth2( tmpLst, lstHdl))<0)
  155. goto RET;
  156. }
  157. if ( (sts = DelZeroVec( lstHdl, tmpLst))<0)
  158. goto RET;
  159. if ( (sts = straightCurve( tmpLst, lstHdl))<0)
  160. goto RET;
  161. if ( (sts = DelZeroVec( lstHdl, tmpLst))<0)
  162. goto RET;
  163. sts = BindLinears( tmpLst, lstHdl);
  164. RET:
  165. return sts;
  166. }
  167. /***********************************************************************
  168. * Bind Same Direction Unit Vector
  169. */
  170. /* */ static int
  171. /* */ BindVector(
  172. /* */ int inLst, /* Absolute Coordinate */
  173. /* */ int outLst) /* Relative one */
  174. /*
  175. * reuturns : 0, -1
  176. ***********************************************************************/
  177. {
  178. struct VHEAD *vhd;
  179. struct VDATA *vp;
  180. struct vecdata rel, nxtrel;
  181. int np;
  182. int sts;
  183. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  184. goto RET;
  185. VDNew(outLst);
  186. nxtrel.atr = 1;
  187. while ( vhd->next!=NIL) {
  188. /* No point data is not Allowed */
  189. /* Set Origin */
  190. vp = vhd->headp;
  191. if ((sts = VDSetData(outLst, &vp->vd))!=0)
  192. goto RET;
  193. rel.x = rel.y = 0;
  194. for ( np = 0; np < vhd->nPoints; np++,vp = vp->next) {
  195. nxtrel.x = vp->next->vd.x - vp->vd.x;
  196. nxtrel.y = vp->next->vd.y - vp->vd.y;
  197. if ( rel.x==0 && rel.y ==0)
  198. rel = nxtrel;
  199. else {
  200. if ( rel.y==0 && nxtrel.y==0)
  201. rel.x += nxtrel.x;
  202. else if ( rel.x == 0 && nxtrel.x==0)
  203. rel.y += nxtrel.y;
  204. else {
  205. if ((sts=VDSetData(outLst, &rel))!=0)
  206. goto RET;
  207. rel = nxtrel;
  208. }
  209. }
  210. }
  211. if ( rel.x!=0 || rel.y!=0) {
  212. if ((sts=VDSetData(outLst, &rel))!=0)
  213. goto RET;
  214. }
  215. vhd = vhd->next;
  216. if ((sts = VDClose(outLst))!=0)
  217. goto RET;
  218. }
  219. RET:
  220. return( sts);
  221. }
  222. /***********************************************************************
  223. * Bind Same Direction Unit Vector(Absolute Coodinate Version)
  224. * Only for short vector ( dont care SPLINE )
  225. */
  226. /* */ static int
  227. /* */ BindPoint(
  228. /* */ int inLst, /* Absolute Coordinate */
  229. /* */ int outLst) /* .. */
  230. /*
  231. * reuturns : 0, -1
  232. ***********************************************************************/
  233. {
  234. struct VHEAD *vhd;
  235. struct VDATA *vp;
  236. struct vecdata lastvd;
  237. int np;
  238. int sts;
  239. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  240. goto RET;
  241. VDNew(outLst);
  242. while ( vhd->next!=NIL) {
  243. /* No point data is not Allowed */
  244. /* Set Origin */
  245. vp = vhd->headp;
  246. if ((sts = VDSetData(outLst, &vp->vd))!=0)
  247. goto RET;
  248. lastvd = vp->vd;
  249. for ( np = 0; np < vhd->nPoints; np++,vp = vp->next) {
  250. if (vp->next->vd.x != lastvd.x && vp->next->vd.y != lastvd.y) {
  251. if ((sts=VDSetData(outLst, &vp->vd))!=0)
  252. goto RET;
  253. lastvd = vp->vd;
  254. }
  255. }
  256. vhd = vhd->next;
  257. if ((sts = VDClose(outLst))!=0)
  258. goto RET;
  259. }
  260. RET:
  261. return( sts);
  262. }
  263. /***********************************************************************
  264. * Detect Corner and edge
  265. */
  266. /* */ static int
  267. /* */ DetectNoSmooth(
  268. /* */ int lsthdl) /* Absolute Coordinate */
  269. /*
  270. * returns : 0, -1
  271. ***********************************************************************/
  272. {
  273. struct VHEAD *vhd;
  274. int sts;
  275. struct VDATA *vp;
  276. int np;
  277. if ( (sts = VDGetHead( lsthdl, &vhd))!=0)
  278. goto RET;
  279. while ( vhd->next != NIL) {
  280. vp = vhd->headp;
  281. for ( np = 0; np < vhd->nPoints; np++, vp = vp->next) {
  282. if ( isturn( vp) )
  283. turnsort(vp);
  284. else if (islong (vp))
  285. longline( vp);
  286. else /* based on general rule */
  287. generalsmooth(vp);
  288. }
  289. vhd = vhd->next;
  290. }
  291. RET:
  292. return sts;
  293. }
  294. /***********************************************************************
  295. * Judge smooth or not at Turning Part
  296. */
  297. /* */ static void
  298. /* */ turnsort(
  299. /* */ struct VDATA *vp)
  300. /*
  301. * returns : none
  302. ***********************************************************************/
  303. {
  304. struct vecdata cur, prev1, prev2, next1, next2;
  305. if (!vp)
  306. {
  307. return;
  308. }
  309. cur.x = vp->vd.x-vp->prev->vd.x;
  310. cur.y = vp->vd.y-vp->prev->vd.y;
  311. prev1.x = vp->prev->vd.x-vp->prev->prev->vd.x;
  312. prev1.y = vp->prev->vd.y-vp->prev->prev->vd.y;
  313. prev2.x = vp->prev->prev->vd.x-vp->prev->prev->prev->vd.x;
  314. prev2.y = vp->prev->prev->vd.y-vp->prev->prev->prev->vd.y;
  315. next1.x = vp->next->vd.x - vp->vd.x;
  316. next1.y = vp->next->vd.y - vp->vd.y;
  317. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  318. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  319. if ( cur.x) {
  320. if ( abs(next1.y) > 1)
  321. vp->vd.atr |= NOSMOOTH ;
  322. else if ( sign( cur.x) == sign( next2.x))
  323. vp->vd.atr |= SMOOTH | BACKWARD;
  324. else
  325. vp->vd.atr |= NOSMOOTH;
  326. if ( abs(prev1.y) > 1)
  327. vp->prev->vd.atr |= NOSMOOTH ;
  328. else if (sign(cur.x)==sign(prev2.x))
  329. vp->prev->vd.atr |= SMOOTH | FOREWARD;
  330. else
  331. vp->prev->vd.atr |= NOSMOOTH ;
  332. }
  333. else {
  334. if ( abs(next1.x) > 1)
  335. vp->vd.atr |= NOSMOOTH ;
  336. else if ( sign( cur.y) == sign( next2.y))
  337. vp->vd.atr |= SMOOTH | BACKWARD;
  338. else
  339. vp->vd.atr |= NOSMOOTH;
  340. if ( abs(prev1.x) > 1)
  341. vp->prev->vd.atr |= NOSMOOTH ;
  342. else if (sign(cur.y)==sign(prev2.y))
  343. vp->prev->vd.atr |= SMOOTH | FOREWARD;
  344. else
  345. vp->prev->vd.atr |= NOSMOOTH;
  346. }
  347. return;
  348. }
  349. /***********************************************************************
  350. * Judge Smooth or not with general rule
  351. */
  352. /* */ static void
  353. /* */ generalsmooth( struct VDATA *vp)
  354. /*
  355. * returns : none
  356. ***********************************************************************/
  357. {
  358. struct vecdata prev2, prev1, cur, next1, next2, next3;
  359. if (!vp)
  360. {
  361. return;
  362. }
  363. cur.x = vp->vd.x- vp->prev->vd.x;
  364. cur.y = vp->vd.y- vp->prev->vd.y;
  365. prev1.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  366. prev1.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  367. prev2.x = vp->prev->prev->vd.x - vp->prev->prev->prev->vd.x;
  368. prev2.y = vp->prev->prev->vd.y - vp->prev->prev->prev->vd.y;
  369. next1.x = vp->next->vd.x - vp->vd.x;
  370. next1.y = vp->next->vd.y - vp->vd.y;
  371. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  372. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  373. next3.x = vp->next->next->next->vd.x - vp->next->next->vd.x;
  374. next3.y = vp->next->next->next->vd.y - vp->next->next->vd.y;
  375. if ( cur.y) {
  376. if ( abs(next1.x)>1 && abs(cur.y)>1) {
  377. if ( sign(cur.y) == sign(next1.x)
  378. && abs(next2.y)==1
  379. && abs(prev1.x)==1
  380. && sign(cur.y)==sign(prev2.y)
  381. && sign(next1.x)==sign( next3.x))
  382. ;
  383. else
  384. vp->vd.atr |= NOSMOOTH;
  385. }
  386. }
  387. else {
  388. if ( abs(next1.y)>1 && abs(cur.x)>1) {
  389. if ( sign(cur.x) != sign(next1.y)
  390. && abs(next2.x)==1
  391. && abs(prev1.y)==1
  392. && sign(cur.x)==sign(prev2.x)
  393. && sign(next1.y)==sign( next3.y))
  394. ;
  395. else
  396. vp->vd.atr |= NOSMOOTH;
  397. }
  398. }
  399. return;
  400. }
  401. /***********************************************************************
  402. * Judge turning
  403. */
  404. /* */ static int
  405. /* */ isturn( struct VDATA *vp) /* Absolute */
  406. /*
  407. * retuns
  408. ***********************************************************************/
  409. {
  410. int turnSort=0;
  411. struct vecdata prev, cur, next;
  412. if (!vp)
  413. {
  414. return turnSort;
  415. }
  416. prev.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  417. prev.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  418. cur.x = vp->vd.x - vp->prev->vd.x;
  419. cur.y = vp->vd.y - vp->prev->vd.y;
  420. next.x = vp->next->vd.x - vp->vd.x;
  421. next.y = vp->next->vd.y - vp->vd.y;
  422. if ( prev.x !=0) {
  423. if ( sign(prev.x )!=sign(next.x )) {
  424. if (sign(next.x ) ==sign(cur.y))
  425. turnSort = TURN_TOTSU;
  426. else
  427. turnSort = TURN_OU;
  428. }
  429. else turnSort = 0;
  430. }
  431. else {
  432. if ( sign(prev.y )!=sign(next.y )) {
  433. if (sign(next.y ) ==sign(cur.x))
  434. turnSort = TURN_OU;
  435. else
  436. turnSort = TURN_TOTSU;
  437. }
  438. else turnSort = 0;
  439. }
  440. return turnSort;
  441. }
  442. /***********************************************************************
  443. * judge Long Line or Not
  444. */
  445. /* */ static int
  446. /* */ islong( struct VDATA *vp)
  447. /*
  448. * returns : 0, 1
  449. ***********************************************************************/
  450. {
  451. struct vecdata cur, prev1, prev2, next1, next2;
  452. int sts;
  453. if (!vp)
  454. {
  455. return (0);
  456. }
  457. cur.x = vp->vd.x - vp->prev->vd.x;
  458. cur.y = vp->vd.y - vp->prev->vd.y;
  459. if ( abs(cur.x)<= LONGMIN && abs(cur.y) <= LONGMIN)
  460. return( 0);
  461. prev2.x = vp->prev->prev->vd.x - vp->prev->prev->prev->vd.x;
  462. prev2.y = vp->prev->prev->vd.y - vp->prev->prev->prev->vd.y;
  463. prev1.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  464. prev1.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  465. next1.x = vp->next->vd.x - vp->vd.x;
  466. next1.y = vp->next->vd.y - vp->vd.y;
  467. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  468. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  469. if ( cur.x) {
  470. if ( (sign(cur.x) != sign(next2.x)
  471. || abs(next1.y)>1
  472. || ( abs(next1.y)==1 && abs(cur.x)/2 > abs(next2.x)))
  473. && (sign(cur.x) != sign(prev2.x)
  474. || abs(prev1.y)>1
  475. || ( abs(prev1.y)==1 && abs(cur.x)/2 > abs(prev2.x))))
  476. sts = 1;
  477. /* 94.11.09 */
  478. else if ( abs(cur.x) > 2 && (abs(next1.y)>2 || abs(prev1.y)>2))
  479. sts = 1;
  480. /* */
  481. else sts = 0;
  482. }
  483. else {
  484. if ( (sign(cur.y) != sign(next2.y)
  485. || abs(next1.x)>1
  486. || ( abs(next1.x)==1 && abs(cur.y)/2 > abs(next2.y)))
  487. && (sign(cur.y) != sign(prev2.y)
  488. || abs(prev1.x)>1
  489. || ( abs(prev1.x)==1 && abs(cur.y)/2 > abs(prev2.y))))
  490. sts = 1;
  491. /* 94.11.09 */
  492. else if ( abs(cur.y) > 2 && (abs(next1.x)>2 || abs(prev1.x)>2))
  493. sts = 1;
  494. /* */
  495. else sts = 0;
  496. }
  497. return sts;
  498. }
  499. /***********************************************************************
  500. * judge Long Line or Not
  501. */
  502. /* */ static void
  503. /* */ longline( struct VDATA *vp)
  504. /*
  505. * returns : 0, 1
  506. ***********************************************************************/
  507. {
  508. struct vecdata cur, prev1, prev2, next1, next2;
  509. if (!vp)
  510. {
  511. return;
  512. }
  513. prev2.x = vp->prev->prev->vd.x - vp->prev->prev->prev->vd.x;
  514. prev2.y = vp->prev->prev->vd.y - vp->prev->prev->prev->vd.y;
  515. prev1.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  516. prev1.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  517. cur.x = vp->vd.x - vp->prev->vd.x;
  518. cur.y = vp->vd.y - vp->prev->vd.y;
  519. next1.x = vp->next->vd.x - vp->vd.x;
  520. next1.y = vp->next->vd.y - vp->vd.y;
  521. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  522. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  523. if ( cur.x) {
  524. /* �O�� */
  525. if ( abs(next1.y)!=1 || sign(cur.x)!=sign(next2.x))
  526. vp->vd.atr |= NOSMOOTH;
  527. else if ( abs( next2.x) ==1 && sign(cur.x)==sign(next1.y))
  528. vp->vd.atr |= NOSMOOTH;
  529. else
  530. vp->vd.atr |= NOSMOOTH | BACKWARD;
  531. /* ���� */
  532. if ( abs(prev1.y)!=1 || sign(cur.x)!=sign(prev2.x))
  533. vp->prev->vd.atr |= NOSMOOTH;
  534. else if ( abs( prev2.x) ==1&& sign(cur.x)!=sign(prev1.y))
  535. vp->prev->vd.atr |= NOSMOOTH;
  536. else
  537. vp->prev->vd.atr |= NOSMOOTH | FOREWARD;
  538. }
  539. else {
  540. /* �O�� */
  541. if ( abs(next1.x)!=1 || sign(cur.y)!=sign(next2.y))
  542. vp->vd.atr |= NOSMOOTH;
  543. else if ( abs( next2.y) ==1 && sign(cur.y)!=sign(next1.x))
  544. vp->vd.atr |= NOSMOOTH;
  545. else
  546. vp->vd.atr |= NOSMOOTH | BACKWARD;
  547. /* ���� */
  548. if ( abs(prev1.x)!=1 || sign(cur.y)!=sign(prev2.y))
  549. vp->prev->vd.atr |= NOSMOOTH;
  550. else if ( abs( prev2.y) ==1&& sign(cur.y)==sign(prev1.x))
  551. vp->prev->vd.atr |= NOSMOOTH;
  552. else
  553. vp->prev->vd.atr |= NOSMOOTH | FOREWARD;
  554. }
  555. }
  556. /***********************************************************************
  557. * Zoom for fixed point
  558. */
  559. /* */ static int
  560. /* */ ZoomPoint(
  561. /* */ int lstHdl, /* List Handle to proccess */
  562. /* */ int xinMesh, /* INPut Dot Mesh */
  563. /* */ int yinMesh,
  564. /* */ int outMesh, /* output mesh (256) */
  565. /* */ int uFp) /* Under Fixed Point Value */
  566. /*
  567. * returns : none
  568. * remarks : ʂ̍WńA(128,128)[=outMesh/2]_ɈړA
  569. * @UFp|lł
  570. ***********************************************************************/
  571. {
  572. struct VHEAD *vhd;
  573. int sts;
  574. struct VDATA *vp;
  575. int np;
  576. int center;
  577. center = outMesh/2*uFp;
  578. if ( (sts = VDGetHead( lstHdl, &vhd))!=0)
  579. goto RET;
  580. while ( vhd->next != NIL) {
  581. vp = vhd->headp;
  582. for ( np = 0; np < vhd->nPoints; np++, vp = vp->next) {
  583. vp->vd.x =(short)((long)vp->vd.x*outMesh*uFp/xinMesh)-center;
  584. vp->vd.y =(short)((long)vp->vd.y*outMesh*uFp/yinMesh)-center;
  585. }
  586. vhd = vhd->next;
  587. }
  588. RET:
  589. return sts;
  590. }
  591. /***********************************************************************
  592. * Pre-Proc1 of smoothing( divide long vector )
  593. */
  594. /* */ static int
  595. /* */ preproc1( int inLst, int outLst)
  596. /*
  597. * returns : 0. -1
  598. ***********************************************************************/
  599. {
  600. struct VHEAD *vhd;
  601. int sts;
  602. struct VDATA *vp;
  603. int np;
  604. struct vecdata vd;
  605. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  606. goto RET;
  607. VDNew( outLst);
  608. while ( vhd->next != NIL) {
  609. vp = vhd->headp;
  610. for ( np = 0; np < vhd->nPoints; ) {
  611. if ( vp->vd.atr & FOREWARD) {
  612. if ( vp->next->vd.atr& BACKWARD) {
  613. if ((sts = diveachside( vp, outLst))<0)
  614. goto RET;
  615. np++;
  616. vp = vp->next;
  617. }
  618. else {
  619. if ((sts=divoneside(vp, outLst))<0)
  620. goto RET;
  621. }
  622. }
  623. else if ((vp->vd.atr & BACKWARD)
  624. && (vp->prev->vd.atr & FOREWARD)==0){
  625. if ( (sts = divoneside( vp, outLst))<0)
  626. goto RET;
  627. }
  628. else { /* only copy */
  629. vd = vp->vd;
  630. if ( vp->vd.atr & NOSMOOTH)
  631. vd.atr = SMOOTHANCHOR;
  632. if ((sts=VDSetData( outLst, &vd))<0)
  633. goto RET;
  634. }
  635. np++;
  636. vp = vp->next;
  637. }
  638. if ( (sts = VDClose( outLst))<0)
  639. break;
  640. vhd = vhd->next;
  641. }
  642. RET:
  643. return sts;
  644. }
  645. /***********************************************************************
  646. * Divide Vector from each side( for PreProc)
  647. */
  648. /* */ static int
  649. /* */ diveachside( struct VDATA *vp, int outLst)
  650. /*
  651. * returns : 0, -1
  652. ***********************************************************************/
  653. {
  654. struct vecdata prev, cur, next1, next2, next3;
  655. struct vecdata div1, div2;
  656. int sts=0;
  657. if (!vp)
  658. {
  659. goto RET;
  660. }
  661. prev.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  662. prev.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  663. cur.x = vp->vd.x - vp->prev->vd.x;
  664. cur.y = vp->vd.y - vp->prev->vd.y;
  665. next1.x = vp->next->vd.x - vp->vd.x;
  666. next1.y = vp->next->vd.y - vp->vd.y;
  667. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  668. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  669. next3.x = vp->next->next->next->vd.x - vp->next->next->vd.x;
  670. next3.y = vp->next->next->next->vd.y - vp->next->next->vd.y;
  671. sts = 0;
  672. if ( next1.x) {
  673. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  674. goto RET;
  675. div1.y = vp->vd.y;
  676. div2.y = vp->vd.y;
  677. div1.atr = SMOOTHANCHOR;
  678. div2.atr = SMOOTHANCHOR;
  679. if ( abs(prev.x) + abs( next3.x) <= abs(next1.x)) {
  680. div1.x = vp->vd.x + prev.x;
  681. if ( (sts = VDSetData( outLst, &div1))<0)
  682. goto RET;
  683. div2.x = vp->next->vd.x - next3.x;
  684. if ( (sts = VDSetData( outLst, &div2))<0)
  685. goto RET;
  686. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  687. goto RET;
  688. }
  689. else {
  690. div1.x = (short)((long)next1.x*abs(prev.x)/abs(prev.x + next3.x));
  691. if ( div1.x != 0) {
  692. div1.x += vp->vd.x;
  693. if ( (sts = VDSetData( outLst, &div1))<0)
  694. goto RET;
  695. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  696. goto RET;
  697. }
  698. else {
  699. div1.x = vp->next->vd.x;
  700. div1.y = vp->next->vd.y;
  701. if ( (sts = VDSetData( outLst, &div1))<0)
  702. goto RET;
  703. }
  704. }
  705. }
  706. else {
  707. div1.x = vp->vd.x;
  708. div2.x = vp->vd.x;
  709. div1.atr = SMOOTHANCHOR;
  710. div2.atr = SMOOTHANCHOR;
  711. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  712. goto RET;
  713. if ( abs(prev.y) + abs( next3.y) <= abs(next1.y)) {
  714. // div1.y = vp->vd.y + prev.y;
  715. div1.y = vp->vd.y + prev.y/2;
  716. if ( (sts = VDSetData( outLst, &div1))<0)
  717. goto RET;
  718. // div2.y = vp->next->vd.y - next3.y;
  719. div2.y = vp->next->vd.y - next3.y/2;
  720. if ( (sts = VDSetData( outLst, &div2))<0)
  721. goto RET;
  722. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  723. goto RET;
  724. }
  725. else {
  726. div1.y = (short)((long)next1.y*abs(prev.y)/abs(prev.y + next3.y));
  727. if ( div1.y!=0) {
  728. div1.y += vp->vd.y;
  729. if ( (sts = VDSetData( outLst, &div1))<0)
  730. goto RET;
  731. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  732. goto RET;
  733. }
  734. else {
  735. div1.x = vp->next->vd.x;
  736. div1.y = vp->next->vd.y;
  737. if ( (sts = VDSetData( outLst, &div1))<0)
  738. goto RET;
  739. }
  740. }
  741. }
  742. RET:
  743. return( sts);
  744. }
  745. /***********************************************************************
  746. *
  747. */
  748. /* */ static int
  749. /* */ divoneside(
  750. /* */ struct VDATA *vp,
  751. /* */ int outLst)
  752. /*
  753. *
  754. ***********************************************************************/
  755. {
  756. struct vecdata prev, cur, next1, next2;
  757. struct vecdata div1;
  758. int sts;
  759. sts = 0;
  760. if (!vp)
  761. {
  762. goto RET;
  763. }
  764. div1.atr = SMOOTHANCHOR;
  765. if ( vp->vd.atr & FOREWARD) {
  766. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  767. goto RET;
  768. prev.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  769. prev.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  770. cur.x = vp->vd.x - vp->prev->vd.x;
  771. cur.y = vp->vd.y - vp->prev->vd.y;
  772. next1.x = vp->next->vd.x - vp->vd.x;
  773. next1.y = vp->next->vd.y - vp->vd.y;
  774. if ( vp->vd.x == vp->prev->vd.x) {
  775. if ( abs(prev.x) < abs(next1.x)) {
  776. div1.y = vp->vd.y;
  777. // div1.x = vp->vd.x + prev.x;
  778. div1.x = vp->vd.x + prev.x/2;
  779. if ( (sts = VDSetData( outLst, &div1))<0)
  780. goto RET;
  781. }
  782. }
  783. else {
  784. if ( abs(prev.y) < abs(next1.y)) {
  785. div1.x = vp->vd.x;
  786. // div1.y = vp->vd.y + prev.y;
  787. div1.y = vp->vd.y + prev.y/2;
  788. if ( (sts = VDSetData( outLst, &div1))<0)
  789. goto RET;
  790. }
  791. }
  792. }
  793. else {
  794. cur.x = vp->vd.x - vp->prev->vd.x;
  795. cur.y = vp->vd.y - vp->prev->vd.y;
  796. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  797. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  798. if ( vp->vd.x == vp->next->vd.x) {
  799. if ( abs(cur.x) > abs(next2.x)) {
  800. // div1.x = vp->vd.x - next2.x;
  801. div1.x = vp->vd.x - next2.x/2;
  802. div1.y = vp->vd.y;
  803. if ( (sts = VDSetData( outLst, &div1))<0)
  804. goto RET;
  805. }
  806. }
  807. else {
  808. if ( abs(cur.y) > abs(next2.y)) {
  809. div1.x = vp->vd.x;
  810. // div1.y = vp->vd.y - next2.y;
  811. div1.y = vp->vd.y - next2.y/2;
  812. if ( (sts = VDSetData( outLst, &div1))<0)
  813. goto RET;
  814. }
  815. }
  816. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  817. goto RET;
  818. }
  819. RET:
  820. return( sts);
  821. }
  822. /***********************************************************************
  823. * Smoothing 1
  824. */
  825. /* */ static int
  826. /* */ Smooth1( int inLst,
  827. /* */ int outLst,
  828. /* */ int weight1, /* Waight of Smoothing Form.*/
  829. /* */ int weight2,
  830. /* */ int weight3 )
  831. /*
  832. * returns : 0, -1
  833. ***********************************************************************/
  834. {
  835. struct VHEAD *vhd;
  836. int sts;
  837. struct VDATA *svp, *evp;
  838. int sp, ep;
  839. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  840. goto RET;
  841. VDNew( outLst);
  842. while ( vhd->next != NIL) {
  843. svp = vhd->headp;
  844. if ((sp=searchanchor(0,svp,&svp,vhd->nPoints))<vhd->nPoints){
  845. while(sp <vhd->nPoints) {
  846. ep = searchanchor(sp+1, svp->next,&evp, vhd->nPoints);
  847. if ((sts=smooth1sub( svp, ep-sp,outLst,weight1, weight2, weight3))<0)
  848. goto RET;
  849. if ( ep >= vhd->nPoints)
  850. break;
  851. sp = ep;
  852. svp = evp;
  853. }
  854. }
  855. vhd = vhd->next;
  856. if ( (sts = VDClose( outLst)) < 0)
  857. break;
  858. }
  859. RET:
  860. return sts;
  861. }
  862. /***********************************************************************
  863. * Smoothing 2 ( mabiki)
  864. */
  865. /* */ static int
  866. /* */ Smooth2( int inLst, int outLst )
  867. /*
  868. * returns : 0, -1
  869. ***********************************************************************/
  870. {
  871. struct VHEAD *vhd;
  872. int sts;
  873. struct VDATA *svp, *evp;
  874. int sp, ep;
  875. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  876. goto RET;
  877. VDNew( outLst);
  878. while ( vhd->next != NIL) {
  879. svp = vhd->headp;
  880. if ((sp=searchanchor(0,svp,&svp,vhd->nPoints))<vhd->nPoints){
  881. while(sp <vhd->nPoints) {
  882. ep = searchanchor(sp+1, svp->next,&evp, vhd->nPoints);
  883. if ((sts=smooth2sub( svp, ep-sp,outLst))<0)
  884. goto RET;
  885. if ( ep >= vhd->nPoints)
  886. break;
  887. sp = ep;
  888. svp = evp;
  889. }
  890. }
  891. vhd = vhd->next;
  892. if ( (sts = VDClose( outLst)) < 0)
  893. break;
  894. }
  895. RET:
  896. return sts;
  897. }
  898. /***********************************************************************
  899. * Search Smoothing Anchor Point
  900. */
  901. /* */ int
  902. /* */ searchanchor(
  903. /* */ int sn,
  904. /* */ struct VDATA *sp,
  905. /* */ struct VDATA **ep,
  906. /* */ int lim)
  907. /*
  908. *
  909. ***********************************************************************/
  910. {
  911. if ( (!sp) || (!ep))
  912. {
  913. return 0;
  914. }
  915. while ( lim-- > 0) {
  916. if (sp->vd.atr & SMOOTHANCHOR) {
  917. *ep = sp;
  918. return sn;
  919. }
  920. sp = sp->next;
  921. sn++;
  922. }
  923. return( sn);
  924. }
  925. /***********************************************************************
  926. * Smooth1 body
  927. */
  928. /* */ static int
  929. /* */ smooth1sub(
  930. /* */ struct VDATA *vp,
  931. /* */ int np,
  932. /* */ int outLst,
  933. /* */ int w1, /* Waight of Smoothing Form.*/
  934. /* */ int w2,
  935. /* */ int w3)
  936. /*
  937. * returns : 0, -1
  938. ***********************************************************************/
  939. {
  940. int pcnt,
  941. sts=-1;
  942. struct vecdata vd;
  943. int base;
  944. if (!vp)
  945. {
  946. goto RET;;
  947. }
  948. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  949. goto RET;
  950. np--;
  951. vp = vp->next;
  952. base = w1 + w2 + w3;
  953. for ( pcnt = 0; pcnt < np; pcnt++, vp= vp->next) {
  954. vd.x = (vp->prev->vd.x*w1 + vp->vd.x*w2 + vp->next->vd.x*w3)/base;
  955. vd.y = (vp->prev->vd.y*w1 + vp->vd.y*w2 + vp->next->vd.y*w3)/base;
  956. vd.atr = vp->vd.atr;
  957. if ( (sts = VDSetData( outLst, &vd))<0)
  958. break;
  959. }
  960. RET:
  961. return( sts);
  962. }
  963. /***********************************************************************
  964. * Smooth2 body ( mabiki body)
  965. */
  966. /* */ static int
  967. /* */ smooth2sub(
  968. /* */ struct VDATA *vp,
  969. /* */ int np,
  970. /* */ int outLst)
  971. /*
  972. * returns : 0, -1
  973. ***********************************************************************/
  974. {
  975. int pcnt,
  976. sts=-1;
  977. if (!vp)
  978. {
  979. goto RET;;
  980. }
  981. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  982. goto RET;
  983. np--;
  984. vp = vp->next;
  985. for ( pcnt = 0; pcnt < np; pcnt++, vp= vp->next) {
  986. if ( np < 3 || pcnt % 2 == 0) {
  987. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  988. break;
  989. }
  990. }
  991. RET:
  992. return( sts);
  993. }
  994. /***********************************************************************
  995. * Remove Fixed Point
  996. */
  997. /* */ int
  998. /* */ RemoveFp(
  999. /* */ int lstHdl, /* List Handle to proccess */
  1000. /* */ int outMesh, /* output mesh */
  1001. /* */ int uFp) /* Under Fixed Point Value */
  1002. /*
  1003. * returns : none
  1004. * remarks : X[YBȌʂ̍WńAUFpŊČ_
  1005. * (128,128) [=outMesh/2]Ɉړlł
  1006. ***********************************************************************/
  1007. {
  1008. struct VHEAD *vhd;
  1009. int sts;
  1010. struct VDATA *vp;
  1011. int center;
  1012. int np;
  1013. center = outMesh/2;
  1014. if ( (sts = VDGetHead( lstHdl, &vhd))!=0)
  1015. goto RET;
  1016. while ( vhd->next != NIL) {
  1017. vp = vhd->headp;
  1018. for ( np = 0; np < vhd->nPoints; np++, vp = vp->next) {
  1019. vp->vd.x = vp->vd.x / uFp+center;
  1020. if ( vp->vd.x < 0) vp->vd.x = 0;
  1021. else if ( vp->vd.x >= outMesh) vp->vd.x = outMesh-1;
  1022. vp->vd.y = vp->vd.y / uFp+center;
  1023. if ( vp->vd.y < 0) vp->vd.y = 0;
  1024. else if ( vp->vd.y >= outMesh) vp->vd.y = outMesh-1;
  1025. }
  1026. vhd = vhd->next;
  1027. }
  1028. RET:
  1029. return sts;
  1030. }
  1031. /***********************************************************************
  1032. * Bind same direction vector
  1033. */
  1034. /* */ static int
  1035. /* */ BindLinears( int inLst, int outLst)
  1036. /*
  1037. ***********************************************************************/
  1038. {
  1039. struct VHEAD *vhd;
  1040. int sts;
  1041. struct VDATA *vp;
  1042. int np;
  1043. struct vecdata rel1, rel2;
  1044. VDNew( outLst);
  1045. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  1046. goto RET;
  1047. while ( vhd->next != NIL) {
  1048. vp = vhd->headp;
  1049. /* Origin */
  1050. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1051. goto RET;
  1052. vp = vp->next;
  1053. for ( np = 1; np < vhd->nPoints; np++, vp = vp->next) {
  1054. if ( np+1 >= vhd->nPoints) {
  1055. if ((sts=VDSetData( outLst, &vp->vd))<0)
  1056. goto RET;
  1057. break;
  1058. }
  1059. else if ( vp->vd.atr&SPLINE_ATR) {
  1060. if ((sts=VDSetData( outLst, &vp->vd))<0)
  1061. goto RET;
  1062. /* End Point */
  1063. vp = vp->next;
  1064. np++;
  1065. if ( np >= vhd->nPoints)
  1066. break;
  1067. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1068. goto RET;
  1069. }
  1070. else {
  1071. rel1.x = vp->next->vd.x - vp->vd.x;
  1072. rel1.y = vp->next->vd.y - vp->vd.y;
  1073. rel2.x = vp->vd.x - vp->prev->vd.x;
  1074. rel2.y = vp->vd.y - vp->prev->vd.y;
  1075. if ( (vp->next->vd.atr & SPLINE_ATR )
  1076. || (long)rel1.x*rel2.y != (long)rel1.y*rel2.x) {
  1077. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1078. goto RET;
  1079. }
  1080. }
  1081. }
  1082. if ( (sts = VDClose( outLst))<0)
  1083. goto RET;
  1084. vhd = vhd->next;
  1085. }
  1086. RET:
  1087. return( sts);
  1088. }
  1089. /***********************************************************************
  1090. * Deleate Zero Vector ( about Non Curve Part)
  1091. */
  1092. /* */ static int
  1093. /* */ DelZeroVec( int inLst, int outLst)
  1094. /*
  1095. ***********************************************************************/
  1096. {
  1097. struct VHEAD *vhd;
  1098. int sts;
  1099. struct VDATA *vp;
  1100. int np;
  1101. VDNew( outLst);
  1102. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  1103. goto RET;
  1104. while ( vhd->next != NIL) {
  1105. vp = vhd->headp;
  1106. /* Origin */
  1107. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1108. goto RET;
  1109. vp = vp->next;
  1110. for ( np = 1; np < vhd->nPoints; np++, vp = vp->next) {
  1111. if ( vp->vd.atr&SPLINE_ATR) {
  1112. /* Control Point */
  1113. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1114. goto RET;
  1115. /* End Point */
  1116. vp = vp->next;
  1117. np++;
  1118. if ( np >= vhd->nPoints)
  1119. break;
  1120. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1121. goto RET;
  1122. }
  1123. else {
  1124. if ( vp->vd.x != vp->prev->vd.x
  1125. || vp->vd.y != vp->prev->vd.y) {
  1126. if ((sts=VDSetData( outLst, &vp->vd))<0)
  1127. goto RET;
  1128. }
  1129. }
  1130. }
  1131. if ( (sts = VDClose( outLst))<0)
  1132. goto RET;
  1133. vhd = vhd->next;
  1134. }
  1135. RET:
  1136. return( sts);
  1137. }
  1138. /* X |Y
  1139. * O------------ +-|------+
  1140. * | | | | |
  1141. * | | ---> | | |
  1142. * | | -----+-------------X
  1143. * |-------+ O-|------+
  1144. * |Y |
  1145. */
  1146. int
  1147. toTTFFrame( int lstH, struct BBX *bbx)
  1148. {
  1149. struct VHEAD *vhd;
  1150. struct VDATA *vp;
  1151. int np;
  1152. int sts=-1;
  1153. short mesh;
  1154. if (!bbx)
  1155. {
  1156. goto RET;
  1157. }
  1158. if ( (sts = VDGetHead( lstH, &vhd))!=0)
  1159. goto RET;
  1160. if ( (sts = VDGetNCont( lstH))<=0)
  1161. goto RET;
  1162. mesh = bbx->xMax - bbx->xMin+1;
  1163. if ( mesh > bbx->yMax - bbx->yMin)
  1164. mesh = bbx->yMax - bbx->yMin+1;
  1165. while ( vhd->next != NIL) {
  1166. vp = vhd->headp;
  1167. np = vhd->nPoints;
  1168. while ( np-->0) {
  1169. vp->vd.x += (short)bbx->xMin;
  1170. vp->vd.y = (mesh - 1) - vp->vd.y + bbx->yMin;
  1171. /* Limit in BBX */
  1172. if ( vp->vd.x > bbx->xMax)
  1173. vp->vd.x = (short)bbx->xMax;
  1174. else if (vp->vd.x < bbx->xMin)
  1175. vp->vd.x = (short)bbx->xMin;
  1176. if ( vp->vd.y > bbx->yMax)
  1177. vp->vd.y = (short)bbx->yMax;
  1178. else if (vp->vd.y < bbx->yMin)
  1179. vp->vd.y = (short)bbx->yMin;
  1180. vp = vp->next;
  1181. }
  1182. vhd = vhd->next;
  1183. }
  1184. sts = 0;
  1185. RET:
  1186. return sts;
  1187. }
  1188. static int
  1189. lightSub( int inLst, int outLst)
  1190. {
  1191. struct VHEAD *vhd;
  1192. int sts;
  1193. struct VDATA *svp, *evp;
  1194. int sp, ep;
  1195. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  1196. goto RET;
  1197. VDNew( outLst);
  1198. while ( vhd->next != NIL) {
  1199. svp = vhd->headp;
  1200. if ((sp=searchanchor(0,svp,&svp,vhd->nPoints))<vhd->nPoints){
  1201. while(sp <vhd->nPoints) {
  1202. ep = searchanchor(sp+1, svp->next,&evp, vhd->nPoints);
  1203. if ((sts=smooth1sub( svp, ep-sp,outLst,1, 2, 1))<0)
  1204. goto RET;
  1205. if ( ep >= vhd->nPoints)
  1206. break;
  1207. sp = ep;
  1208. svp = evp;
  1209. }
  1210. }
  1211. vhd = vhd->next;
  1212. if ( (sts = VDClose( outLst)) < 0)
  1213. break;
  1214. }
  1215. RET:
  1216. return sts;
  1217. }
  1218. static int
  1219. divVec( int ilst, int olst, int divN)
  1220. {
  1221. struct VHEAD *vhd;
  1222. struct VDATA *vp;
  1223. struct vecdata rel, vd;
  1224. int np;
  1225. int n;
  1226. if ( VDGetHead( ilst, &vhd)!=0)
  1227. goto RET;
  1228. VDNew( olst);
  1229. while ( vhd->next != NIL) {
  1230. vp = vhd->headp;
  1231. np = vhd->nPoints;
  1232. while ( np-->0) {
  1233. if (VDSetData(olst, &vp->vd))
  1234. goto RET;
  1235. rel.x = vp->next->vd.x - vp->vd.x;
  1236. rel.y = vp->next->vd.y - vp->vd.y;
  1237. vd.atr = 0;
  1238. for ( n=1; n<divN; n++) {
  1239. vd.x = vp->vd.x+rel.x*n/divN;
  1240. vd.y = vp->vd.y+rel.y*n/divN;
  1241. if (VDSetData(olst, &vd))
  1242. goto RET;
  1243. }
  1244. vp = vp->next;
  1245. }
  1246. vhd = vhd->next;
  1247. VDClose( olst);
  1248. }
  1249. return 0;
  1250. RET:
  1251. return -1;
  1252. }
  1253. int
  1254. SmoothLight( int ioLst, int tmpLst, int width, int height, int oWidth, int ufpVal)
  1255. {
  1256. int sts;
  1257. if ( (sts = BindPoint( ioLst, tmpLst))<0)
  1258. goto RET;
  1259. if ( (sts = DetectNoSmooth( tmpLst))<0)
  1260. goto RET;
  1261. if ( (sts = ZoomPoint( tmpLst, width, height, oWidth, ufpVal))<0)
  1262. goto RET;
  1263. if ( (sts = preproc1( tmpLst, ioLst))<0)
  1264. goto RET;
  1265. if ( sts = divVec( ioLst, tmpLst, 2))
  1266. goto RET;
  1267. if ( lightSub( tmpLst, ioLst))
  1268. goto RET;
  1269. if ( lightSub( ioLst, tmpLst))
  1270. goto RET;
  1271. if ( RemoveFp( tmpLst, oWidth, ufpVal))
  1272. goto RET;
  1273. if ( (sts = DelZeroVec( tmpLst, ioLst))<0)
  1274. goto RET;
  1275. return 0;
  1276. RET:
  1277. return -1;
  1278. }
  1279. int
  1280. ConvMesh( int lstH, int inMesh, int outMesh)
  1281. {
  1282. struct VHEAD *vhd;
  1283. struct VDATA *vp;
  1284. int np;
  1285. int sts;
  1286. if ( inMesh==outMesh)
  1287. return 0;
  1288. if ( (sts = VDGetHead( lstH, &vhd))!=0)
  1289. goto RET;
  1290. if ( (sts = VDGetNCont( lstH))<=0)
  1291. goto RET;
  1292. while ( vhd->next != NIL) {
  1293. vp = vhd->headp;
  1294. np = vhd->nPoints;
  1295. while ( np-->0) {
  1296. vp->vd.x = (int)((long)vp->vd.x*outMesh/inMesh);
  1297. vp->vd.y = (int)((long)vp->vd.y*outMesh/inMesh);
  1298. vp = vp->next;
  1299. }
  1300. vhd = vhd->next;
  1301. }
  1302. sts = 0;
  1303. RET:
  1304. return sts;
  1305. }
  1306. /* EOF */