Changeset 2058 for libcaca/trunk/csharp
- Timestamp:
- Nov 25, 2007, 6:12:59 PM (13 years ago)
- Location:
- libcaca/trunk/csharp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/csharp/AssemblyInfo.cs
r2044 r2058 1 1 /* 2 * AssemblyInfo 2 * AssemblyInfo .NET bindings for libcaca 3 3 * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> 4 4 * All Rights Reserved -
libcaca/trunk/csharp/Caca.cs
r2052 r2058 1 1 /* 2 * libcaca .NET bindings for libcaca2 * libcaca .NET bindings for libcaca 3 3 * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> 4 * 2007 Sam Hocevar <sam@zoy.org> 4 5 * All Rights Reserved 5 6 * -
libcaca/trunk/csharp/Cucul.cs
r2046 r2058 1 1 /* 2 * libcucul .NET bindings for libcucul2 * libcucul .NET bindings for libcucul 3 3 * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> 4 * 2007 Sam Hocevar <sam@zoy.org> 4 5 * All Rights Reserved 5 6 * … … 348 349 349 350 /* frame handling */ 350 /* FIXME: clean up this shit */351 351 352 352 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 353 353 SuppressUnmanagedCodeSecurity] 354 354 private static extern int cucul_get_frame_count(IntPtr cv); 355 public int getFrameCount() 356 { 357 return cucul_get_frame_count(_cv); 358 } 359 355 360 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 356 361 SuppressUnmanagedCodeSecurity] 357 362 private static extern int cucul_set_frame(IntPtr cv, int f); 363 public int setFrame(int f) 364 { 365 return cucul_set_frame(_cv, f); 366 } 367 358 368 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 359 369 SuppressUnmanagedCodeSecurity] … … 362 372 SuppressUnmanagedCodeSecurity] 363 373 private static extern int cucul_set_frame_name(IntPtr cv, string n); 374 public string frameName 375 { 376 get { return cucul_get_frame_name(_cv); } 377 set { cucul_set_frame_name(_cv, value); } 378 } 379 364 380 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 365 381 SuppressUnmanagedCodeSecurity] 366 382 private static extern int cucul_create_frame(IntPtr cv, int f); 383 public int createFrame(int f) 384 { 385 return cucul_create_frame(_cv, f); 386 } 387 367 388 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 368 389 SuppressUnmanagedCodeSecurity] 369 390 private static extern int cucul_free_frame(IntPtr cv, int f); 370 371 public int getFrameCount()372 {373 return cucul_get_frame_count(_cv);374 }375 376 public int setFrame(int f)377 {378 return cucul_set_frame(_cv, f);379 }380 381 public string getFrameName()382 {383 return cucul_get_frame_name(_cv);384 }385 386 public int setFrameName(string n)387 {388 return cucul_set_frame_name(_cv, n);389 }390 391 public int createFrame(int f)392 {393 return cucul_create_frame(_cv, f);394 }395 396 391 public int freeFrame(int f) 397 392 { 398 393 return cucul_free_frame(_cv, f); 394 } 395 396 /* bitmap dithering */ 397 398 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 399 SuppressUnmanagedCodeSecurity] 400 private static extern int cucul_dither_bitmap(IntPtr c, int x, int y, 401 int w, int h, 402 IntPtr d, IntPtr data); 403 public int ditherBitmap(int x, int y, int w, int h, CuculDither d, 404 object data) 405 { 406 GCHandle gch = GCHandle.Alloc(data); 407 int ret = cucul_dither_bitmap(_cv, x, y, w, h, d._dither, 408 gch.AddrOfPinnedObject()); 409 gch.Free(); 410 return ret; 399 411 } 400 412 } … … 436 448 public unsafe class CuculDither : IDisposable 437 449 { 438 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 439 SuppressUnmanagedCodeSecurity] 440 private static extern IntPtr cucul_create_dither(int bpp, int w, 441 int h, int pitch, 442 Int64 rmask, 443 Int64 gmask, 444 Int64 bmask, 445 Int64 amask); 446 450 public readonly IntPtr _dither; 451 452 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 453 SuppressUnmanagedCodeSecurity] 454 private static extern IntPtr cucul_create_dither(int bpp, int w, 455 int h, int pitch, 456 ulong rmask, 457 ulong gmask, 458 ulong bmask, 459 ulong amask); 460 public CuculDither(int bpp, int w,int h, int pitch, 461 uint rmask, uint gmask, uint bmask, uint amask) 462 { 463 _dither = cucul_create_dither(bpp, w, h, pitch, 464 rmask, gmask, bmask, amask); 465 } 466 467 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 468 SuppressUnmanagedCodeSecurity] 469 private static extern int cucul_free_dither(IntPtr d); 470 public void Dispose() 471 { 472 cucul_free_dither(_dither); 473 GC.SuppressFinalize(this); 474 } 475 476 /* TODO: fix this shit */ 447 477 448 478 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), … … 487 517 SuppressUnmanagedCodeSecurity] 488 518 private static extern string[] cucul_get_dither_mode_list(IntPtr d); 489 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 490 SuppressUnmanagedCodeSecurity] 491 private static extern int cucul_free_dither(IntPtr d); 492 493 /* FIXME [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 494 SuppressUnmanagedCodeSecurity] 495 int cucul_dither_bitmap(Canvas c, int x, int y, int w , int y, 496 IntPtr d2, void *);*/ 497 498 IntPtr _dither; 499 500 public CuculDither(int bpp, int w,int h, int pitch, 501 Int64 rmask, Int64 gmask,Int64 bmask, Int64 amask) 502 { 503 _dither = cucul_create_dither(bpp, w, h, pitch, rmask, gmask, bmask, amask); 504 } 505 506 public void Dispose() 507 { 508 cucul_free_dither(_dither); 509 GC.SuppressFinalize(this); 510 } 519 511 520 512 521 public int setBrightness(float b) -
libcaca/trunk/csharp/test.cs
r2052 r2058 1 1 /* 2 * Test .NET bindings test program2 * Test .NET bindings test program 3 3 * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> 4 * 2007 Sam Hocevar <sam@zoy.org> 4 5 * All Rights Reserved 5 6 * … … 15 16 16 17 using System; 18 using System.Runtime.InteropServices; 17 19 18 20 using Cucul; … … 21 23 class DemoCanvas : CuculCanvas 22 24 { 25 private uint[,] table; 26 23 27 private DateTime startTime; 28 private CuculDither d; 24 29 25 30 public DemoCanvas() 26 31 { 27 32 startTime = DateTime.Now; 33 34 table = new uint[16,16]; 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); 28 39 } 29 40 … … 34 45 35 46 Clear(); 47 48 ditherBitmap(0, 0, width, height, d, table); 36 49 37 50 setColorAnsi(Libcucul.WHITE, Libcucul.BLACK);
Note: See TracChangeset
for help on using the changeset viewer.