i'm very confused and the others forums make me more confused :(
i'm using string, so i need convert string to WCHAR*:

const size_t len = filename.length() + 1;
            wchar_t wcstring[len];
            swprintf(wcstring, len, L"%s", filename.c_str());

            Gdiplus::Image img2(wcstring);

the img2 read the file normaly, but i'm creating another Image variable in class private section:

class image
{
private:
    ULONG_PTR m_gdiplusToken;
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    HDC hdcimage=CreateCompatibleDC(NULL);
    Gdiplus::Graphics graphics;
    Gdiplus::Image img;
    ///................

but for work in image constructors i must do(or i get several errors):

public:
    image() : graphics(hdcimage),img((WCHAR*)(L"C:\\"))
    {
    //..................

but for string:

image(  const string & filename)  : graphics(hdcimage),img(towstring(filename))
    {
    //.............

i'm getting errors:
"call of overloaded 'Image(wchar_t)' is ambiguous"
why?? see my function:

wchar_t towstring(const std::string& s)
{
    wchar_t Wstring;
    int c =  MultiByteToWideChar( CP_UTF8 , 0 , s.c_str() , s.size() , &Wstring, 0 );
    return Wstring;
}

i'm confused from information that gevi me :(
so what is 'WCHAR'? how can i convert it to string?
i'm sorry, but i'm several confused with these :(

At a guess, it's because you are passing the GdiPlus::Image class constructor (for the img member of your image class) a wchar_t when it wants a pointer to wchar_t, a WCHAR*.

Have you tried this:

image(  const string & filename)  : graphics(hdcimage),img(&(towstring(filename)))
    {
    //.............

That will pass the address of the wchar_t returned by your towstring function. Effectively converting it to a WCHAR* that I am fairly certain the GdiPlus::Image class will be able to accept as a parameter in its constructor.

I could be wrong, but it's probably worth a shot! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.