Looks like I'm becoming a "regular contributor" to this list...

I don't find it easy to figure out C# signature for all the lcms C
functions...

The original  C function looks like this :      

cmsUInt32Number    cmsGetProfileInfo(
        cmsHPROFILE hProfile, 
        cmsInfoType Info, 
        const char LanguageCode[3], 
        const char CountryCode[3], 
        wchar_t* Buffer, 
        cmsUInt32Number BufferSize);

The "best" DLLImport I could come up with, in C# is this :

[DllImport(@lcms2Path, CharSet = CharSet.Unicode)]
                public extern static UInt32 cmsGetProfileInfo(
                IntPtr hProfile,
                int InfoType, 
                [MarshalAs(UnmanagedType.BStr)]string languageCode,  //
UnmanagedType.BStr = A COM-style BSTR with a prefixed length and Unicode
characters.
                [MarshalAs(UnmanagedType.BStr)]string countryCode,  
                [Out, MarshalAsAttribute(UnmanagedType.LPWStr)]
StringBuilder buffer,  
                UInt32 bufferSize);

And, in code, I call the function like this :

StringBuilder Buffer = new StringBuilder(255);
UInt32 Buffer=0;
UInt32 descSize;
descSize = cmsGetProfileInfo(hSource, 0, "en", "US", Buffer, 0);

When I execute the function, descSize = 0 and Buffer is empty...

----

I also tried this Import statement :

                [DllImport(@lcms2Path, CharSet = CharSet.Unicode)]
                public extern static UInt32 cmsGetProfileInfo(
                IntPtr hProfile,
                [In] int InfoType,
                [In] string languageCode,  // UnmanagedType.BStr = A
COM-style BSTR with a prefixed length and Unicode characters.
                [In] string countryCode,
                [Out] StringBuilder buffer,
                [Out] UInt32 bufferSize); 

But don't get any better?

For curiosity, I also tried the following in C :

        wchar_t* Buffer;
        cmsUInt32Number BufferSize, DescSize;
        BufferSize = 0;

        Buffer = NULL;

        cmsInfoType Info;

        Info = cmsInfoDescription;

        DescSize  = cmsGetProfileInfo(rgbProfile, Info, "en", "US", Buffer,
BufferSize);

When I execute the function, DescSize = 20 but Buffer is null and BufferSize
= 0.

/ Roger


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to