source: libpipi/trunk/pipi-sharp/Picture.cs @ 2872

Last change on this file since 2872 was 2872, checked in by Sam Hocevar, 14 years ago

Start playing with scrolling widgets in Pimp.

File size: 2.0 KB
Line 
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
15using System;
16using System.Runtime.InteropServices;
17using System.Security;
18
19namespace Pipi
20{
21    public class Picture
22    {
23        private IntPtr _picture;
24
25        [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
26         SuppressUnmanagedCodeSecurity]
27        private static extern IntPtr pipi_load(string s);
28        public Picture(string s)
29        {
30            _picture = pipi_load(s);
31        }
32
33        [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
34         SuppressUnmanagedCodeSecurity]
35        private static extern int pipi_free(IntPtr img);
36        ~Picture()
37        {
38            pipi_free(_picture);
39        }
40
41        [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
42         SuppressUnmanagedCodeSecurity]
43        private static extern IntPtr pipi_save(IntPtr p, string s);
44        public void Save(string s)
45        {
46            _picture = pipi_save(_picture, s);
47        }
48
49        [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
50         SuppressUnmanagedCodeSecurity]
51        private static extern int pipi_get_image_width(IntPtr img);
52        public int Width
53        {
54            get { return pipi_get_image_width(_picture); }
55        }
56
57        [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl),
58         SuppressUnmanagedCodeSecurity]
59        private static extern int pipi_get_image_height(IntPtr img);
60        public int Height
61        {
62            get { return pipi_get_image_height(_picture); }
63        }
64    }
65}
Note: See TracBrowser for help on using the repository browser.