Closed mbway closed 11 months ago
I missed that new svg and pdf backends have been added that do not use matplotlib. I'll look into those soon.
btw, this PR includes the reference dxf file and the associated images which comes to ~650KiB. Is that OK or would you prefer if I remove them?
@mbway Thanks for your great work!
A future improvement would be to move the clipping of the image to the designer stage, where the viewport clipping happens. This may allow to clip the images at the viewport borders.
I suppose clipping could be moved entirely to the designer, or it could be done twice, so the frontend clips the image to its boundary and the designer clips to the active viewport (if there is one)? but that's up to you
This PR adds support for the drawing addon to draw Image entities as requested here
The approach is for the frontend to load the image and apply any effects and clipping paths by altering the pixels of the image (so the image is pre-cropped before it is sent to the backend).
This design allows the backends to be relatively simple: they are given an array containing RGBA pixels (even if the image on disk has no transparency) and a
Matrix44
indicating the transform to apply to the image when drawing it.I have implemented image rendering in Qt and matplotlib and compared to a fairly detailed reference document that a colleague prepared for me.
reference image (created in AutoCAD) ezdxf matplotlib -> pdf render (with white background / paperspace): ezdxf Qt viewer:
So as you can see from the images above, the addon now supports:
I think the support is pretty good and should cover almost all use cases but there are still some things I'm not sure about:
PIL.ImageEnhance.Brightness()
did not give the expected results when scaling the 0-100 value to 0-2PIL.ImageEnhance.Contrast()
which looks about rightSHOW_IMAGE_WHEN_NOT_ALIGNED
is to do with viewing images in 3D? This flag is currently not usedUSE_CLIPPING_BOUNDARY
is not set, act like the clipping path doesn't existDXFEntity.transparency
works as expected when applied to an Image entityThere are some limitations: