コード例 #1
0
        public VImageModel GetImage(Ctx ctx, int ad_image_id, int size)
        {
            VImageModel obj   = new VImageModel();
            MImage      mimg  = new MImage(ctx, ad_image_id, null);
            var         value = mimg.GetThumbnailByte(size, size);

            if (value != null)
            {
                obj.UsrImage = Convert.ToBase64String(value);
                //obj.UsrImage = Convert.ToBase64String(mimg.GetBinaryData());
            }
            return(obj);
        }
コード例 #2
0
        public void GetImage(Ctx ctx, int ad_image_id, int size)
        {
            MImage mimg  = new MImage(ctx, ad_image_id, null);
            var    value = mimg.GetThumbnailByte(size, size);

            if (value != null)
            {
                UsrImage = Convert.ToBase64String(value);
                //obj.UsrImage = Convert.ToBase64String(mimg.GetBinaryData());
                if (mimg.GetBinaryData() != null)
                {
                    Isdatabase = true;
                }
            }
        }
コード例 #3
0
 public JsonResult SaveImageAsByte(HttpPostedFileBase file)
 {
     try
     {
         HttpPostedFileBase hpf = file as HttpPostedFileBase;
         if (!Directory.Exists(Path.Combine(Server.MapPath("~/Images"), "Temp")))
         {
             Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Images"), "Temp"));       //Create Thumbnail Folder if doesnot exists
         }
         string savedFileName = Path.Combine(Server.MapPath("~/Images/Temp"), Path.GetFileName(hpf.FileName));
         hpf.SaveAs(savedFileName);
         MemoryStream ms = new MemoryStream();
         hpf.InputStream.CopyTo(ms);
         byte[]   byteArray = ms.ToArray();
         FileInfo file1     = new FileInfo(savedFileName);
         if (file1.Exists)
         {
             file1.Delete(); //Delete Temporary file
         }
         Ctx ctx = Session["ctx"] as Ctx;
         //string imgByte = Convert.ToBase64String(byteArray);
         HomeModels objHomeModel = new HomeModels();
         int        imageID      = objHomeModel.SaveUserImage(ctx, byteArray, hpf.FileName, false);
         if (imageID <= 0)
         {
             return(Json(JsonConvert.SerializeObject(null), JsonRequestBehavior.AllowGet));
         }
         MImage objImage = new MImage(ctx, imageID, null);
         string imgByte  = Convert.ToBase64String(objImage.GetThumbnailByte(140, 120));
         return(Json(JsonConvert.SerializeObject(imgByte), JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(Json(JsonConvert.SerializeObject(null), JsonRequestBehavior.AllowGet));
     }
 }
コード例 #4
0
        private string GetUserImage(int imageID)
        {
            string image = string.Empty;

            if (imageID > 0)
            {
                MImage objImage = new MImage(ctx, imageID, null);
                // byte[] imageByte = objImage.GetThumbnailByte(320, 185);
                byte[] imageByte = objImage.GetThumbnailByte(320, 240);
                if (imageByte != null)
                {
                    image = "data:image/jpg;base64," + Convert.ToBase64String(imageByte);
                }
                else
                {
                    image = "Areas/VIS/Images/home/User.png";
                }
            }
            else
            {
                image = "Areas/VIS/Images/home/User.png";
            }
            return(image);
        }