Jump to content
Sign in to follow this  
pyscripter

Translation of C headers.

Recommended Posts

2 minutes ago, Attila Kovacs said:

yippiii, it works. nice one @Mahdi Safsafi

It does not recolor here.   Could you please post your project.

Share this post


Link to post
20 minutes ago, Mahdi Safsafi said:

Those are not stored inside vtable ... you need to skip them(don't declare them).

Exactly! 

That's my bad man ... I'm a little bit bad at explaining since I'm not a native English speaker.

First step, add all methods in the order they declared(skip all overloaded versions but keep the original). second step for each added method "A" add just after it "A" all its overloaded versions in the order they declared too.

Here is how your vtable looks like.

 

vtbl.PNG

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?

Share this post


Link to post
Posted (edited)

@pyscripter d2missing again without the reformatting, sorry 😉

D2DMissing.7z

 

btw. he is using IDA

 

btw2. RecolorSubtree(Root, D2D1ColorF(1, 0, 0, 0)); should be the other way, 0,0,0,1, rgba

Edited by Attila Kovacs

Share this post


Link to post

This is the right order as Mahdi shown and this will recolor and get the Paint item right, @Attila Kovacs your last file still reversed.

Quote

    function SetAttributeValue(name: LPWSTR;
                               value: ID2D1SvgAttribute): HResult; overload; stdcall;
    function SetAttributeValue(name: LPWSTR;
                               _type: D2D1_SVG_ATTRIBUTE_POD_TYPE;
                               value: Pointer;
                               valueSizeInBytes: UINT32): HResult; overload; stdcall;
     function SetAttributeValue(name: LPWSTR;
                               _type: D2D1_SVG_ATTRIBUTE_STRING_TYPE;
                               value: LPWSTR): HResult; overload; stdcall;


    function GetAttributeValue(name: LPWSTR;
                               const riid: TGUID;
                               var value: Pointer): HResult; overload; stdcall;

    function GetAttributeValue(name: LPWSTR;
                               _type: D2D1_SVG_ATTRIBUTE_POD_TYPE;
                               value: Pointer;
                               valueSizeInBytes: UINT32): HResult; overload; stdcall;
    function GetAttributeValue(name: LPWSTR;
                               _type: D2D1_SVG_ATTRIBUTE_STRING_TYPE;
                               out value: PWideChar;
                               valueCount: UINT32): HResult; overload; stdcall;

 

  • Like 1

Share this post


Link to post
Posted (edited)

@Kas Ob. your version AV's here, I get the recoloring 😄 what now

 

hm, sorry, it works, so declare in reverse order?

 

image.png.66c8f571a550463e6727f8f7b260b98a.png

Edited by Attila Kovacs

Share this post


Link to post
Posted (edited)

@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;

 

Edited by pyscripter

Share this post


Link to post

@Kas Ob. is right. With his order this works too:

 

      Element.SetAttributeValue('fill', D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, '#FF0000');

Share this post


Link to post
Posted (edited)

@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?

 

Edited by pyscripter

Share this post


Link to post
Posted (edited)

@pyscripter yup, was just playing around, it's also RGBA so the original 1, 0, 0, 0 did also not make much sense, mentioned that already earlier

Edited by Attila Kovacs

Share this post


Link to post
18 minutes ago, pyscripter said:

Does anyone know how to draw the svg with opacity say 0.5?  Everything not just the fill color possibly using D2D primitives?

      opacity : single := 0.5;
      Element.SetAttributeValue('opacity', D2D1_SVG_ATTRIBUTE_POD_TYPE_FLOAT, @opacity, SizeOf(opacity));
      where element = 'svg'

 

 if this was the question

  • Thanks 1

Share this post


Link to post
7 minutes ago, Attila Kovacs said:

Element.SetAttributeValue('opacity', D2D1_SVG_ATTRIBUTE_POD_TYPE_FLOAT, @opacity, SizeOf(opacity));

If you do it on the Root it works as expected.

Share this post


Link to post
Posted (edited)

btw. in the header and also on the screenshot from Mahdi the first parameters are PCWSTR (LPCWSTR) (const) and not always PWSTR (LPWSTR).

this however makes no difference, at least at the moment, as they are defined the same in delphi 

Edited by Attila Kovacs
  • Like 1

Share this post


Link to post
20 minutes ago, Attila Kovacs said:

btw. in the header and also on the screenshot from Mahdi the first parameters are PCWSTR (LPCWSTR) (const) and not always PWSTR (LPWSTR).

this however makes no difference, at least at the moment, as they are defined the same in delphi 

Good point Attila. It also makes comparing c code against Delphi code much easy. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×