ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.01k stars 407 forks source link

How to draw rectangle? #229

Closed mikeversteeg closed 1 year ago

mikeversteeg commented 1 year ago

I'm trying to draw a rectangle with a linewidth of 2. This works but fills the rectangle:

SimdFill(pVideo+r.Left+r.Top*iWidth, iWidth, r.Width(), r.Height(), 1, y);

so I thought I could skip the area encompassed by the rectangle like this

int width = 2;
SimdFillFrame(pVideo+r.Left+r.Top*iWidth, iWidth, r.Width(), r.Height(), 1,
      r.Left+width, r.Top+width, r.Right-width, r.Bottom-width, y);

but this gives an AV. Figuring I may have misunderstood the documentation I also tried width=-2 but that also gives an AV. The specified rectangle is well within the bounds of the video frame.

Is this a bug or am I misunderstanding the way this function works?

ermig1979 commented 1 year ago

See SimdDrawing.hpp

mikeversteeg commented 1 year ago

There's no additional information about SimdFill(or SimdFillFrame) there, only about C++ functions which I do not use.

ermig1979 commented 1 year ago

Simd implements drawing algorithms only in SimdDrawing.hpp. This implementation is not optimized and is used for debug purposes.

mikeversteeg commented 1 year ago

I know, but I did expect it to work. No problem, I now draw 4 filled rectangles to create the frame.