MCPcopy Create free account
hub / github.com/creatale/node-dv / LineAA

Function LineAA

deps/opencv/modules/core/src/drawing.cpp:287–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285};
286
287static void
288LineAA( Mat& img, Point2l pt1, Point2l pt2, const void* color )
289{
290 int64 dx, dy;
291 int ecount, scount = 0;
292 int slope;
293 int64 ax, ay;
294 int64 x_step, y_step;
295 int64 i, j;
296 int ep_table[9];
297 int cb = ((uchar*)color)[0], cg = ((uchar*)color)[1], cr = ((uchar*)color)[2], ca = ((uchar*)color)[3];
298 int _cb, _cg, _cr, _ca;
299 int nch = img.channels();
300 uchar* ptr = img.data;
301 size_t step = img.step;
302 Size2l size(img.cols, img.rows);
303
304 if( !((nch == 1 || nch == 3 || nch == 4) && img.depth() == CV_8U) )
305 {
306 Line(img, Point((int)(pt1.x<<XY_SHIFT), (int)(pt1.y<<XY_SHIFT)), Point((int)(pt2.x<<XY_SHIFT), (int)(pt2.y<<XY_SHIFT)), color);
307 return;
308 }
309
310 pt1.x -= XY_ONE*2;
311 pt1.y -= XY_ONE*2;
312 pt2.x -= XY_ONE*2;
313 pt2.y -= XY_ONE*2;
314 ptr += img.step*2 + 2*nch;
315
316 size.width = ((size.width - 5) << XY_SHIFT) + 1;
317 size.height = ((size.height - 5) << XY_SHIFT) + 1;
318
319 if( !clipLine( size, pt1, pt2 ))
320 return;
321
322 dx = pt2.x - pt1.x;
323 dy = pt2.y - pt1.y;
324
325 j = dx < 0 ? -1 : 0;
326 ax = (dx ^ j) - j;
327 i = dy < 0 ? -1 : 0;
328 ay = (dy ^ i) - i;
329
330 if( ax > ay )
331 {
332 dx = ax;
333 dy = (dy ^ j) - j;
334 pt1.x ^= pt2.x & j;
335 pt2.x ^= pt1.x & j;
336 pt1.x ^= pt2.x & j;
337 pt1.y ^= pt2.y & j;
338 pt2.y ^= pt1.y & j;
339 pt1.y ^= pt2.y & j;
340
341 x_step = XY_ONE;
342 y_step = (dy << XY_SHIFT) / (ax | 1);
343 pt2.x += XY_ONE;
344 ecount = (int)((pt2.x >> XY_SHIFT) - (pt1.x >> XY_SHIFT));

Callers 3

FillConvexPolyFunction · 0.85
CollectPolyEdgesFunction · 0.85
ThickLineFunction · 0.85

Calls 5

clipLineFunction · 0.85
LineFunction · 0.70
PointClass · 0.50
channelsMethod · 0.45
depthMethod · 0.45

Tested by

no test coverage detected