Hy Guys, 

I have a UIViewController wich has on ViewDidAppear this code:

ThreadPool.QueueUserWorkItem( delegate{
    make_thumbs();
});

the make_thumbs function is:

void make_thumbs()
                {
                        using( var ns = new NSAutoreleasePool() )
                        {
                                foreach( var c in Settings.Instance.Categories )
                                {
                                        for( var i = 0; i < c.Pictures.Count; 
i++ )
                                        {
                                                //this is the existing
bundled image path
                                                string     path = 
c.Pictures[i].PicturePath; 
                                                string   folder = 
Environment.GetFolderPath(
Environment.SpecialFolder.Personal );
                                                //this is the destination image 
file name
                                                string filename = Path.Combine( 
folder, c.Name + i + ".png");
                                                if( !File.Exists( filename ) )
                                                {
                                                        UIImage    img = 
UIImage.FromFile( path ).Scale( 250,250 );
                                                        NSError err;
                                                        img.AsPNG().Save( 
filename, true, out err );
                                                        
                                                }
                                                
                                        }
                                }
                        }
                }

The code is pretty easy, it has to load from a settings file all the
existing images, scale them to 250x250 and save them with another name.

The problem is that on the device ( teste on an iPhone 3g and an iPad ) it
crushes after a while with memory warnings.  

--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/Save-UIImage-as-png-from-another-thread-tp4343087p4343087.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to