altsvgrast.diff 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. 1,6d0
  2. < //
  3. < // "$Id: altsvgrast.diff 12415 2017-09-03 13:20:52Z manolo $"
  4. < //
  5. <
  6. < /* Modified by FLTK from original sources to support non-square X,Y axes scaling */
  7. <
  8. 31d24
  9. <
  10. 51,53d43
  11. <
  12. < // For non-square X,Y scaling, use
  13. < nsvgAltRasterize(rast, image, 0,0,1,1, img, w, h, w*4);
  14. 63c53
  15. < // scale - image scale (assumes square aspect ratio)
  16. ---
  17. > // scale - image scale
  18. 72,77d61
  19. < // As above, but allow X and Y axes to scale independently for non-square aspects
  20. < void nsvgAltRasterize(NSVGrasterizer* r,
  21. < NSVGimage* image, float tx, float ty,
  22. < float sx, float sy,
  23. < unsigned char* dst, int w, int h, int stride);
  24. <
  25. 382c366
  26. < static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy)
  27. ---
  28. > static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
  29. 390c374
  30. < nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0);
  31. ---
  32. > nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
  33. 393c377
  34. < nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, 0);
  35. ---
  36. > nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
  37. 396c380
  38. < nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0);
  39. ---
  40. > nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
  41. 746c730
  42. < static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy)
  43. ---
  44. > static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale)
  45. 754,755c738
  46. < const float sw = (sx + sy) / 2; // average scaling factor
  47. < const float lineWidth = shape->strokeWidth * sw; // FIXME (?)
  48. ---
  49. > float lineWidth = shape->strokeWidth * scale;
  50. 760c743
  51. < nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, NSVG_PT_CORNER);
  52. ---
  53. > nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
  54. 763c746
  55. < nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, NSVG_PT_CORNER);
  56. ---
  57. > nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
  58. 809c792
  59. < dashLen = (shape->strokeDashArray[idash] - dashOffset) * sw;
  60. ---
  61. > dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
  62. 831c814
  63. < dashLen = shape->strokeDashArray[idash] * sw;
  64. ---
  65. > dashLen = shape->strokeDashArray[idash] * scale;
  66. 1000c983
  67. < float tx, float ty, float sx, float sy, NSVGcachedPaint* cache)
  68. ---
  69. > float tx, float ty, float scale, NSVGcachedPaint* cache)
  70. 1041,1043c1024,1026
  71. < fx = ((float)x - tx) / sx;
  72. < fy = ((float)y - ty) / sy;
  73. < dx = 1.0f / sx;
  74. ---
  75. > fx = ((float)x - tx) / scale;
  76. > fy = ((float)y - ty) / scale;
  77. > dx = 1.0f / scale;
  78. 1086,1088c1069,1071
  79. < fx = ((float)x - tx) / sx;
  80. < fy = ((float)y - ty) / sy;
  81. < dx = 1.0f / sx;
  82. ---
  83. > fx = ((float)x - tx) / scale;
  84. > fy = ((float)y - ty) / scale;
  85. > dx = 1.0f / scale;
  86. 1127c1110
  87. < static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float sx, float sy, NSVGcachedPaint* cache, char fillRule)
  88. ---
  89. > static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
  90. 1209c1192
  91. < nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, sx, sy, cache);
  92. ---
  93. > nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
  94. 1377,1379c1360,1361
  95. < void nsvgAltRasterize(NSVGrasterizer* r,
  96. < NSVGimage* image, float tx, float ty,
  97. < float sx, float sy,
  98. ---
  99. > void nsvgRasterize(NSVGrasterizer* r,
  100. > NSVGimage* image, float tx, float ty, float scale,
  101. 1410c1392
  102. < nsvg__flattenShape(r, shape, sx, sy);
  103. ---
  104. > nsvg__flattenShape(r, shape, scale);
  105. 1427c1409
  106. < nsvg__rasterizeSortedEdges(r, tx,ty, sx, sy, &cache, shape->fillRule);
  107. ---
  108. > nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
  109. 1429c1411
  110. < if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * sx) > 0.01f) {
  111. ---
  112. > if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
  113. 1434c1416
  114. < nsvg__flattenShapeStroke(r, shape, sx, sy);
  115. ---
  116. > nsvg__flattenShapeStroke(r, shape, scale);
  117. 1453c1435
  118. < nsvg__rasterizeSortedEdges(r, tx,ty,sx, sy, &cache, NSVG_FILLRULE_NONZERO);
  119. ---
  120. > nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
  121. 1465,1477c1447
  122. < void nsvgRasterize(NSVGrasterizer* r,
  123. < NSVGimage* image, float tx, float ty, float scale,
  124. < unsigned char* dst, int w, int h, int stride)
  125. < {
  126. < nsvgAltRasterize(r,image, tx, ty, scale, scale, dst, w, h, stride);
  127. < }
  128. <
  129. < #endif // NANOSVGRAST_IMPLEMENTATION
  130. <
  131. <
  132. < //
  133. < // End of "$Id: altsvgrast.diff 12415 2017-09-03 13:20:52Z manolo $".
  134. < //
  135. ---
  136. > #endif