public JsonResult AddImageAjax(string expansion, string fileData) { EGalleryEntities db = new EGalleryEntities(); Users user = db.Users.FirstOrDefault(u => u.UserURL == User.Identity.Name); var permission = user.Permission > 0; if (permission) { if (User.IsInRole("Moderator")) { Images image = new Images { Expansion = expansion.ToLower(), UserId = user.Id }; db.Images.Add(image); db.SaveChanges(); ImageSave.Save(fileData, GetPathToImg(image.Name + "." + image.Expansion, "gallery")); } else { PicturesWaiting image = new PicturesWaiting { Expansion = expansion.ToLower(), UserId = user.Id, Status = (int)Status.WAITING }; db.PicturesWaiting.Add(image); db.SaveChanges(); ImageSave.Save(fileData, GetPathToImg(image.Name + "." + image.Expansion, "expectation")); } } return(Json(permission, JsonRequestBehavior.AllowGet)); }
private void AppBarButton_Click_1(object sender, RoutedEventArgs e) { var imageSave = new ImageSave(); ImageSave.SaveImage(((CommandBarFlyout1.Target as Image).GetValue(Image.SourceProperty) as BitmapImage) .UriSource); }
public ImageSave DisplaySpecificationSheet(ImageSave objImageSave) { string sql = ""; sql = "SELECT " + "STYLE_NO, " + "FILE_NAME, " + "FILE_SIZE , " + "FILE_EXTENSION, " + "UPDATE_BY, " + "HEAD_OFFICE_ID, " + "BRANCH_OFFICE_ID, " + "SEASON_ID, " + "SEASON_YEAR " + " FROM PRODUCT_IMAGE where SEASON_ID = '" + objImageSave.SeasonName + "' AND SEASON_YEAR = '" + objImageSave.SeasonYear + "' AND STYLE_NO = '" + objImageSave.StyleNumber + "' "; OracleCommand objCommand = new OracleCommand(sql); OracleDataReader objDataReader; using (OracleConnection strConn = GetConnection()) { objCommand.Connection = strConn; strConn.Open(); objDataReader = objCommand.ExecuteReader(); try { while (objDataReader.Read()) { objImageSave.StyleNumber = objDataReader.GetValue(0).ToString(); objImageSave.ImageFileName = objDataReader.GetValue(1).ToString(); objImageSave.File = (byte[])objDataReader.GetValue(2); objImageSave.ImageFileExtension = objDataReader.GetValue(3).ToString(); objImageSave.UpdateBy = objDataReader.GetValue(4).ToString(); objImageSave.HeadOfficeId = objDataReader.GetValue(5).ToString(); objImageSave.BranchOfficeId = objDataReader.GetValue(6).ToString(); objImageSave.SeasonName = objDataReader.GetValue(7).ToString(); objImageSave.SeasonYear = objDataReader.GetValue(8).ToString(); } } catch (Exception ex) { throw new Exception("Error : " + ex.Message); } finally { strConn.Close(); } } return(objImageSave); }
public JsonResult EditAvatar(string fileData, string expansion) { EGalleryEntities db = new EGalleryEntities(); var user = db.Users.FirstOrDefault(u => u.UserURL == User.Identity.Name); if (user.Avatar != "http://www.teniteatr.ru/assets/no_avatar-e557002f44d175333089815809cf49ce.png") { System.IO.File.Delete(GetPathToImg(user.Avatar, "avatar")); } ImageSave.Save(fileData, GetPathToImg(user.UserURL + "." + expansion, "avatar")); user.Avatar = Url.Content("~/Images/avatar/" + user.UserURL + "." + expansion); db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(ImageSave imageModel) { string filename = Path.GetFileNameWithoutExtension(imageModel.ImageFile.FileName); string extension = Path.GetExtension(imageModel.ImageFile.FileName); filename = filename + DateTime.Now.ToString("yymmssfff") + extension; imageModel.ImagePath = "~/Image/" + filename; filename = Path.Combine(Server.MapPath("~/Image/"), filename); imageModel.ImageFile.SaveAs(filename); using (SchoolImageEntities db = new SchoolImageEntities()) { db.ImageSaves.Add(imageModel); db.SaveChanges(); } ModelState.Clear(); return(View()); }
public ImageSaveHerper() { this.ImageQueue = new Queue(); this.ImageQueueBMP = new Queue(); this.ImageNameQueue = new Queue(); this.ImageNameQueueBMP = new Queue(); this.myImageFileForSave = new CogImageFileTool(); this.IsAddingImage = false; this.IsNeedClose = false; this.mySaveImageUI = new ImageSave(); this.sleeptime = 15; this.ErrorTimes = 0; this.UseCognex = true; this.TooFastSafeguard = false; ImageSaveHerper cCImageSave = this; this.mythreading = new Thread(new ThreadStart(cCImageSave.SaveImageQueue)) { IsBackground = true, Priority = ThreadPriority.Lowest }; this.mythreading.Start(); }
private void btn_add_img_Click(object sender, EventArgs e) { OpenFileDialog opFile = new OpenFileDialog(); opFile.Title = "Select a Image"; opFile.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*"; string dataPath = dataSrcPath + product_id.Text + @"\"; // <--- if (Directory.Exists(dataPath) == false) // <--- { // <--- Directory.CreateDirectory(dataPath); // <--- } // <--- if (opFile.ShowDialog() == DialogResult.OK) { try { string iName = opFile.SafeFileName; // <--- string filePath = opFile.FileName; // <--- product_img.Image = new Bitmap(opFile.OpenFile()); string imgPath = dataPath + iName; //File.Copy(filePath, imgPath); // <--- imageSave = new ImageSave(filePath, imgPath, iName); } catch (Exception exp) { MessageBox.Show("Unable to open file " + exp.Message); } } else { opFile.Dispose(); } }
static void Main(string[] args) { Console.WriteLine("MiRaIRender 1.4.0.2"); string projectPath = null; string configPath = null; string outputPath = null; foreach (string item in args) { string iteml = item.ToLower(); if (iteml.EndsWith(".mrirpro")) { projectPath = item; } else if (iteml.EndsWith(".rconf")) { configPath = item; } else { outputPath = item; } } if (string.IsNullOrEmpty(projectPath)) { Console.WriteLine("Error Need Project File"); return; } if (string.IsNullOrEmpty(configPath)) { Console.WriteLine("Error Need Render Config File"); return; } if (string.IsNullOrEmpty(outputPath)) { Console.WriteLine("Need Output File Name"); return; } Console.WriteLine($"Project: {projectPath}"); Console.WriteLine($"Config : {configPath}"); Console.WriteLine($"Output : {outputPath}"); if (File.Exists(outputPath + ".ppm")) { string uinp; do { Console.WriteLine("Output file already exist, overwrite it?(y/n)"); uinp = Console.ReadLine(); if (uinp.ToLower() == "n") { return; } if (uinp.ToLower() == "y") { break; } }while (true); } (Scene scene, bool ok) = MiRaIRanderProjectLoader.LoadScene(projectPath, DefaultSkyBox.Default); if (!ok) { Console.WriteLine("project load error"); return; } PathTraceRenderOptions options; string[] optCont = File.ReadAllLines(configPath); (options, ok) = PathTraceRenderOptions.LoadOptions(optCont); if (!ok) { Console.WriteLine("config load error"); return; } PathTraceRender render = new PathTraceRender() { Scene = scene, Options = options }; DateTime begin = DateTime.Now; XYZSpectrum[,] img = render.RenderImg(); DateTime end = DateTime.Now; Console.WriteLine($"Render end, use time {(end - begin)}"); ColorRGB8[,] simg = ImageTools.ColorConverter.ConvertToRGB8Image(img); //string fname = $"A:\\img\\{FileName()}"; Console.WriteLine("save to " + outputPath + ".png"); //ImageSave.ImageSave_PPM(simg, outputPath + ".ppm"); ImageSave.ImageSave_PNG(simg, outputPath + ".png"); #if ReflactDebug simg = ImageTools.ColorConverter.ConvertToRGB8Image(render.debugImg); //ImageSave.ImageSave_PPM(simg, outputPath + "_dbg.ppm"); ImageSave.ImageSave_PNG(simg, outputPath + "_dbg.png"); #endif }
public string SaveImageInformation(ImageSave objImageSave) { string strMsg = ""; OracleTransaction objOracleTransaction = null; OracleCommand objOracleCommand = new OracleCommand("pro_product_image_save"); objOracleCommand.CommandType = CommandType.StoredProcedure; objOracleCommand.Parameters.Add("p_style_no", OracleDbType.Varchar2, ParameterDirection.InputOutput).Value = !string.IsNullOrWhiteSpace(objImageSave.StyleNumber) ? objImageSave.StyleNumber : null; objOracleCommand.Parameters.Add("P_season_id", OracleDbType.Varchar2, ParameterDirection.InputOutput).Value = !string.IsNullOrWhiteSpace(objImageSave.SeasonName) ? objImageSave.SeasonName : null; objOracleCommand.Parameters.Add("p_season_year", OracleDbType.Varchar2, ParameterDirection.InputOutput).Value = !string.IsNullOrWhiteSpace(objImageSave.SeasonYear) ? objImageSave.SeasonYear : null; objOracleCommand.Parameters.Add("P_FILE_NAME", OracleDbType.Varchar2, ParameterDirection.InputOutput).Value = !string.IsNullOrWhiteSpace(objImageSave.ImageFileName) ? objImageSave.ImageFileName : null; if (!string.IsNullOrWhiteSpace(objImageSave.ImageFileSize)) { byte[] array = System.Convert.FromBase64String(objImageSave.ImageFileSize); objOracleCommand.Parameters.Add("P_FILE_SIZE", OracleDbType.Blob, ParameterDirection.Input).Value = array; } else { objOracleCommand.Parameters.Add("P_FILE_SIZE", OracleDbType.Blob, ParameterDirection.Input).Value = null; } objOracleCommand.Parameters.Add("P_FILE_EXTENSION", OracleDbType.Varchar2, ParameterDirection.InputOutput).Value = !string.IsNullOrWhiteSpace(objImageSave.ImageFileExtension) ? objImageSave.ImageFileExtension : null; objOracleCommand.Parameters.Add("P_UPDATE_BY", OracleDbType.Varchar2, ParameterDirection.Input).Value = objImageSave.UpdateBy; objOracleCommand.Parameters.Add("P_HEAD_OFFICE_ID", OracleDbType.Varchar2, ParameterDirection.Input).Value = objImageSave.HeadOfficeId; objOracleCommand.Parameters.Add("P_BRANCH_OFFICE_ID", OracleDbType.Varchar2, ParameterDirection.Input).Value = objImageSave.BranchOfficeId; objOracleCommand.Parameters.Add("P_MESSAGE", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; using (OracleConnection strConn = GetConnection()) { try { objOracleCommand.Connection = strConn; strConn.Open(); trans = strConn.BeginTransaction(); objOracleCommand.ExecuteNonQuery(); trans.Commit(); strConn.Close(); strMsg = objOracleCommand.Parameters["P_MESSAGE"].Value.ToString(); } catch (Exception ex) { throw new Exception("Error : " + ex.Message); objOracleTransaction.Rollback(); } finally { strConn.Close(); } } return(strMsg); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageSave obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
private void SaveButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { ImageSave.SaveImage((imageDetail.GetValue(Image.SourceProperty) as BitmapImage).UriSource); }