DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: jeff1314
今日帖子: 22
在线用户: 11
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2020/12/1 2:33:37
标题:
SVG and Delphi support in RAD Studio 10.3 and 10.4 on GitHub projects 浏览:1240
加入我的收藏
楼主: by pyscripter from DelphiPraxis forum

I am not sure many know that since the Windows Creators update, svg parsing and painting is natively supported and is part of Direct2D.  I wanted to test this Windows feature, however, the first obstacle was that the Direct2d headers that come with Delphi are very very old.  There are two open tickets in 

https://quality.embarcadero.com/.

Direct2D 1.1 support missing (open since XE7!)
https://quality.embarcadero.com/browse/RSP-10159

Direct2D 1.2 and 1.3 support missing
https://quality.embarcadero.com/browse/RSP-21071

SVG parsing and painting is natively supported and is part of Direct2D since MS Windows Creators
https://docs.microsoft.com/en-us/windows/win32/direct2d/svg-support

You may want to vote for them, since lack of good Direct2D support (includes DirectWrite) it is a bit of a shame.

I then looked at other Direct2D translations and found two that are regularly updated. 
https://github.com/FactoryXCode/MfPack/tree/Master/MfPack
https://github.com/CMCHTPC/DelphiDX12

They both had some issues but that was a good start.  It turned out that parsing and painting svg files to Canvas is quite straightforward.  Once you establish a renderer (Vcl.Direct2d does this, but it is easy to do it from scratch) you can do everything with two lines of code.

fDeviceContext5.CreateSvgDocument(fStream,D2D1SizeF(ClientWidth, ClientHeight),fsvgDocument);
fDeviceContext5.DrawSvgDocument(fsvgDocument);

You can check whether Svg is supported by:

if Supports( rt, ID2D1DeviceContext5, fDeviceContext5) then
...

And it is easy to do things like scaling, opacity, rotation, recoloring etc.  The quality and speed appear to be quite good, but there are some limitations, the most important of which I think is the lack of support for the text element.  I am attaching the source code of my test project (no dependencies) in case anyone wants to play with it.  The Svg scales automatically as you resize the form.

https://en.delphipraxis.net/applications/core/interface/file/attachment.php?id=2648

About Affinity Suite tool for SVG creating
https://youtu.be/UVqJIaMlB6E

TMS VCL UIPack support SVG
GitHub projects for SVG support

https://github.com/EtheaDev/SVGIconImageList
https://github.com/EtheaDev/IconFontsImageList
https://github.com/publicjoke/freepascal_resvg

SVGIconImageList: Now it's possible also to use native VirtualImageList (from 10.3 or 10.4) linked to a TSVGIconImageCollection!
If you have an older Delphi version you can use TSVGIconsVirtualImageList.

按此在新窗口浏览图片
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行62.5毫秒 RSS