I am using Visual C# 2015 with .NET.
Made the lcms2.dll without any problem, and also half-made a new lcms2
"header" for my C# project.
Most of the functions works fine - i can open and close profiles; get the
infos from them, etc. -, but i cannot program the InputBuffer and OutputBuffer
of the function *cmsDoTransform* in the right way.
If anybody familiar with this problem, please help me.
Here is a simple working example of the cmsGetProfileInfo function declaration:
[DllImport("lcms2.dll")]
public static extern UInt32 cmsGetProfileInfo(IntPtr hProfile, int
InfoType, string LanguageCode, string CountryCode,
[MarshalAsAttribute(UnmanagedType.LPWStr)] StringBuilder Buffer, int
BufferSize);
And like most of the other functions its works nice.
But i stucked in cmsDoTransform, and don't know what would be the ideal
declaration and usage. (Unmanaged Marshal attributes are one path, i tried a
few variations of it without any succes)
E.g.:
[DllImport("lcms2.dll")]
public static extern void cmsDoTransform(IntPtr hTransform, IntPtr
InputBuffer, IntPtr OutputBuffer,UInt32 Size);
or
[DllImport("lcms2.dll")]
public static extern void cmsDoTransform(IntPtr hTransform, char[]
InputBuffer, char[] OutputBuffer,UInt32 Size);
For pixel manipulation i use the following code:
Bitmap Source = new Bitmap("test.jpg", true);
Bitmap Target = new Bitmap(Source.Width, Source.Height,
PixelFormat.Format32bppArgb);
Rectangle r1 = new Rectangle(0, 0, Source.Width, Source.Height);
BitmapData sourceData = Source.LockBits(r1, ImageLockMode.ReadOnly,
sourcePixelFormat);
BitmapData targetData = Target.LockBits(r1, ImageLockMode.WriteOnly,
sourcePixelFormat);
IntPtr sourcePtr = sourceData.Scan0;
IntPtr targetPtr = targetData.Scan0;
int bytesPerPixel = ColorDepth / 8;
int bytes = Source.Width * bytesPerPixel * Source.Height;
byte[] colorValues = new byte[bytes];
Marshal.Copy(sourcePtr, colorValues, 0, bytes);
// Do stuffs here, like:
// cmsDoTransform(hTransform, sourcePtr, targetPtr, bytes); - Or using the
colorValues array, or ???
Marshal.Copy(colorValues, 0, targetPtr, bytes);
Source.UnlockBits(sourceData);
Target.UnlockBits(targetData);
...
During debug, i always got memory error on the second and third argument of
the cmsDoTransform function.
*Tamas*
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user