Example #1
0
        private static void Save_Data(queue Finsh_queue)
        {
            DataSql      _DataSql = new DataSql();
            UIImage      image;
            LibraryWords library = new LibraryWords();



            var myByteArray = File.ReadAllBytes(Finsh_queue.Filename);

            byte[] myByteThumbnail = null;


            if (Finsh_queue._Type == "Video")
            {
                //   byte[] myByteArray;
                CoreMedia.CMTime actualTime;
                NSError          outError;
                using (var asset = AVAsset.FromUrl(NSUrl.FromFilename(Finsh_queue.Filename)))
                    using (var imageGen = new AVAssetImageGenerator(asset))
                        using (var imageRef = imageGen.CopyCGImageAtTime(new CoreMedia.CMTime(1, 1), out actualTime, out outError))
                        {
                            if (imageRef == null)
                            {
                                // return null;
                            }
                            image = UIImage.FromImage(imageRef);
                        }
                using (NSData imageData = image.AsPNG())
                {
                    myByteThumbnail = new Byte[imageData.Length];
                    System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, myByteThumbnail, 0, Convert.ToInt32(imageData.Length));
                }


                if (save.Savegerlly)
                {
                    if (File.Exists(Finsh_queue.Filename))
                    {
                        savedowloaning file = new savedowloaning();
                        // AMvideo.SaveToAlbum(Finsh_queue.Filename);
                        file.Get_clipfile(Finsh_queue.ID.ToString(), myByteArray);
                        // ALAssetsLibrary lib = new ALAssetsLibrary();
                        // lib.WriteVideoToSavedPhotosAlbum(NSUrl.FromFilename(Finsh_queue.Filename), (t, u) => { });
                    }
                }
            }
            else
            {
                myByteThumbnail = myByteArray;


                if (save.Savegerlly)
                {
                    savedowloaning file = new savedowloaning();
                    file.Get_imagefile(Finsh_queue.ID.ToString(), myByteArray);
                }
            }


            _DataSql.process(library.File(2), library.INSERT(2), DataSql_Parameters(Path.GetFileName(Finsh_queue.Filename), myByteArray, myByteThumbnail, Finsh_queue._Type));
        }
Example #2
0
        void todatabese()
        { //change
            List <byte[]> Imagebyeds = new List <byte[]>();
            List <string> strimg     = new List <string>();

            foreach (save_Plus Savefile in saveFormGrally)
            {
                DataSql = new DataSql();


                if (Savefile.Extension == "Image")
                {
                    //DataSql = new DataSql();

                    //  Byte[] myByteArray;
                    using (NSData imageData = Savefile.Image.AsPNG())
                    {
                        Savefile.ImageToBytes = new Byte[imageData.Length];
                        System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, Savefile.ImageToBytes, 0, Convert.ToInt32(imageData.Length));
                    }// tumblt

                    using (NSData Thumbnaildata = Savefile.Thumbnail.AsPNG())
                    {
                        Savefile.ThumbnailToBytes = new Byte[Thumbnaildata.Length];
                        System.Runtime.InteropServices.Marshal.Copy(Thumbnaildata.Bytes, Savefile.ThumbnailToBytes, 0, Convert.ToInt32(Thumbnaildata.Length));
                    }


                    Savefile.Title = GeneratePassword(7);
                    // Imagebyeds.Add(myByteArray);
                    //  strimg.Add(random);
                    DataSql.process(library.File(2), library.INSERT(2), DataSql_Parameters(Savefile.Title + ".jpg", Savefile.ImageToBytes, Savefile.ThumbnailToBytes, Savefile.Extension));
                }


                else
                {
                    using (NSData Thumbnaildata = Savefile.Thumbnail.AsPNG())
                    {
                        Savefile.ThumbnailToBytes = new Byte[Thumbnaildata.Length];
                        System.Runtime.InteropServices.Marshal.Copy(Thumbnaildata.Bytes, Savefile.ThumbnailToBytes, 0, Convert.ToInt32(Thumbnaildata.Length));
                    }

                    using (NSData data = NSData.FromUrl(NSUrl.FromString(Savefile.Url)))
                    {
                        Savefile.ImageToBytes = new byte[data.Length];

                        System.Runtime.InteropServices.Marshal.Copy(data.Bytes, Savefile.ImageToBytes, 0, Convert.ToInt32(data.Length));
                    }
                    Savefile.Title = GeneratePassword(7);


                    DataSql.process(library.File(2), library.INSERT(2), DataSql_Parameters(Savefile.Title + ".mp4", Savefile.ImageToBytes, Savefile.ThumbnailToBytes, Savefile.Extension));
                }
            }
            //foreach (string stringUrl in UrlVideoString)
            //{


            //    DataSql = new DataSql();

            //    byte[] myByteArray;
            //    using (NSData data = NSData.FromUrl(NSUrl.FromString(stringUrl)))
            //    {


            //        myByteArray = new byte[data.Length];

            //        System.Runtime.InteropServices.Marshal.Copy(data.Bytes, myByteArray, 0, Convert.ToInt32(data.Length));
            //    }
            //    string random = GeneratePassword(7);
            //    // this.Title = videoUrl.ToString(); ;

            //    DataSql.process(library.File(2), library.INSERT(2), DataSql_Parameters(random+".mp4", myByteArray, "Video"));
            //}


            //foreach (byte[] stringUrl in byetdata)
            //{

            //        string random = GeneratePassword(7);
            //        DataSql.process(library.File(2), library.INSERT(2), DataSql_Parameters(random + ".jpg", stringUrl, "Image"));

            //}

            //

            reload();
            saveFormGrally.Clear();
            //cal.addbutton(Imagebyeds, strimg);
            // Imagebyeds.Clear();
            // strimg.Clear();
            //UrlVideoString.Clear();
            //Imagedata.Clear();
            //byetdata.Clear();
        }