Ignore:
Timestamp:
10/11/08 23:56:21 (5 years ago)
Author:
sam
Message:

ThePimp?: make image loading more robust.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi-sharp/Picture.cs

    r2874 r2926  
    2222    { 
    2323        private IntPtr _picture; 
     24        private string _filename; 
    2425 
    25         public readonly string FileName; 
     26        public string FileName 
     27        { 
     28            get { return _filename; } 
     29        } 
    2630 
    27         [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl), 
    28          SuppressUnmanagedCodeSecurity] 
    29         private static extern IntPtr pipi_load(string s); 
    30         public Picture(string s) 
     31        private Picture(IntPtr p) 
    3132        { 
    32             _picture = pipi_load(s); 
    33             FileName = s; 
     33            _picture = p; 
    3434        } 
    3535 
     
    4040        { 
    4141            pipi_free(_picture); 
     42        } 
     43 
     44        [DllImport("libpipi.dll", CallingConvention=CallingConvention.Cdecl), 
     45         SuppressUnmanagedCodeSecurity] 
     46        private static extern IntPtr pipi_load(string s); 
     47        public static Picture Load(string s) 
     48        { 
     49            IntPtr p = pipi_load(s); 
     50            if(p == IntPtr.Zero) 
     51                return null; 
     52 
     53            Picture ret = new Picture(p); 
     54            ret._filename = s; 
     55            return ret; 
    4256        } 
    4357 
Note: See TracChangeset for help on using the changeset viewer.