Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

66 строки
2.0 KiB

  1. //
  2. // libpipi Pathetic image processing interface library
  3. // Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
  4. // All Rights Reserved
  5. //
  6. // $Id$
  7. //
  8. // This library is free software. It comes without any warranty, to
  9. // the extent permitted by applicable law. You can redistribute it
  10. // and/or modify it under the terms of the Do What The Fuck You Want
  11. // To Public License, Version 2, as published by Sam Hocevar. See
  12. // http://sam.zoy.org/wtfpl/COPYING for more details.
  13. //
  14. using System;
  15. using System.Runtime.InteropServices;
  16. using System.Security;
  17. namespace Pipi
  18. {
  19. public class Picture
  20. {
  21. private IntPtr _picture;
  22. [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
  23. SuppressUnmanagedCodeSecurity]
  24. private static extern IntPtr pipi_load(string s);
  25. public Picture(string s)
  26. {
  27. _picture = pipi_load(s);
  28. }
  29. [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
  30. SuppressUnmanagedCodeSecurity]
  31. private static extern int pipi_free(IntPtr img);
  32. ~Picture()
  33. {
  34. pipi_free(_picture);
  35. }
  36. [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
  37. SuppressUnmanagedCodeSecurity]
  38. private static extern IntPtr pipi_save(IntPtr p, string s);
  39. public void Save(string s)
  40. {
  41. _picture = pipi_save(_picture, s);
  42. }
  43. [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
  44. SuppressUnmanagedCodeSecurity]
  45. private static extern int pipi_get_image_width(IntPtr img);
  46. public int Width
  47. {
  48. get { return pipi_get_image_width(_picture); }
  49. }
  50. [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
  51. SuppressUnmanagedCodeSecurity]
  52. private static extern int pipi_get_image_height(IntPtr img);
  53. public int Height
  54. {
  55. get { return pipi_get_image_height(_picture); }
  56. }
  57. }
  58. }