MCPcopy Create free account
hub / github.com/KLayout/klayout / render_scanline_std_edge

Function render_scanline_std_edge

src/laybasic/laybasic/layBitmapsToImage.cc:56–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56static void
57render_scanline_std_edge (const uint32_t *dp, unsigned int ds, const lay::Bitmap *pbitmap, unsigned int y, unsigned int w, unsigned int h, uint32_t *data)
58{
59 const uint32_t *psp = (y > 0 ? pbitmap->scanline (y - 1) : pbitmap->empty_scanline ());
60 const uint32_t *psn = (y < h - 1 ? pbitmap->scanline (y + 1) : pbitmap->empty_scanline ());
61 const uint32_t *ps = pbitmap->scanline (y);
62
63 const uint32_t *dm = dp;
64
65 unsigned int b = (y % (32 * ds));
66 bool vflag = (dp[b / 32] & (1 << (b % 32))) != 0;
67
68 uint32_t ddp = 0;
69
70 int x = int (w);
71 while (x > 0) {
72
73 uint32_t d = 0;
74 uint32_t dsn = 0, dsp = 0;
75 uint32_t ddn = 0;
76
77 if (x > int (lay::wordlen)) {
78 d = *ps++;
79 dsn = *psn++;
80 dsp = *psp++;
81 ddn = *ps;
82 } else {
83 d = *ps;
84 dsn = *psn;
85 dsp = *psp;
86 if (x < int (lay::wordlen)) {
87 d &= ((1 << x) - 1);
88 }
89 }
90
91 // di selects the inner bits - such that have a left, right neighbor
92 uint32_t dhn1 = (d & ((d >> 1) | ((ddn & 1) << 31)));
93 uint32_t dhn2 = (d & ((d << 1) | ((ddp >> 31) & 1)));
94 uint32_t dhi = dhn1 & dhn2;
95 uint32_t dhn = dhn1 | dhn2;
96
97 // dvi selects the vertically inner bits - such that have a top and botton neighbor
98 uint32_t dvn1 = dsn & d;
99 uint32_t dvn2 = dsp & d;
100 uint32_t dvi = dvn1 & dvn2;
101 uint32_t dvn = dvn1 | dvn2;
102
103#if 1
104 /*
105 NOTE: this solution is ugly for lines with angles a little away from 45 degree
106 like 30..40 and 50..60 degree.
107 This is the truth table of the various combinations of bits that are
108 encountered. Each combination gets horizontal or vertical bit masks.
109 This is basically an edge detection algorithm.
110 The diagonal pixels are not considered currently.
111
112 configuration use mask dhi dvi dhn dvn
113 --------------------------------------------------

Callers 3

create_precursor_bitmapsFunction · 0.85
bitmaps_to_imageFunction · 0.85
bitmap_to_bitmapFunction · 0.85

Calls 1

scanlineMethod · 0.60

Tested by

no test coverage detected