public long SetImage(long HumanID, ImageForTransfer Image)//IMAGE image)//long HumanID , byte[] Image) { try { using (KARYABDBEntities db = new KARYABDBEntities()) { var _Image = db.IMAGES.Where(q => q.HUMANID == HumanID).FirstOrDefault(); if (_Image != null) { _Image.IMAGE1 = Convert.FromBase64String(Image.Bitmap); db.SaveChanges(); return(_Image.ID); } else { IMAGE image = new IMAGE(); image.HUMANID = HumanID; image.IMAGE1 = Convert.FromBase64String(Image.Bitmap); db.IMAGES.Add(image); db.SaveChanges(); return(image.ID); } } } catch (Exception e) { return(0); } }
public static int InsertImageFromFile(string filename, string contenttype) { int counter = 0; Image img = Image.FromFile(filename); byte[] ImageData = imgToByteArray(img); using (Mongo mongo = new Mongo(config.BuildConfiguration())) { mongo.Connect(); var db = mongo.GetDatabase(VehicleRecords.VEHICLE_DB.DataBaseName); IMongoCollection <Document> collImage; collImage = db.GetCollection <Document>(IMAGE.TableName); var cursor = collImage.FindAll(); if (cursor.Documents.Count() > 0) { counter = cursor.Documents.Count(); } IMAGE pic = new IMAGE(); pic.ContentType = contenttype; pic.ImageData = ImageData; pic.ImageId = counter; pic.ImageName = Path.GetFileName(filename); pic.TimesServed = 0; IMAGE.InsertDocumentFromMEMBER(collImage, pic); mongo.Disconnect(); } img = null; return(counter); }
/// <summary> /// Tries to load an image from the given path and sets the <see cref="ImagePath"/>. /// </summary> /// <param name="path">The path of the image.</param> /// <returns>true if the image was loaded, else false.</returns> public async Task <bool> TryLoadImageAsync(string path) { if (!File.Exists(path)) { return(false); } IMAGE i = await ImageHelper.LoadImageAsync(path); if (i == null) { this.OnLoadFailed(path); return(false); } bool _ = this.DisposeImageOnReplace; this.DisposeImageOnReplace = true; this.Image = i; this.ImagePath = new FileInfo(path); this.DisposeImageOnReplace = _; return(true); }
private void ChangeAllImageToggle_Click(object sender, RoutedEventArgs e) { if ((bool)ChangeAllImageToggle.IsChecked) { IMAGEHead.SelectionMode = ListViewSelectionMode.Multiple; IMAGEBottom.SelectionMode = ListViewSelectionMode.Multiple; IMAGE.SelectionMode = ListViewSelectionMode.Multiple; HambShotList.SelectionMode = ListViewSelectionMode.None; IMAGEHead.SelectAll(); IMAGEBottom.SelectAll(); IMAGE.SelectAll(); UpImage.IsEnabled = true; DownImage.IsEnabled = true; } else { IMAGEHead.SelectionMode = ListViewSelectionMode.Single; IMAGEBottom.SelectionMode = ListViewSelectionMode.Single; IMAGE.SelectionMode = ListViewSelectionMode.Single; HambShotList.SelectionMode = ListViewSelectionMode.Single; IMAGEHead.SelectedIndex = -1; IMAGEBottom.SelectedIndex = -1; IMAGE.SelectedIndex = -1; HambShotList.SelectedIndex = -1; UpImage.IsEnabled = false; DownImage.IsEnabled = false; } }
public static string SerializeIMAGE(IMAGE wim) { if (wim == null) { return(string.Empty); } var xmlSerializer = new XmlSerializer(typeof(IMAGE)); using (var stringWriter = new StringWriter()) { using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings { Indent = false, IndentChars = "", NewLineChars = "", NewLineHandling = NewLineHandling.None, OmitXmlDeclaration = true, NewLineOnAttributes = false })) { xmlSerializer.Serialize(xmlWriter, wim); return(stringWriter.ToString().Replace(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", "") .Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "")); } } }
/// <summary> /// Reloads the current image if the <see cref="ImagePath"/> exists. /// </summary> public void ReloadImage() { if (this.ImagePath == null || !File.Exists(this.ImagePath.FullName)) { return; } IMAGE i = ImageHelper.LoadImage(this.ImagePath.FullName); if (i == null) { return; } bool _ = this.DisposeImageOnReplace; bool __ = this.ClearImagePathOnReplace; this.DisposeImageOnReplace = true; this.ClearImagePathOnReplace = false; this.Image = i; this.DisposeImageOnReplace = _; this.ClearImagePathOnReplace = __; }
public ActionResult AddPictures(int id, HttpPostedFileBase file, FormCollection collection) { try { string[] allowedTypes = { "image/jpeg", "image/png", "image/gif" }; string type = file.ContentType; if (file != null && file.ContentLength > 0 && allowedTypes.Contains(type)) { Guid g = Guid.NewGuid(); var fileName = g.ToString() + Path.GetExtension(file.FileName); var path = Path.Combine(Server.MapPath("~/Images/"), fileName); file.SaveAs(path); PRODUCT newfeatPic = new PRODUCT(); // newfeatPic.feature_picture = path; IMAGE newPic = new IMAGE(); newPic.path = fileName; newPic.product_id = id; newPic.description = collection["Description"]; st.IMAGEs.InsertOnSubmit(newPic); st.SubmitChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult UpLoadNew2(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { try { string path = Path.Combine(Server.MapPath("~/Images/product"), Path.GetFileName(file.FileName)); file.SaveAs(path); int id = int.Parse(Session["UpLoadProID"].ToString()); IMAGE img = new IMAGE(); string projectPath = HostingEnvironment.ApplicationPhysicalPath; path = path.Replace(projectPath, "/"); img.Image_Path = path; img.Product_ID = id; db.IMAGEs.Add(img); db.SaveChanges(); } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } var listImg = db.IMAGEs.ToList(); return(View("ListImage", listImg)); }
public static IntPtr CopyImage(IHandle hImage, IMAGE type, int cx, int cy, LR flags) { IntPtr result = CopyImage(hImage.Handle, type, cx, cy, flags); GC.KeepAlive(hImage); return(result); }
public bool Create(IMAGE iMAGES) { try { iMAGES.IMAGE_UploadTime = DateTime.Now; iMAGES.IMAGE_Status = false; db.IMAGEs.Add(iMAGES); db.SaveChanges(); return(true); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }
public JsonResult SaveImg(int id, HttpPostedFileBase file) { if (file == null) { ViewBag.Error = "Vui lòng chọn ảnh!"; } else { if (file != null) { var fileName = DateTime.Now.ToFileTimeUtc() + ".png"; var path = Path.Combine(Server.MapPath("~/Images/"), fileName); file.SaveAs(path); using (BDSEntities db = new BDSEntities()) { db.Database.ExecuteSqlCommand("delete from IMAGE where IdBuild=" + id); IMAGE img = new IMAGE(); img.nameImage = fileName; img.idBuild = id; db.IMAGEs.Add(img); db.SaveChanges(); } } } int response = 1; return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult fileupload(IEnumerable <HttpPostedFileBase> file) { foreach (var f in file) { if (f != null && f.ContentLength > 0) { string pcki = Convert.ToString(Request["pck"]); string extension = Path.GetExtension(f.FileName); var fileName = Path.GetFileName(f.FileName); var p = Server.MapPath("~/Content/Album/"); Directory.CreateDirectory(p); //var fileName = f + extension; var path = Path.Combine(p, fileName); f.SaveAs(path); using (var fileup = new TourCrowDBEntities()) { var qry = new IMAGE { Path = path }; fileup.IMAGEs.Add(qry); } } else { ViewBag.PropicError = "Invalid Photo"; } } //return RedirectToAction("Index", HttpContext.User.Identity.Name.Split('|')[1].ToString()); return(View("Index")); }
public ActionResult DeletePicture(int id) { try { // TODO: Add delete logic here IMAGE picture = (from p in st.IMAGEs where p.Id == id select p).FirstOrDefault(); var prod = from x in st.PRODUCTs where x.Id == picture.Id select x; st.IMAGEs.DeleteOnSubmit(picture); st.SubmitChanges(); deletePicFile(picture); return(RedirectToAction("Index")); } catch { return(View()); } }
/* initialises an image structure to a random position and velocity */ public static void init_image(ref IMAGE image) { image.x = (float)(AL_RAND() % 704); image.y = (float)(AL_RAND() % 568); image.dx = (float)(((AL_RAND() % 255) - 127) / 32.0); image.dy = (float)(((AL_RAND() % 255) - 127) / 32.0); }
public async Task <IHttpActionResult> ImageCreate(int notid) { int userid = UserInf.GetUser(); List <string> path = new List <string>(); var fileuploadPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); var multiFormDataStreamProvider = new MultiFileUploadProvider(fileuploadPath); await Request.Content.ReadAsMultipartAsync(multiFormDataStreamProvider); path = multiFormDataStreamProvider.FileData.Select(x => x.LocalFileName).ToList(); foreach (var item in path) { using (MynoteDBEntities db = new MynoteDBEntities()) { IMAGE img = new IMAGE { ImagePath = item, ImageName = Path.GetFileName(item), NotId = notid, UserId = userid, CreatedDate = DateTime.Now }; db.IMAGES.Add(img); db.SaveChanges(); } } return(Ok()); }
private Substrate(IMAGE target, int seed, COLOR[] palette) : base(target, seed) { _Palette = palette; _CrackGrid = new int[this.Width * this.Height]; _Begin(); }
public ActionResult DeleteConfirmed(short id) { IMAGE iMAGE = db.IMAGE.Find(id); db.IMAGE.Remove(iMAGE); db.SaveChanges(); return(RedirectToAction("Index")); }
public BitmapUndo(IMAGE bmp) { undos = new Stack <BitmapChanges>(); redos = new Stack <BitmapChanges>(); bitmapUndoHistoryData = new Stack <Bitmap>(); bitmapRedoHistoryData = new Stack <Bitmap>(); CurrentBitmap = bmp; }
public void Clear() { ClearHistory(); if (CurrentBitmap != null) { CurrentBitmap.Dispose(); } CurrentBitmap = null; }
/// <summary> /// Dispose of the CurrentBitmap and replace it with the given bitmap. /// </summary> /// <param name="bmp">The new bitmap.</param> public void ReplaceBitmap(Bitmap bmp) { if (CurrentBitmap != null) { CurrentBitmap.Dispose(); } CurrentBitmap = IMAGE.ProperCast(bmp, this.Format); }
public Canvas(IMAGE target, int seed) { _Canvas = target; _Randomizer = new Random(seed); var mode = PixelColorBlendingMode.Normal; // _Blender = PixelOperations<Rgba32>.Instance.GetPixelBlender(mode); _GfxMode = new GraphicsOptions(true, mode, 1); }
public DitherForm(IMAGE img) { if (img == null) { return; } InitializeComponent(); this.Resize += new System.EventHandler(this.MainWindow_Resize); ibMain.AllowClickZoom = false; ibMain.AllowDrop = false; ibMain.LimitSelectionToImage = false; ibMain.DisposeImageBeforeChange = true; ibMain.AutoCenter = true; ibMain.AutoPan = true; ibMain.RemoveSelectionOnPan = InternalSettings.Remove_Selected_Area_On_Pan; ibMain.BorderStyle = BorderStyle.None; ibMain.BackColor = InternalSettings.Image_Box_Back_Color; ibMain.SelectionMode = ImageBoxSelectionMode.Rectangle; ibMain.SelectionButton = MouseButtons.Right; ibMain.PanButton = MouseButtons.Left; ibMain.GridDisplayMode = ImageBoxGridDisplayMode.Image; ibMain.RemoveSelectionOnPan = InternalSettings.Remove_Selected_Area_On_Pan; ibMain.BackColor = InternalSettings.Image_Box_Back_Color; if (InternalSettings.Show_Default_Transparent_Colors) { ibMain.GridColor = InternalSettings.Default_Transparent_Grid_Color; ibMain.GridColorAlternate = InternalSettings.Default_Transparent_Grid_Color_Alternate; } else { ibMain.GridColor = InternalSettings.Current_Transparent_Grid_Color; ibMain.GridColorAlternate = InternalSettings.Current_Transparent_Grid_Color_Alternate; } backgroundWorker.WorkerSupportsCancellation = true; updateThresholdTimer.Interval = InternalSettings.Dither_Threshold_Update_Limit; updateThresholdTimer.Tick += UpdateThresholdTimer_Tick; rb_MonochromeColor.Checked = true; cb_ColorPallete.SelectedIndex = 0; rb_NoDither.Checked = true; originalImage = img; RequestImageTransform(); }
public ActionResult Edit([Bind(Include = "ID_IMAGE,ID_PRODUIT,TYPE_IMAGE,TAILLE_IMAGE,CHEMIN_IMAGE,ORDRE_IMAGE")] IMAGE iMAGE) { if (ModelState.IsValid) { db.Entry(iMAGE).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_PRODUIT = new SelectList(db.PRODUIT, "ID_PRODUIT", "LIBELLE_PRODUIT", iMAGE.ID_PRODUIT); return(View(iMAGE)); }
public static IMAGE SquishImage(this IMAGE srcImage, CompressionMode mode, CompressionOptions options, Action <string> logger) { var srcBitmap = srcImage.ToSquishImage(); var blocks = srcBitmap.Compress(mode, options); var dstBitmap = Bitmap.Decompress(srcImage.Width, srcImage.Height, blocks, mode); logger("\t" + dstBitmap.CompareRGBToOriginal(srcBitmap).ToString()); return(dstBitmap.ToImageSharp()); }
public static IMAGE SquishImage(this IMAGE srcImage, CompressionMode mode, CompressionOptions options, TestContext context) { var srcBitmap = srcImage.ToSquishImage(); var blocks = srcBitmap.Compress(mode, options); var dstBitmap = Bitmap.Decompress(srcImage.Width, srcImage.Height, blocks, mode); context.WriteLine(dstBitmap.CompareRGBToOriginal(srcBitmap).ToString()); return(dstBitmap.ToImageSharp()); }
public ActionResult UploadImage(IMAGE iMAGES, HttpPostedFileBase image) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var dao = new AccountDAO(); var user = dao.GetById(session.UserID); Guid id = Guid.NewGuid(); iMAGES.IMAGE_Id = id; iMAGES.ACCOUNT_Id = session.UserID; iMAGES.FACULTY_Id = user.FACULTY_Id; if (image != null) { string fileName = new ImageDAO().GetCode(new StringHelper().RemoveUnicode(user.ACCOUNT_Name)); string extension = Path.GetExtension(image.FileName); iMAGES.IMAGE_FileName = fileName; fileName += extension; string Url = "/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/" + fileName; fileName = Path.Combine(Server.MapPath("~/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/"), fileName); if (!Directory.Exists(Server.MapPath("~/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/"))) { Directory.CreateDirectory(Server.MapPath("~/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/")); } iMAGES.IMAGE_FileUpload = Url; iMAGES.IMAGE_Type = extension.Replace(".", ""); iMAGES.IMAGE_Size = image.ContentLength; image.SaveAs(fileName); } if (new ImageDAO().Create(iMAGES)) { try { string content = System.IO.File.ReadAllText(Server.MapPath("~/Views/templates/UploadImage.html")); content = content.Replace("{{student}}", user.ACCOUNT_Username); content = content.Replace("{{domain}}", Request.Url.Host); content = content.Replace("{{image}}", iMAGES.IMAGE_FileName); content = content.Replace("{{username}}", dao.GetAccountCoordinator(user.FACULTY_Id).ACCOUNT_Username); new MailHelper().SendMail(dao.GetAccountCoordinator(user.FACULTY_Id).ACCOUNT_Email, "University Magazine", content, "Student upload file"); } catch (Exception) { SetAlert("Email sending failed!", "warning"); } SetAlert("Added successfully!", "success"); } else { SetAlert("Add failed!", "warning"); } return(RedirectToAction("UploadImage")); }
// GET: Administration/Image/Details/5 public ActionResult Details(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IMAGE iMAGE = db.IMAGE.Find(id); if (iMAGE == null) { return(HttpNotFound()); } return(View(iMAGE)); }
public static IMAGE ToImageSharp(this Bitmap image) { var dst = new IMAGE(image.Width, image.Height); for (int y = 0; y < dst.Height; ++y) { for (int x = 0; x < dst.Width; ++x) { dst[x, y] = new SixLabors.ImageSharp.PixelFormats.Rgba32(image[x, y]); } } return(dst); }
public static Bitmap ToSquishImage(this IMAGE image) { var dst = new Bitmap(image.Width, image.Height); for (int y = 0; y < dst.Height; ++y) { for (int x = 0; x < dst.Width; ++x) { dst[x, y] = image[x, y].Rgba; } } return(dst); }
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show("Failed to transform image. " + e.Error.GetBaseException().Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!e.Cancelled) { ibMain.Image = IMAGE.ProperCast(e.Result as Bitmap, originalImage.GetImageFormat()); } Cursor.Current = Cursors.Default; this.UseWaitCursor = false; }
public static extern IntPtr LoadImage(IntPtr hInst, [MarshalAs(UnmanagedType.LPTStr)] string lpszName, IMAGE uType, int cxDesired, int cyDesired, LR fuLoad);
public static extern IntPtr LoadImage(IntPtr hInst, IntPtr lpszName, IMAGE uType, int cxDesired, int cyDesired, LR fuLoad);
public static extern IntPtr LoadImage(Microsoft.Win32.SafeHandles.SafeLibraryHandle hInst, [MarshalAs(UnmanagedType.LPTStr)] string lpszName, IMAGE uType, int cxDesired, int cyDesired, LR fuLoad);
public static extern IntPtr LoadImage(Microsoft.Win32.SafeHandles.SafeLibraryHandle hInst, IntPtr lpszName, IMAGE uType, int cxDesired, int cyDesired, LR fuLoad);