diff --git a/DotNet/Cucul.cs b/DotNet/Cucul.cs index 041a669..a23384e 100644 --- a/DotNet/Cucul.cs +++ b/DotNet/Cucul.cs @@ -319,17 +319,139 @@ namespace libCucul } + /* Privates methods, are not meant to be called by user*/ + + public IntPtr get_cucul_t() + { + return qq; + } + } + public unsafe class Dither : IDisposable + { + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern IntPtr cucul_create_dither(Int32 bpp, Int32 w, + Int32 h, Int32 pitch, + Int64 rmask, + Int64 gmask, + Int64 bmask, + Int64 amask); - /* Privates methods, are not meant to be called by user*/ - - public IntPtr get_cucul_t() + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_palette(IntPtr d, + Int32[] r, Int32[] g, + Int32[] b, Int32[] a); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_brightness(IntPtr d, float b); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_gamma(IntPtr d, float g); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_contrast(IntPtr d, float c); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_invert(IntPtr d, int i); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_antialias(IntPtr d, string s); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern string[] cucul_get_dither_antialias_list(IntPtr d); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_color(IntPtr d, string s); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern string[] cucul_get_dither_color_list(IntPtr d); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_charset(IntPtr d, string s); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern string[] cucul_get_dither_charset_list(IntPtr d); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_dither_mode(IntPtr d, string s); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern string[] cucul_get_dither_mode_list(IntPtr d); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_free_dither(IntPtr d); + + /* FIXME [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + Int32 cucul_dither_bitmap(Cucul c,Int32 x, Int32 y, Int32 w , Int32 y, + IntPtr d2, void *);*/ + + + + IntPtr dither; + + public Dither(Int32 bpp, Int32 w,Int32 h, Int32 pitch, + Int64 rmask, Int64 gmask,Int64 bmask, Int64 amask) { - return qq; + dither = cucul_create_dither(bpp, w, h, pitch, rmask, gmask, bmask, amask); + } + public void Dispose() + { + cucul_free_dither(dither); + GC.SuppressFinalize(this); + } + public Int32 setBrightness(float b) + { + return cucul_set_dither_brightness(dither, b); + } + public Int32 setGamma(float g) + { + return cucul_set_dither_gamma(dither, g); + } + public Int32 setContrast(float c) + { + return cucul_set_dither_contrast(dither, c); + } + public Int32 setInvert(Int32 i) + { + return cucul_set_dither_invert(dither, i); } + public Int32 setAntialias(string s) + { + return cucul_set_dither_antialias(dither, s); + } + public Int32 setColor(string s) + { + return cucul_set_dither_color(dither, s); + } + public Int32 setCharset(string s) + { + return cucul_set_dither_charset(dither, s); + } + public Int32 setMode(string s) + { + return cucul_set_dither_mode(dither, s); + } + /* */ + public string[] getAntialiasList() + { + return cucul_get_dither_antialias_list(dither); + } + public string[] getColorList() + { + return cucul_get_dither_color_list(dither); + } + public string[] getCharsetList() + { + return cucul_get_dither_charset_list(dither); + } + public string[] getModeList() + { + return cucul_get_dither_mode_list(dither); + } + /* */ + } + + + + + + + + + + + + } diff --git a/DotNet/test.cs b/DotNet/test.cs index 177aeaf..b2c26bc 100644 --- a/DotNet/test.cs +++ b/DotNet/test.cs @@ -26,7 +26,7 @@ class Test { /* Instanciate a cucul canvas */ Cucul qq = new Cucul(); - + /* Get size, and change it */ Console.WriteLine("Old size : {0}x{1}", qq.getWidth(), qq.getHeight()); qq.setSize(80,50); @@ -36,18 +36,21 @@ class Test { not to be used with previous instance */ Console.WriteLine("A random number : {0}", Cucul.Rand(0, 1337)); - + /* Draw stuff on our canvas */ qq.putChar(0,0, 'J'); - qq.setColor(Cucul.CUCUL_BLUE, Cucul.CUCUL_RED); qq.drawLine(10, 15, 45, 27, "#"); - qq.putStr(10, 10, "Hello from .NET"); + Console.WriteLine("Char at 0,0 : {0}", qq.getChar(0,0)); + qq.Flip(); - Console.WriteLine("Char at 0,0 : {0}", qq.getChar(0,0)); + /* Create a Dither instance */ + Dither dither = new Dither(32, 320, 200, 320, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); + dither.setBrightness((float)0.7); + string[] aalist = dither.getAntialiasList(); + Console.WriteLine("List : '{0}'", aalist[1]); - qq.Flip(); /* We have a proper canvas, let's display it using Caca */ Caca kk = new Caca(qq);