Re: How to call a GDI+ function from D ?

2022-06-05 Thread Vinod K Chandran via Digitalmars-d-learn

On Sunday, 5 June 2022 at 11:33:14 UTC, Vinod K Chandran wrote:




For future readers of this thread, rikki cattermole helped me to 
findthe solution to this problem. I Do not need the C++ classes 
or their methods for this. There is a set of C functions in 
gdiplus.dll. Check this link. 
https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-flatapi-flat





Re: How to call a GDI+ function from D ?

2022-06-05 Thread Vinod K Chandran via Digitalmars-d-learn

On Sunday, 5 June 2022 at 10:57:16 UTC, rikki cattermole wrote:

Bitmap is a class, not a namespace.

The function you want is actually a constructor.

https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-headers/include/gdiplus/gdiplusheaders.h#L179


Thank you for the reply. Well, I know that it is a CTOR. But I 
thought this is the D way to call it.


Re: How to call a GDI+ function from D ?

2022-06-05 Thread rikki cattermole via Digitalmars-d-learn

Bitmap is a class, not a namespace.

The function you want is actually a constructor.

https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-headers/include/gdiplus/gdiplusheaders.h#L179


How to call a GDI+ function from D ?

2022-06-05 Thread Vinod K Chandran via Digitalmars-d-learn

Hi all,
I want to call the Bitmap function from gdi+. This is the syntax 
of the function in C++.

```c++
void Bitmap(
  [in] const WCHAR *filename,
  [in] BOOLuseEmbeddedColorManagement
);
```
And this is the mangled name which I got from goldbolt compiler.
`?Bitmap@@YAXPEB_WH@Z `

Now, this is my declaration in D.
```d
extern (C++, "Bitmap") void * Bitmap(const(wchar)* file, BOOL 
useClr);

```
And this is my call site.
```d
auto imgPath = toUTF16z(r"C:\Users\AcerLap\Pictures\Saved 
Pictures\d3.png") ;

auto pBmp = Bitmap(imgPath, FALSE);
```
But I got this error message.
```
app.obj : error LNK2019: unresolved external symbol "void * 
__cdecl Bitmap::Bitmap(char16_t const *,int)" 
(?Bitmap@0@YAPAXPB_SH@Z) referenced in function 
__D4wing9imagelist9ImageList8addImageMFAyaZv

app.exe : fatal error LNK1120: 1 unresolved externals
Error: linker exited with status 1120
```
You see, the mangled names are different.
From D - `?Bitmap@0@YAPAXPB_SH@Z`
From C++ - `?Bitmap@@YAXPEB_WH@Z`
How to fix this ?