Changeset 2076 for libcaca/trunk/csharp
- Timestamp:
- Nov 26, 2007, 2:04:36 AM (13 years ago)
- Location:
- libcaca/trunk/csharp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/csharp/Caca.cs
r2065 r2076 22 22 namespace Caca 23 23 { 24 /* Static libcaca stuff that does not fit in any object */ 25 public static class Libcaca 26 { 27 [DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), 28 SuppressUnmanagedCodeSecurity] 29 private static extern IntPtr caca_get_version(); 30 public static string getVersion() 31 { 32 return Marshal.PtrToStringAnsi(caca_get_version()); 33 } 34 } 35 24 36 public enum CacaEventType 25 37 { … … 149 161 { 150 162 caca_get_event_key_utf8(cevent, utf8); 151 return Marshal.PtrToString Uni(utf8);163 return Marshal.PtrToStringAnsi(utf8); 152 164 } 153 165 } -
libcaca/trunk/csharp/Cucul.cs
r2065 r2076 26 26 SuppressUnmanagedCodeSecurity] 27 27 private static extern int cucul_rand(int min, int max); 28 29 28 public static int Rand(int min, int max) 30 29 { 31 30 return cucul_rand(min, max); 31 } 32 33 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 34 SuppressUnmanagedCodeSecurity] 35 private static extern IntPtr cucul_get_version(); 36 public static string getVersion() 37 { 38 return Marshal.PtrToStringAnsi(cucul_get_version()); 32 39 } 33 40 -
libcaca/trunk/csharp/test.cs
r2058 r2076 34 34 table = new uint[16,16]; 35 35 d = new CuculDither(32, 16, 16, 16 * 4, 0xff0000, 0xff00, 0xff, 0x0); 36 for(int y = 0; y < 16; y++)37 for(int x = 0; x < 16; x++)38 table[x,y] = (uint)((x + y) << 16) | (uint)(x << 8) | (uint)(y);39 36 } 40 37 … … 46 43 Clear(); 47 44 45 double cos = Math.Cos(t / 500.0); 46 double sin = Math.Sin(t / 500.0); 47 48 for(int y = 0; y < 16; y++) 49 for(int x = 0; x < 16; x++) 50 { 51 double xt = (double)(x - 8); 52 double yt = (double)(y - 8); 53 int x2 = (int)(xt * cos + yt * sin + 8.0); 54 int y2 = (int)(xt * sin - yt * cos + 8.0); 55 if(x2 < 0) x2 = 0; 56 if(y2 < 0) y2 = 0; 57 58 table[x,y] = (uint)((x2 + y2) << 16) 59 | (uint)(x2 << 8) 60 | (uint)(y2); 61 } 48 62 ditherBitmap(0, 0, width, height, d, table); 49 63 … … 103 117 public static void Main() 104 118 { 105 Console.WriteLine("libcaca .NET test");119 Console.WriteLine("libcaca {0} .NET test", Libcaca.getVersion()); 106 120 Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>"); 107 121
Note: See TracChangeset
for help on using the changeset viewer.