Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How can I make a MAC desktop application for taking snap shop in a regular interval?

$
0
0

I am using

string SnapPath = "Users/dreamztechsmacmini5/Desktop/Partha/NewApplication/enableEmployment/Snapshot" + "/" + taskId; if (!System.IO.Directory.Exists(SnapPath)) System.IO.Directory.CreateDirectory(SnapPath);

            int width = 1200;
            int height = 1200;


            int windowNumber = 0; System.Drawing.RectangleF bounds = new RectangleF(0,0,1200,1200);

            CGImage screenImage = MonoMac.CoreGraphics.CGImage.ScreenImage(windowNumber,bounds);
            using(NSBitmapImageRep imageRep = new NSBitmapImageRep(screenImage))
            {
                NSDictionary properties = NSDictionary.FromObjectAndKey(new NSNumber(1.0), new NSString("NSImageCompressionFactor"));
                using(NSData tiffData = imageRep.RepresentationUsingTypeProperties(NSBitmapImageFileType.Png, properties))
                {
                    //NSError err=new NSError();
                    //tiffData.Save(System.IO.Path.Combine(SnapPath, Guid.NewGuid().ToString() + ".png"),false,out err);

                    byte[] imageBytes;

                    using(var ms = new MemoryStream())
                    {
                        tiffData.AsStream().CopyTo(ms);
                        imageBytes = ms.ToArray();

                        Bitmap img = (Bitmap)System.Drawing.Image.FromStream(ms);
                        img.Save(System.IO.Path.Combine(SnapPath, Guid.NewGuid().ToString() + ".png"));


                    }
                }
            }

but it creates blank images. Please help me.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>