瀏覽代碼

* Added preliminary dither support to .NET bindings

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 18 年之前
父節點
當前提交
00733ed08f
共有 2 個文件被更改,包括 135 次插入10 次删除
  1. +126
    -4
      DotNet/Cucul.cs
  2. +9
    -6
      DotNet/test.cs

+ 126
- 4
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);
}
/* <FIXME> */
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);
}
/* </FIXME> */

}












}


+ 9
- 6
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);


Loading…
取消
儲存