public ActionResult Ayar(HttpPostedFileBase[] images, IsletmeAyar model) { if (images[0] != null) { var saveResult = ImageSaver.SaveImage(images, model.Ad).FirstOrDefault(); if (!saveResult.Contains("Dosya Kaydedilemedi")) { model.LogoUri = saveResult; } else { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", $"Görsel Kaydedilemedi </br>{saveResult[1]} " } }; return(RedirectToAction("Ekle")); } } using (IsletmeAyarRepository repo = new IsletmeAyarRepository()) { model.isActive = true; bool result = repo.Create(model); TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Ayar eklendi." } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Ayar eklenemedi." } }; return(RedirectToAction("Liste")); } }
public void Run() { var width = BaseSettings.Width; var height = BaseSettings.Height; const int fov = (int)(MathF.PI / 2.0f); var framebuffer = new Framebuffer <Vector3>(width, height, default); Parallel.For(0, height, j => { for (var i = 0; i < width; i++) { var x = (2 * (i + 0.5f) / width - 1) * MathF.Tan(fov / 2.0f) * width / height; var y = -(2 * (j + 0.5f) / height - 1) * MathF.Tan(fov / 2.0f); var dir = new Vector3(x, y, -1).Normalize(); framebuffer[i + j * width] = CastRay(Vector3.Zero, dir); } }); var fileName = $"output-raytracer{DateTime.Now:yyyy-dd-M--HH-mm-ss.fff}.ppm"; var image = new Image(fileName) { Height = height, Width = width, Data = framebuffer }; ImageSaver.Save(image); }
private void setupContols() { PreviewKeyUp += (s, e) => { if (!ns) { return; } if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { if (e.Key == Key.S) { ImageSaver.asPNG(ns.view, sets.projectName + "References"); } } }; connVisButt.Click += (s, e) => { alternate(connVisButt, "Show all references", "Show deepest references only"); if ((string)connVisButt.Content == "Show all references") { ns.displayMeth = ConnectionsVisibility.Deepest; } else { ns.displayMeth = ConnectionsVisibility.All; } }; }
public void OnImageAvailable(ImageReader reader) { var img = reader.AcquireNextImage(); var btmp = ImageProcessing.ConvertImgToBtmp(img); if (owner.isFaceCamera) { if (owner.mSensorOrientation == ImageOrientation.Portrait) { owner.mSensorOrientation = ImageOrientation.PortraitBottom; } else if (owner.mSensorOrientation == ImageOrientation.PortraitBottom) { owner.mSensorOrientation = ImageOrientation.Portrait; } } ImageProcessing.RotateBitmap(owner.mSensorOrientation, ref btmp); var imageSaver = new ImageSaver(btmp, owner.GetExternalFilesDir(null), mre); owner.mBackgroundHandler.Post(imageSaver); PostResult = imageSaver.mFile; }
public ActionResult Sil(int id, string path) { using (KategoriRepository repo = new KategoriRepository()) { bool result; try { result = repo.Delete(id); } catch (Exception e) { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Kategor silinemedi. Kategoriye Bağlı Ürün Olabilir." } }; result = false; } if (result) { var message = ImageSaver.DeleteImage(path); TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Kategori silindi" } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Kategor silinemedi." + message } }; return(RedirectToAction("Liste")); } return(RedirectToAction("Liste")); } }
private void updateNewInfo(Worker workerToUpdate, WorkerBundle newWorkerInfo) { if (newWorkerInfo.Name != null) { workerToUpdate.Name = newWorkerInfo.Name; workerToUpdate.Surname = newWorkerInfo.Surname; workerToUpdate.Password = newWorkerInfo.Password; workerToUpdate.PhoneNumber = newWorkerInfo.PhoneNumber; } if (newWorkerInfo.ShortDescription != null) { workerToUpdate.ShortDescription = newWorkerInfo.ShortDescription; workerToUpdate.Information = newWorkerInfo.Information; workerToUpdate.BoardingPrice = newWorkerInfo.BoardingPrice; workerToUpdate.ZIPCode = localizationMgr.GetZipCodeFromAddress(newWorkerInfo.Address); } if (newWorkerInfo.Disponibility != null) { workerToUpdate.Disponibility = convertDisponibilityIntToString(newWorkerInfo.Disponibility, workerToUpdate.WorkerId); } if (newWorkerInfo.WalkingPrice != null && newWorkerInfo.WalkingPrice != 0) { workerToUpdate.WalkingPrice = newWorkerInfo.WalkingPrice; } if (newWorkerInfo.ProfileImage != null) { workerToUpdate.ProfileImage = ImageSaver.GetIntance().getUrlOfImage(newWorkerInfo.ProfileImage, workerToUpdate.WorkerId.ToString(), "w"); } }
private PetToReturn convertPetToReturn(Pet pet) { byte[] petImg = ImageSaver.GetIntance().getImage(pet.PetImage); PetToReturn petToReturn = new PetToReturn(pet.PetId, pet.Name, pet.PetType, petImg, pet.Gender, pet.Age, pet.Weight, pet.FriendlyPet, pet.HasVaccination, pet.Information); return(petToReturn); }
private static void SaveUploadedImagesNew(borsvarldenContext db) { //var filesAlreadySaved = // File.ReadAllLines(Path.GetFullPath($@"{Directory.GetCurrentDirectory()}\..\..\..\UploadedImages.txt")); var dirRootToDownload = Path.GetFullPath($@"{Directory.GetCurrentDirectory()}\..\..\..\..\borsvarlden\wwwroot\assets\uploads"); db.WpPostmeta.Where(x => x.MetaKey == "_wp_attached_file") .Select(x => x.MetaValue) .ToList() .ForEach(x => { var subPath = x.Replace("/", "\\"); var dir = $@"{dirRootToDownload}\{subPath.Substring(0, subPath.LastIndexOf('\\'))}"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var file = $@"{dirRootToDownload}\{subPath}"; if (!File.Exists(file)) { ImageSaver.Save(x, dir); } } ); }
public ActionResult Guncelle(Urun model, int number, string OldMedia, HttpPostedFileBase[] media) { model.UrunId = number; if (media == null) { model.MediaPath = OldMedia; } //ImageSaver.DeleteImage(OldMedia); var saveResult = ImageSaver.SaveImage(media, model.Ad).Last(); if (!saveResult.Contains("Dosya Kaydedilemedi")) { model.MediaPath = saveResult; } else { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", $"Görsel Kaydedilemedi </br>{saveResult[1]} " } }; return(RedirectToAction("Ekle")); } using (UrunRepository repo = new UrunRepository()) { //model.KategoriId = number; bool result = repo.Update(model); TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Kategroi eklendi." } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Kategroi eklenemedi." } }; return(RedirectToAction("Liste")); } }
public ActionResult Ekle(Urun model, HttpPostedFileBase[] images) { if (images != null) { var saveResult = ImageSaver.SaveImage(images, model.Ad).FirstOrDefault(); if (!saveResult.Contains("Dosya Kaydedilemedi")) { model.MediaPath = saveResult; } else { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", $"Görsel Kaydedilemedi </br>{saveResult[1]} " } }; return(RedirectToAction("Ekle")); } } using (UrunRepository repo = new UrunRepository()) { model.IsAktif = true; bool result = repo.Create(model); TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Ürün eklendi." } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Ürün eklenemedi." } }; return(RedirectToAction("Liste")); } }
public FDesktop(IEmailer emailer, ImageSaver imageSaver, StringWrapper stringWrapper, AppConfigManager appConfigManager, RecoveryManager recoveryManager, IScannedImageImporter scannedImageImporter, AutoUpdaterUI autoUpdaterUI, OcrDependencyManager ocrDependencyManager, IProfileManager profileManager, IScanPerformer scanPerformer, IScannedImagePrinter scannedImagePrinter, ChangeTracker changeTracker, EmailSettingsContainer emailSettingsContainer, FileNamePlaceholders fileNamePlaceholders, ImageSettingsContainer imageSettingsContainer, PdfSettingsContainer pdfSettingsContainer, PdfSaver pdfSaver, IErrorOutput errorOutput) { this.emailer = emailer; this.imageSaver = imageSaver; this.stringWrapper = stringWrapper; this.appConfigManager = appConfigManager; this.recoveryManager = recoveryManager; this.scannedImageImporter = scannedImageImporter; this.autoUpdaterUI = autoUpdaterUI; this.ocrDependencyManager = ocrDependencyManager; this.profileManager = profileManager; this.scanPerformer = scanPerformer; this.scannedImagePrinter = scannedImagePrinter; this.changeTracker = changeTracker; this.emailSettingsContainer = emailSettingsContainer; this.fileNamePlaceholders = fileNamePlaceholders; this.imageSettingsContainer = imageSettingsContainer; this.pdfSettingsContainer = pdfSettingsContainer; this.pdfSaver = pdfSaver; this.errorOutput = errorOutput; InitializeComponent(); thumbnailList1.MouseWheel += thumbnailList1_MouseWheel; Shown += FDesktop_Shown; FormClosing += FDesktop_FormClosing; Closed += FDesktop_Closed; }
private void SaveCopy() { var newPhotodata = ImageSaver.SaveCopy(dstBmp, photoView.CroppingRectangle, _photodata, MaxDistance, Context); AppContextLiveData.Instance.PhotosModel.InsertItem(newPhotodata); ReInitialize(newPhotodata); }
public void AddClientImage(int clientId, ImageBundle newImage) { Client clientToAddImage = unitOfWork.ClientRepository.GetByID(clientId); validator.validateUserExists(clientToAddImage, null); clientToAddImage.ProfileImage = ImageSaver.GetIntance().getUrlOfImage(newImage.Image, clientToAddImage.ClientId.ToString(), "c"); unitOfWork.Save(); }
public byte [] GetClientImage(int clientId) { Client client = unitOfWork.ClientRepository.GetByID(clientId); string imgUrl = client.ProfileImage; byte [] profileImage = ImageSaver.GetIntance().getImage(imgUrl); return(profileImage); }
private ClientToReturn convertClientToReturn(Client client, List <PetToReturn> pets) { byte[] clientImg = ImageSaver.GetIntance().getImage(client.ProfileImage); ClientToReturn clientToReturn = new ClientToReturn(client.ClientId, client.Name, client.Surname, client.Email, client.Password, clientImg, pets, client.PhoneNumber); return(clientToReturn); }
public MainViewModel(MainWindow mainWindow) { ImageLoader = new ImageLoader(); FilterHandler = new FilterHandler(ImageLoader); ImageSaver = new ImageSaver(FilterHandler); KernelBarViewModel = new KernelBarViewModel(FilterHandler, mainWindow); ThresholdingParametersViewModel = new ThresholdingParametersViewModel(FilterHandler); }
private static void SaveUploadedImagesToDisk() { var dirToDownload = Path.GetFullPath($@"{Directory.GetCurrentDirectory()}\..\..\..\..\borsvarlden\wwwroot\assets\images\finauto\other\general"); var pathListFiles = Path.GetFullPath($@"{Directory.GetCurrentDirectory()}\..\..\..\UploadedImages.txt"); File.ReadAllLines(pathListFiles) .ToList() .ForEach(x => ImageSaver.Save(x, dirToDownload)); }
public CommandHandler( PetShelterDbContext petShelterDbContext, ImageSaver imageSaver, UserResolverService userResolverService) { _petShelterDbContext = petShelterDbContext; _imageSaver = imageSaver; _user = userResolverService.GetUser(); }
private async void SaveMotionFile(ByteWrapper image) { await Task.Run(() => { if (!Directory.Exists(saveDirectory)) { CreateSaveDirectory(); } ImageSaver.WriteBytesToFileAsync(image, saveDirectory + @"\movement_" + image.sequenceNumber + ".jpg"); }); }
/// <summary> /// Runs a number of single extractions from the IP camera /// Times the change to Bitmap and count of the pixels for /// These images /// </summary> public void RunBenchmarking(string logfile) { //extract the images List <String> saveLocations = new List <string>(); string url = "http://192.168.0.2/axis-cgi/mjpg/video.cgi?resolution="; List <String[]> resolutions = ReturnResolutions(); for (int i = 0; i < resolutions.Count; i++) { string actualurl = url + resolutions[i][0] + "x" + resolutions[i][1]; //set up the extractor ImageExtractor imageExtractor = new ImageExtractor(actualurl, "root", "root"); //set up the save file object ImageSaver imageSaver = new ImageSaver(0, 1); saveLocations.Add(imageSaver.CaptureDirectory); //create the validator ImageValidator imageValidator = new ImageValidator(); imageValidator.ListenForImages(imageExtractor); imageValidator.imageValidated += new ImageValidator.ImageValidatedEvent(imageSaver.ImageCreatedAsync);//subscribe to events from the validator imageExtractor.Run(true); System.Threading.Thread.Sleep(5000); //wait 5 seconds to let the async requests complete } //do the analysis for (int i = 0; i < saveLocations.Count; i++) { string header = resolutions[i][0] + "x" + resolutions[i][1]; Console.WriteLine(Environment.NewLine + resolutions[i][0] + "x" + resolutions[i][1]); JPEG jpeg = new JPEG(saveLocations[i] + @"\1\test_0.jpg"); string msToBitmap = MsToBitmap(jpeg).ToString(); string msToBitmapAndSumPixels = MsToBitmapAndSumPixels(jpeg).ToString(); string totalPixels = TotalPixels(jpeg).ToString(); Console.WriteLine(msToBitmap); Console.WriteLine(msToBitmapAndSumPixels); Console.WriteLine(totalPixels); using (System.IO.StreamWriter file = new System.IO.StreamWriter(logfile, true)) { file.WriteLine(header); file.WriteLine(msToBitmap); file.WriteLine(msToBitmapAndSumPixels); file.WriteLine(totalPixels); file.WriteLine("------------------------------"); } } }//RunBenchmarking
private Pet convertDTOPet(PetBundle petData) { Pet pet = new Pet(petData.Name, petData.PetType, petData.Gender, petData.Information, petData.Age, petData.Weight, petData.FriendlyPet, petData.HasVaccination); if (petData.PetImage != null) { pet.PetImage = ImageSaver.GetIntance().getUrlOfImage(petData.PetImage, Guid.NewGuid().ToString(), "p"); } return(pet); }
private void DoSave() { if (_img != null) { ImageSaver.SavedByHandle(_img, VideoName); } if (SaveAction != null) { SaveAction(); } }
/// <summary> /// Read signature from image, extract features, generate new image /// </summary> static void OfflineVerifierDemo() { Logger debugLogger = new Logger( LogLevel.Debug, new FileStream($@"Logs\OfflineDemo_{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.log", FileMode.Create), LogConsole); var verifier = new Verifier() { Logger = debugLogger, TransformPipeline = new SequentialTransformPipeline { new Binarization().Input(Features.Image), new Trim(5), new PrepareForThinning(), new ImageGenerator(true), new HSCPThinning(), new ImageGenerator(true), new OnePixelThinning().Output(MyFeatures.Skeleton),//output Skeletonba, mert az Extraction onnan szedi new ImageGenerator(true), //new BaselineExtraction(), //new LoopExtraction(), new EndpointExtraction(), new ComponentExtraction(5), new ComponentSorter(), new ComponentsToFeatures(), new ParallelTransformPipeline { new Normalize().Input(Features.X), new Normalize().Input(Features.Y) }, new ApproximateOnlineFeatures(), new RealisticImageGenerator(1280, 720), }, ClassifierPipeline = new DTWClassifier() }; verifier.ProgressChanged += ProgressPrimary; Signature s1 = new Signature(); ImageLoader.LoadSignature(s1, @"Databases\Offline\Images\U1S1.png"); s1.Origin = Origin.Genuine; Signer s = new Signer(); s.Signatures.Add(s1); verifier.Train(s); //TODO: ha mar Verifier demo, akkor Test()-et is hasznaljuk.. ImageSaver.Save(s1, @"GeneratedOfflineImage.png"); debugLogger.Stop(); }
private void uploadAndSetImage(ref ApplicationUser user, HttpPostedFileBase ImageUrl) { if (ImageUrl != null) { string pathForToSave = Path.Combine(Server.MapPath("~/Content/images"), user.Id); string fileName = Path.GetFileName(ImageUrl.FileName); string pathForPicture = string.Format(@"/Content/images/{0}/{1}", user.Id, fileName); user.ImageUrl = pathForPicture; ImageSaver.SaveImage(ImageUrl, pathForToSave, fileName); Server.MapPath(pathForPicture); } }
public ActionResult Create([Bind(Include = "Id,Title,Description,ImageUrl,DateTimeOfTheEvent")] Event @event, HttpPostedFileBase ImageUrl, string[] Interests) //{ //public ActionResult Create(HttpPostedFileBase ImageUrl) { if (ModelState.IsValid) { //Event dbEvent = new Event(); ImageSaver.SaveImage(ImageUrl, Server.MapPath("~/App_Data/uploads/events"), ImageUrl.FileName); //if (ImageUrl != null) //{ // if (ImageUrl.ContentLength > 0) // { // var fileName = Path.GetFileName(ImageUrl.FileName); // // var uri = "~/App_Data/uploads/events" + @event.Id; // // need to create folder for each event, the name of the folder is the id of the event // var path = Path.Combine(Server.MapPath("~/App_Data/uploads/events"), fileName); // ImageUrl.SaveAs(path); // @event.ImageUrl = fileName; // } //} @event.DateTimeCreated = DateTime.Now; //dbEvent.DateTimeOfTheEvent = @event.DateTimeOfTheEvent; //dbEvent.Description = @event.Description; //dbEvent.ImageUrl = @event.ImageUrl; @event.Interests = new List <Interest>(); //dbEvent.Place = @event.Place; //dbEvent.Title = @event.Title; //dbEvent.UsersAttending = @event.UsersAttending; //dbEvent.UsersInvited = @event.UsersInvited; foreach (string interestID in Interests) { int id = int.Parse(interestID); Interest interest = db.Interests.SingleOrDefault(x => x.Id == id); if (interest != null) { @event.Interests.Add(interest); } } db.Events.Add(@event); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(@event)); }
public ActionResult Ekle(Menu model, HttpPostedFileBase[] images, int[] urunler) { var saveResult = ImageSaver.SaveImage(images, model.Ad).FirstOrDefault(); if (!saveResult.Contains("Dosya Kaydedilemedi")) { model.MediaPath = saveResult; } else { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", $"Görsel Kaydedilemedi </br>{saveResult[1]} " } }; return(RedirectToAction("Ekle")); } using (MenuRepository repo = new MenuRepository()) { model.isAktive = true; model.MediaPath = saveResult; bool result = repo.Create(model); if (result) { if (urunler != null) { using (MenuUrunRepository repo2 = new MenuUrunRepository()) { List <MenuUrun> menuUrunModel = new List <MenuUrun>(); foreach (var item in urunler) { menuUrunModel.Add(new MenuUrun { MenuId = model.MenuId, UrunId = item, UrunMiktar = 1 }); } bool result2 = repo2.CokluIcerikEkle(menuUrunModel); if (!result2) { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Menü içeriği eklenemedi. </br> Menü oluşturuldu fakat içerikler eklenirken bir hata oluştu menü listesinden içerik eklemeyi deneyin." } }; } } } } TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Menü eklendi." } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Menü eklenemedi." } }; return(RedirectToAction("Liste")); } }
public static void SaveImage(Bitmap bitmap, ImageFormat format, Stream stream) { ImageSaver saver = new ImageSaver(bitmap); if (format == ImageFormat.Jpeg) { saver.SaveJpeg(stream, JPEG_QUALITY, format); } else { saver.Save(stream, format); } }
public void AddWorkerImage(int workerId, ImageBundle newImage) { Worker workerToAddImage = unitOfWork.WorkerRepository.GetByID(workerId); validator.validateUserExists(null, workerToAddImage); string newImgUrl = ImageSaver.GetIntance().getUrlOfImage(newImage.Image, Guid.NewGuid().ToString(), "w"); WorkerImage imageToAdd = new WorkerImage(newImgUrl); workerToAddImage.Images.Add(imageToAdd); unitOfWork.Save(); }
private void SaveQRCodeDialog() { var dlg = new SaveFileDialog { FileName = "QrCode.png", DefaultExt = ".png", Filter = "PNG (.png)|*.png" }; if (dlg.ShowDialog().Value) { ImageSaver.SaveQRCodeToLibrary(this.QrCodeImage, dlg.FileName); } }
public void TearDown() { if (TestContext.CurrentContext.Result.Outcome.Status != TestStatus.Failed) { return; } var testName = TestContext.CurrentContext.Test.Name; var painter = new Painter(new Size(1000, 1000)); var image = painter.GetMultiColorCloud(rectangles); var fileName = new StringBuilder(testName).Append("FAILED").ToString(); var path = ImageSaver.SaveImageToDefaultDirectory(fileName, image); Console.WriteLine($"Tag cloud visualization saved to file {path}"); }
public static void SaveImage(Bitmap bitmap, ImageFormat format, Stream stream) { ImageSaver saver = new ImageSaver(bitmap); if (format == ImageFormat.Jpeg) { saver.SaveJpeg(stream, JPEG_QUALITY, format); } else { saver.Save(stream, format); } }
private void InitializeInstanceFields() { mImageSaver = new ImageSaver(this, this); mSessionCaptureCallback = new DofSessionCaptureCallback(this, this); mDofCaptureCallback = new DofCaptureCallback(this, this); }
public OnScanCompletedListenerAnonymousInnerClassHelper(ImageSaver outerInstance) { this.outerInstance = outerInstance; }
private void InitializeInstanceFields() { mImageSaver = new ImageSaver(this, this); }