-
Content Count
920 -
Joined
-
Last visited
-
Days Won
56
Everything posted by pyscripter
-
August 2020 GM Blog post
pyscripter replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
It refers to the intention to promote Python4Delphi as a means of bringing Python and Delphi closer together: Python for Delphi (P4D) is a set of free components that wrap up the Python dll into Delphi and Lazarus (FPC). They let you easily execute Python scripts, create new Python modules and new Python types. You can create Python extensions as dlls and much more. P4D provides different levels of functionality: Low-level access to the python API High-level bi-directional interaction with Python Access to Python objects using Delphi custom variants (VarPyth.pas) Wrapping of Delphi objects for use in python scripts using RTTI (WrapDelphi.pas) Creating python extension modules with Delphi classes and functions P4D makes it very easy to use python as a scripting language for Delphi applications. It comes with an extensive range of demos and tutorials. -
Java terminology... https://www.programcreek.com/2011/12/monitors-java-synchronization-mechanism/
-
High-level interface-based encapsulation of Direct2D Svg functionality
pyscripter replied to pyscripter's topic in Windows API
@Attila KovacsThanks. Just replace D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT with $00000004. And of course both LPCWSTR and LPWSTR are cast to PWideChar. But you are right! I would like to add that the purpose of Winapi.D2DMissing is not to provide for the missing D2D API, but to include just enough to serve the purpose of handling svg files. Warning: there are many translation errors in the the parts not used in this project. "TOSVersion.Build returns 0 on my system". Any idea why? Is this a Delphi bug? A more reliable way would be: if Supports(RenderTarget, ID2D1DeviceContext5) then //Supported But that would involve creating the Factory and the Render Target. Any other suggestions? -
High-level interface-based encapsulation of Direct2D Svg functionality
pyscripter replied to pyscripter's topic in Windows API
The attached fixes both issues. Svg.zip -
High-level interface-based encapsulation of Direct2D Svg functionality
pyscripter replied to pyscripter's topic in Windows API
Thanks. The aim is to integrate it with https://github.com/EtheaDev/SVGIconImageList -
Is there a way to check whether the Windows version is 10 with the Creators Update or later installed, using the RTL? I know that Jcl provides support for that.
-
In Jcl there is something called Windows10ReleaseId (1703 for Creators Update). Is this same as the build number? (I think not)
-
If you do it on the Root it works as expected.
-
@Mahdi Safsafi You are my hero!
-
@Attila Kovacs RecolorSubtree(Root, D2D1ColorF(0.5, 80, 80, 80)); does not make sense The Values need to be between 0 and 1 for instance. D2D1ColorF(clRed) = D2D1ColorF(1,0,0,1) I will doing drawing in GrayScale. Does anyone know how to draw the svg with opacity say 0.5? Everything not just the fill color possibly using D2D primitives?
-
@Kas Ob.order which is the same as shown by IDA works here. I can recolor both ways: if Succeeded(Element.GetAttributeValue('fill', D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR, @OldColor, SizeOf(OldColor))) then begin if (OldColor.r <> 0) or (OldColor.g <> 0) or (OldColor.b <> 0) then Assert(Succeeded(Element.SetAttributeValue('fill', D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR, @NewColor, SizeOf(NewColor)))); end; and Assert(Succeeded(Element.GetAttributeValue('fill', IID_ID2D1SvgPaint, Pointer(Paint)))); if Assigned(Paint) then begin Paint._AddRef; if Paint.GetPaintType = D2D1_SVG_PAINT_TYPE_COLOR then begin Paint.GetColor(OldColor); if (OldColor.r <> 0) or (OldColor.g <> 0) or (OldColor.b <> 0) then Paint.SetColor(NewColor); end; end; end; The declaration of SetColor needs to be changed: function SetColor(Const color: D2D1_COLOR_F): HResult; stdcall;
-
The functions seem to work now (Succeeded) but still no recoloring though). What is strange is that the order of the overloads in the VTable is the reverse than that in the include file. What is the tool you are using to inspect the Vtables?
-
It does not recolor here. Could you please post your project.
-
This is the one I was getting before at $78 I think. Also when I call it using the commented code it does not succeed. Assert(Succeeded( Element.GetAttributeValue('fill', IID_ID2D1SvgPaint, Pointer(Paint)) )) fails. It does not appear to be in the right order now. Do you get the recoloring to work.
-
@Mahdi Safsafi Amazing stuff. Questions: There are many more overloads in the include file implemented as inline functions. Do those interfere with the above? After the first set of Set/GetAttributeValue there is a GetAttributeValueLength function. Does this comes last? It was just by accident that my GetAttributeCall was picking the correct overload!! That really confused me.
-
Thanks for your efforts...
-
Impressive guess work!
-
Thanks, but this is puzzling. at $7C is the GetAttributeValue, which I know it works and at $78 should be the one before. (right?). In the include file the function before the GetAttributeValue is the relevant SetAttributeValue. How can I find the correct order?
-
Wow. I was using the order in the include file. What exactly is the order that works? Could you please post the relevant section of the file or the file as a whole?
-
I have tried to used the method used in the sample see the commented out code: Assert(Succeeded( Element.GetAttributeValue('fill', IID_ID2D1SvgPaint, Pointer(Paint)) )); but that did not work either. So I then tried to use a different overload to get the color and that worked. But setting it back produces the crash.
-
There is not much in the internet, just a Microsoft sample at https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/D2DSvgImage/cpp which I am following. But the element works fine with GetAttributeValue call. So it should be OK.
-
The value of OldColor returned by GetAttributeValue is right. (I have a simple svg file and checked with the contents of the file). So GetAttributeValue works fine. Access violation at 0x75db8cbx read of address 0x000000001 D2D1_SVG_ATTRIBUTE_POD_TYPE = DWord; {$EXTERNALSYM D2D1_SVG_ATTRIBUTE_POD_TYPE} const // The attribute is a D2D1_COLOR_F. D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR = D2D1_SVG_ATTRIBUTE_POD_TYPE(1); I did check that the correct overload is called. (looked at the assembly code calliing the function: call dword ptr [eax+$7c] for GetAttributeValue , dword ptr [eax+$78] for SetAttributeValue , tripled checked with the C header file order of interface members etc). MSDN description of SetAttributeValue overload used. I am attaching the project source code in case anyone wants to have a go. The display of svg files works fine and now without using Vcl.Direct2D. Svg.zip d2d1svg.h
-
OldColor: TD2D1ColorF; //works with correct results if Succeeded(Element.GetAttributeValue('fill', D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR, @OldColor, SizeOf(OldColor))) // Crashes Access violation Element.SetAttributeValue('fill', D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR, @OldColor, SizeOf(OldColor)); D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR = 1 The prolog of the two functions differ. Doesn't this mean the declaration should be different? But I am not sure what SetAttributeValue expects
-
For comparison the following method is GetAttributeValue: /// <summary> /// Gets an attribute of this element as a POD type. Returns an error if the /// attribute is not specified. Returns an error if the attribute name is not valid /// on this element. Returns an error if the attribute cannot be expressed as the /// specified POD type. /// </summary> STDMETHOD(GetAttributeValue)( _In_ PCWSTR name, D2D1_SVG_ATTRIBUTE_POD_TYPE type, _Out_writes_bytes_(valueSizeInBytes) void *value, UINT32 valueSizeInBytes ) PURE; which I am successfully using by translating to (same parameters) function GetAttributeValue(name: LPWSTR; _type: D2D1_SVG_ATTRIBUTE_POD_TYPE; value: Pointer; valueSizeInBytes: UINT32): HResult; overload; stdcall; However the prolog of GetAttributeValue is different: 564713C0 6690 nop 564713C2 55 push ebp 564713C3 8BEC mov ebp,esp 564713C5 83EC24 sub esp,$24 564713C8 8B4D08 mov ecx,[ebp+$08] 564713CB 53 push ebx 564713CC 8BD9 mov ebx,ecx 564713CE 56 push esi 564713CF 8D4108 lea eax,[ecx+$08] 564713D2 33C9 xor ecx,ecx 564713D4 85C0 test eax,eax 564713D6 57 push edi 564713D7 0F44D9 cmovz ebx,ecx 564713DA 6A08 push $08 564713DC 5A pop edx