On the one hand you can have several declarations/imports of 
cmsDoTransform e.g.:
public static class NativeMethods {
        [DllImport("lcms2.dll")]
        public static extern void cmsDoTransform(
                [In] IntPtr Transform,
                [In] byte[] InputBuffer,
                [Out] byte[] OutputBuffer,
                [In] UInt32 Size);

        [DllImport("lcms2.dll")]
        public static extern void cmsDoTransform(
                [In] IntPtr Transform,
                [In] ushort[] InputBuffer,
                [Out] ushort[] OutputBuffer,
                [In] UInt32 Size);

        [DllImport("lcms2.dll")]
        public static extern void cmsDoTransform(
                [In] IntPtr Transform,
                [In] double[] InputBuffer,
                [Out] double[] OutputBuffer,
                [In] UInt32 Size);
}
on the other hand you could just use the version with byte[]:
In this case you would have to "marshal" your float/double/short data to 
byte[] yourself.
If you have some e.g. double data somewhere in a stream, file, blob, and 
c# is passing
this binary data as byte[] to you, you can use this version.

Of course you can also take a "simple" declaration with IntPtr and do some
System.Runtime.InteropServices.Marshal.PtrToStructure(), 
.StructureToPtr(), .Copy()...
before and after calling cmsDoTransform.

I prefer the first/second way

Edgar


Am 30.06.2016 um 16:41 schrieb Roger Breton:
> Edgar,
>
> Thank YOU so much!!!!
>
> One question...
>
> In the following code :
>
> public static class NativeMethods {
>       [DllImport("lcms2.dll")]
>       public static extern void cmsDoTransform(
>               [In] IntPtr Transform,
>               [In] byte[] InputBuffer,
>               [Out] byte[] OutputBuffer,
>               [In] UInt32 Size);
> }
>
> Why (warum) do you pass a pointer to a byte array (byte[])?
>
> (I understand image pixel data = bytes)
>
> I am no C# specialist BUT that makes the function "less universal" than if
> you were to pass a straight, basic 'IntPtr'?
>
> The reason I ask is, are you not limited to the type of data you can pass
> cmsDoTransform then?
>
> In my original pinvoke declaration, I use pointers to 'double[]' arrays :
> this will not work (arbeit) with your 'byte[]' declaration anymore?
>
> I was thinking of, perhaps, the solution is create a second class to host
> your cmsDoTransform function call and continue using my first cmsDoTransform
> to process individual 'double[]' data type.
>
> Is that what you do?
>
> MfG / Kindest regards,
>
> / Roger Breton
>
>
>
> ------------------------------------------------------------------------------
> 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
>

-- 
lakeBits Inh. Edgar Loser
Haydnstr. 25
78464 Konstanz
Tel 0049 7531 5844154 0
Fax 0049 7531 5844154 9
http://www.colymp.com/
mailto:lo...@colymp.com

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