Esempio n. 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            cat.EnableValidation = true;

            if (string.IsNullOrEmpty(cat.Error))
            {
                if (!string.IsNullOrEmpty(file_selected))
                {
                    string ext = Path.GetExtension(file_selected);

                    string fileName = Path.GetRandomFileName() + ext;

                    string fileSavePath = Path.Combine(Directory.GetCurrentDirectory(),
                                                       "images", fileName);

                    var bmp = ResizeImage.ResizeOrigImg(
                        new Bitmap(System.Drawing.Image.FromFile(file_selected)), 75, 75);

                    bmp.Save(fileSavePath, ImageFormat.Jpeg);

                    file_name = fileSavePath;
                }
                var cat_info =
                    new AppCat
                {
                    Name        = tbname.Text,
                    Birth       = (DateTime)bdcat.SelectedDate,
                    Description = tbdesc.Text,
                    Gender      = cbitem.Text.ToString(),
                    Image       = file_name
                };
                cat_info.AppCatPrices = new List <AppCatPrice>
                {
                    new AppCatPrice
                    {
                        CatId      = cat_info.Id,
                        DateCreate = DateTime.Now,
                        Price      = decimal.Parse(tbprice.Text)
                    }
                };

                _cats.Add(new CatVM
                {
                    Id          = cat_info.Id.ToString(),
                    Name        = cat_info.Name,
                    Birthday    = cat_info.Birth,
                    Description = cat_info.Description,
                    Image       = cat_info.Image
                });

                _context.Add(cat_info);
                _context.SaveChanges();

                Close();
            }
            else
            {
                MessageBox.Show(cat.Error);
            }
        }
Esempio n. 2
0
    public void SetHeight()
    {
        height = float.Parse(h.text.Trim());



        float a, b;

        //a = (float)resizeImage.aspectRatio.width;
        // b = (float)resizeImage.aspectRatio.height;
        a = (float)ResizeImage.GetImageWidth(resizeImage.aspectRatio);
        b = (float)ResizeImage.GetImageHeight(resizeImage.aspectRatio);
        float temp = Convert.ToSingle(a / b);

        if (temp < 1)
        {
            temp = Convert.ToSingle(b / a);
        }

        Debug.Log("Aspect " + temp);
        if (a > b)
        {
            resizeImage.plane.transform.localScale = new Vector3(-height * temp, resizeImage.plane.transform.localScale.y, height);
        }
        else
        {
            resizeImage.plane.transform.localScale = new Vector3(-height / temp, resizeImage.plane.transform.localScale.y, height);
        }
    }
Esempio n. 3
0
        private async Task AddPicture(Patient patient, IFormFile thePicture)
        {
            //get the picture and save it with the Patient
            if (thePicture != null)
            {
                string mimeType   = thePicture.ContentType;
                long   fileLength = thePicture.Length;
                if (!(mimeType == "" || fileLength == 0))//Looks like we have a file!!!
                {
                    if (mimeType.Contains("image"))
                    {
                        PatientPhoto p = new PatientPhoto
                        {
                            FileName = Path.GetFileName(thePicture.FileName)
                        };
                        using (var memoryStream = new MemoryStream())
                        {
                            await thePicture.CopyToAsync(memoryStream);

                            p.PhotoContentFull.Content   = memoryStream.ToArray();
                            p.PhotoContentFull.MimeType  = mimeType;
                            p.PhotoContentThumb.Content  = ResizeImage.shrinkImagePNG(p.PhotoContentFull.Content);
                            p.PhotoContentThumb.MimeType = "image/png";
                        }
                        patient.PatientPhoto = p;
                    }
                }
            }
        }
Esempio n. 4
0
 public override void OnOpening()
 {
     content = new ListItems();
     content.Add(new SingleItem
     {
         Label = "First Item"
         ,
         SuperTip = "The First Item"
         ,
         Image = ResizeImage.Resize(Properties.Resources.one, 16, 16)
     });
     content.Add(new SingleItem
     {
         Label = "Second Item"
         ,
         SuperTip = "The Second Item"
         ,
         Image = ResizeImage.Resize(Properties.Resources.two, 16, 16)
     });
     content.Add(new SingleItem
     {
         Label = "Third Item"
         ,
         SuperTip = "The Third Item"
         ,
         Image = ResizeImage.Resize(Properties.Resources.three, 16, 16)
     });
 }
 public ResizeImageTests()
 {
     _fileRepository = new Mock <IFileRepository>();
     _imageHandler   = new Mock <IImageHandler>();
     _logger         = new Mock <ILogger <ResizeImage> >();
     _function       = new ResizeImage(_fileRepository.Object, _imageHandler.Object);
 }
Esempio n. 6
0
        public ActionResult UrunDuzenle(UrunViewModel uvm, HttpPostedFileBase file)
        {
            var filename = ImageNameGenerator.ProfilFotoIsmiUret(file);
            var path     = "null";

            uvm.Fotograf = filename;
            UrunYonetici uy = new UrunYonetici();
            BusinessLayerResult <Urun> res = new BusinessLayerResult <Urun>();

            if (file != null)
            {
                //filename = Path.GetFileName(file[0].FileName);
                path = Path.Combine(Server.MapPath("~/Content/Image/Urun"), filename);
                Image imgnew = ResizeImage.Resize(Image.FromStream(file.InputStream), 0, 473); //son eklediğim alan
                //file[0].SaveAs(path);
                imgnew.Save(path);
            }
            if (res.Errors.Count > 0)
            {
                res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                return(View(uvm));
            }
            if (ModelState.IsValid)
            {
                Urun             urnyeni = uy.Find(x => x.ilanId == uvm.IlanId);
                RenkYonetici     ry      = new RenkYonetici();
                SehirYonetici    sy      = new SehirYonetici();
                KategoriYonetici ky      = new KategoriYonetici();
                if (uvm.takasdegeri == "UYGUN")
                {
                    uvm.Takas = true;
                }
                else
                {
                    uvm.Takas = false;
                }
                //Burayı düzelt...
                urnyeni.ilanId         = uvm.IlanId;
                urnyeni.urunBaslik     = uvm.UrunBaslik;
                urnyeni.urunFiyati     = uvm.UrunFiyat;
                urnyeni.renkId         = ry.Find(x => x.renkAdi == uvm.UrunRenkAdi).renkId;
                urnyeni.urunKonum      = uvm.UrunKonum;
                urnyeni.ilPlaka        = sy.Find(x => x.ilAdi == uvm.SehirAlani).ilPlaka;
                urnyeni.kategoriId     = ky.Find(x => x.kategoriAdi == uvm.KategoriAdi).kategoriId;
                urnyeni.takasyapilirmi = uvm.Takas;
                urnyeni.durumu         = uvm.durumu;
                urnyeni.urunAciklama   = uvm.UrunAciklama;
                urnyeni.halasatilikmi  = true;
                urnyeni.kullaniciId    = App.Common.GetCurrentUsernameId();
                //urnyeni.satistarihsaat = DateTime.Now; //Ürün güncellendiği zaman yükleme tarihi aynı kalsın
                if (file != null)
                {
                    urnyeni.urunFotosu = filename;
                }

                uy.Update(urnyeni);
                return(RedirectToAction("Sattiklarim", "Profil"));
            }
            return(View(uvm));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Title title, IFormFile titleImage)
        {
            if (ModelState.IsValid)
            {
                if (titleImage != null)
                {
                    string mimeType   = titleImage.ContentType;
                    long   fileLength = titleImage.Length;
                    if (!(mimeType == "" || fileLength == 0))
                    {
                        using (var memoryStream = new MemoryStream())
                        {
                            await titleImage.CopyToAsync(memoryStream);

                            title.TitleImageContent = ResizeImage.shrinkImagePNG(memoryStream.ToArray(), 150, 150);
                        }
                        title.TitleImageMimeType = mimeType;
                        title.TitleImageFileName = titleImage.FileName;
                    }
                }

                _context.Add(title);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(title));
        }
Esempio n. 8
0
        public override void OnOpening()
        {
            AddinContext.ExcelApp.SheetChangeEvent += (a, e) => Ribbon.Invalidate();

            content = new ListItems();
            content.Add(new SingleItem {
                Label    = "First Item",
                SuperTip = "The first Item",
                Image    = ResizeImage.Resize(Properties.Resources.one, 16, 16)
            });
            content.Add(new SingleItem {
                Label    = "Second Item",
                SuperTip = "The second Item",
                Image    = ResizeImage.Resize(Properties.Resources.two, 16, 16)
            });
            content.Add(new SingleItem {
                Label    = "Third Item",
                SuperTip = "The third Item",
                Image    = ResizeImage.Resize(Properties.Resources.three, 16, 16)
            });
            content.Add(new SingleItem {
                Label    = "Fourth Item",
                SuperTip = "The fourth Item",
                Image    = ResizeImage.Resize(Properties.Resources.four, 16, 16)
            });
            content.Add(new SingleItem {
                Label    = "Fifth Item",
                SuperTip = "The fifth Item",
                Image    = ResizeImage.Resize(Properties.Resources.five, 16, 16)
            });

            GallerySelectedIndex = 0;

            this.CreateRibbonCommand(_commands);
        }
    private IEnumerator LoadImage(string str)
    {
        using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(str))
        {
            yield return(uwr.SendWebRequest());

            if (uwr.isNetworkError || uwr.isHttpError)
            {
                Debug.Log(uwr.error);
            }
            else
            {
                txt = new Texture2D(2, 2, TextureFormat.RGB24, false);

                txt = DownloadHandlerTexture.GetContent(uwr);

                ResizeImage rimage = this.gameObject.AddComponent <ResizeImage>();

                txt = rimage.ScaleTexture(txt);

                BildRawData brd = new BildRawData();

                brd.BildHight = txt.height;
                brd.BildWidth = txt.width;
                brd.BildRaw   = txt.GetRawTextureData();

                speise.Bild = brd;

                UpdateInput();
            }
        }
    }
Esempio n. 10
0
        public async Task <IActionResult> Create([Bind("Id,Name,TitleId")] Issue issue, IFormFile coverImage)
        {
            if (ModelState.IsValid)
            {
                if (coverImage != null)
                {
                    string mimeType   = coverImage.ContentType;
                    long   fileLength = coverImage.Length;
                    if (!(mimeType == "" || fileLength == 0))
                    {
                        using (var memoryStream = new MemoryStream())
                        {
                            await coverImage.CopyToAsync(memoryStream);

                            issue.CoverImageContent = ResizeImage.shrinkImagePNG(memoryStream.ToArray(), 150, 150);
                        }
                        issue.CoverImageMimeType = mimeType;
                        issue.CoverImageFileName = coverImage.FileName;
                    }
                }

                _context.Add(issue);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TitleId"] = new SelectList(_context.Titles, "Id", "Id", issue.TitleId);
            return(View(issue));
        }
Esempio n. 11
0
        public void When_distorting_images_while_resizing_we_get_our_exact_requested_size()
        {
            var image = new ResizeImage(base.GetDemoImagePath())
                .Distort()
                .ToSize(300, 300)
                .Save();

            image.Width.Should().Be(300);
            image.Height.Should().Be(300);
        }
Esempio n. 12
0
    public void SetPictureSize()
    {
        height = float.Parse(h.text.Trim());
        width  = float.Parse(w.text.Trim());
        depth  = float.Parse(d.text.Trim());



        float a, b;

        //a = (float)resizeImage.aspectRatio.width;
        // b = (float)resizeImage.aspectRatio.height;
        a = (float)ResizeImage.GetImageWidth(resizeImage.aspectRatio);
        b = (float)ResizeImage.GetImageHeight(resizeImage.aspectRatio);
        float temp = Convert.ToSingle(a / b);

        Debug.Log(temp);
        if (width > 0.0f)
        {
            if (temp < 1)
            {
                temp = Convert.ToSingle(b / a);
            }

            Debug.Log("Aspect " + temp);

            if (a > b)
            {
                resizeImage.plane.transform.localScale = new Vector3(-width, resizeImage.plane.transform.localScale.y, width / temp);
            }
            else
            {
                resizeImage.plane.transform.localScale = new Vector3(-width, resizeImage.plane.transform.localScale.y, width * temp);
            }
        }
        else if (height > 0.0f)
        {
            if (temp < 1)
            {
                temp = Convert.ToSingle(b / a);
            }

            Debug.Log("Aspect " + temp);
            if (a > b)
            {
                resizeImage.plane.transform.localScale = new Vector3(-height * temp, resizeImage.plane.transform.localScale.y, height);
            }
            else
            {
                resizeImage.plane.transform.localScale = new Vector3(-height / temp, resizeImage.plane.transform.localScale.y, height);
            }
        }

        //Debug.Log(width);
    }
Esempio n. 13
0
        public static FadeInImage assetNetwork(
            string placeholder,
            string image,
            ImageErrorWidgetBuilder placeholderErrorBuilder = null,
            ImageErrorWidgetBuilder imageErrorBuilder       = null,
            AssetBundle bundle       = null,
            float?placeholderScale   = null,
            float imageScale         = 1.0f,
            TimeSpan?fadeOutDuration = null,
            Curve fadeOutCurve       = null,
            TimeSpan?fadeInDuration  = null,
            Curve fadeInCurve        = null,
            float?width  = null,
            float?height = null,
            BoxFit?fit   = null,
            AlignmentGeometry alignment = null,
            ImageRepeat repeat          = ImageRepeat.noRepeat,
            bool matchTextDirection     = false,
            Key key = null,
            int?placeholderCacheWidth  = null,
            int?placeholderCacheHeight = null,
            int?imageCacheWidth        = null,
            int?imageCacheHeight       = null
            )
        {
            fadeOutDuration = fadeOutDuration ?? new TimeSpan(0, 0, 0, 0, 300);
            fadeOutCurve    = fadeOutCurve ?? Curves.easeOut;
            fadeInDuration  = fadeInDuration ?? new TimeSpan(0, 0, 0, 0, 700);
            fadeInCurve     = Curves.easeIn;
            alignment       = alignment ?? Alignment.center;
            var holder       = placeholderScale ?? 1.0f;
            var _placeholder = placeholderScale != null
                ? ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
                                             new ExactAssetImage(placeholder, bundle : bundle, scale : holder))
                               : ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
                                                            new AssetImage(placeholder, bundle : bundle));

            return(new FadeInImage(
                       placeholder: _placeholder,
                       placeholderErrorBuilder: placeholderErrorBuilder,
                       image: ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, new NetworkImage(image, scale: imageScale)),
                       imageErrorBuilder: imageErrorBuilder,
                       fadeOutDuration: fadeOutDuration,
                       fadeOutCurve: fadeOutCurve,
                       fadeInDuration: fadeInDuration,
                       fadeInCurve: fadeInCurve,
                       width: width, height: height,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       matchTextDirection: matchTextDirection,
                       key: key
                       ));
        }
Esempio n. 14
0
        public static bool Upload(byte[] stream, string name2Save, string folder2Save, int width, int height, long quality)
        {
            var path = HttpContext.Current.Server.MapPath(folder2Save);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path = Path.Combine(path, name2Save);
            ResizeImage.ImageResize(stream, path, 90, width, height);
            return(true);
        }
Esempio n. 15
0
        public static FadeInImage memoryNetwork(
            byte[] placeholder,
            string image,
            Key key = null,
            ImageErrorWidgetBuilder placeholderErrorBuilder = null,
            ImageErrorWidgetBuilder imageErrorBuilder       = null,
            float placeholderScale   = 1.0f,
            float imageScale         = 1.0f,
            TimeSpan?fadeOutDuration = null,
            Curve fadeOutCurve       = null,
            TimeSpan?fadeInDuration  = null,
            Curve fadeInCurve        = null,
            float?width  = null,
            float?height = null,
            BoxFit?fit   = null,
            AlignmentGeometry alignment = null,
            ImageRepeat repeat          = ImageRepeat.noRepeat,
            bool matchTextDirection     = false,
            int?placeholderCacheWidth   = null,
            int?placeholderCacheHeight  = null,
            int?imageCacheWidth         = null,
            int?imageCacheHeight        = null
            )
        {
            alignment       = alignment ?? Alignment.center;
            fadeOutDuration = fadeOutDuration ?? TimeSpan.FromMilliseconds(300);
            fadeOutCurve    = fadeOutCurve ?? Curves.easeOut;
            fadeInDuration  = fadeInDuration ?? TimeSpan.FromMilliseconds(700);
            fadeInCurve     = fadeInCurve ?? Curves.easeIn;
            ImageProvider memoryImage  = new MemoryImage(placeholder, placeholderScale);
            ImageProvider networkImage = new NetworkImage(image, imageScale);

            //placeholder = ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, memoryImage);
            //image = ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, networkImage);
            return(new FadeInImage(
                       placeholder: ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, memoryImage),
                       placeholderErrorBuilder: placeholderErrorBuilder,
                       image: ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, networkImage),
                       imageErrorBuilder: imageErrorBuilder,
                       fadeOutDuration: fadeOutDuration,
                       fadeOutCurve: fadeOutCurve,
                       fadeInDuration: fadeInDuration,
                       fadeInCurve: fadeInCurve,
                       width: width, height: height,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       matchTextDirection: matchTextDirection,
                       key: key
                       ));
        }
Esempio n. 16
0
        public static Image asset(
            string name,
            Key key                              = null,
            AssetBundle bundle                   = null,
            ImageFrameBuilder frameBuilder       = null,
            ImageErrorWidgetBuilder errorBuilder = null,
            float?scale                          = null,
            float?width                          = null,
            float?height                         = null,
            Color color                          = null,
            BlendMode colorBlendMode             = BlendMode.srcIn,
            BoxFit?fit                           = null,
            Alignment alignment                  = null,
            ImageRepeat repeat                   = ImageRepeat.noRepeat,
            Rect centerSlice                     = null,
            bool matchTextDirection              = false,
            bool gaplessPlayback                 = false,
            string package                       = null,
            FilterQuality filterQuality          = FilterQuality.low,
            int?cacheWidth                       = default,
            int?cacheHeight                      = null
            )
        {
            var _scale = scale ?? 1.0f;
            var _image = scale != null
                ? (AssetBundleImageProvider) new ExactAssetImage(assetName: name, bundle: bundle, scale: _scale)
                : new AssetImage(assetName: name, bundle: bundle);
            var _Image = ResizeImage.resizeIfNeeded(cacheWidth: cacheWidth, cacheHeight: cacheHeight, provider: _image);

            return(new Image(
                       key: key,
                       image: _Image,
                       frameBuilder: frameBuilder,
                       null,
                       errorBuilder: errorBuilder,
                       width: width,
                       height: height,
                       color: color,
                       colorBlendMode: colorBlendMode,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       centerSlice: centerSlice,
                       matchTextDirection: matchTextDirection,
                       gaplessPlayback: gaplessPlayback,
                       filterQuality: filterQuality
                       ));
        }
Esempio n. 17
0
        public static bool Upload(byte[] stream, string name2Save, string folder2Save)
        {
            var path = HttpContext.Current.Server.MapPath(folder2Save);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path = Path.Combine(path, name2Save);
            if (File.Exists(path))
            {
                File.Delete(path);                    //If exists then delete file
            }
            ResizeImage.ImageNoResize(stream, path, 90);
            return(true);
        }
Esempio n. 18
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Title title, IFormFile titleImage)
        {
            if (id != title.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (titleImage != null)
                    {
                        string mimeType   = titleImage.ContentType;
                        long   fileLength = titleImage.Length;
                        if (!(mimeType == "" || fileLength == 0))
                        {
                            using (var memoryStream = new MemoryStream())
                            {
                                await titleImage.CopyToAsync(memoryStream);

                                title.TitleImageContent = ResizeImage.shrinkImagePNG(memoryStream.ToArray(), 150, 150);
                            }
                            title.TitleImageMimeType = mimeType;
                            title.TitleImageFileName = titleImage.FileName;
                        }
                    }

                    _context.Update(title);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TitleExists(title.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(title));
        }
        public ActionResult Hesabim(KullaniciViewModel kvm, List <HttpPostedFileBase> file)
        {
            var filename = ImageNameGenerator.ProfilFotoIsmiUret(file[0]);
            var path     = "null";

            kvm.fotograf = filename;
            KullaniciYönetici ky   = new KullaniciYönetici();
            Kullanici         klnc = Session["giris"] as Kullanici;
            BusinessLayerResult <Kullanici> res = new BusinessLayerResult <Kullanici>();

            if (klnc != null)
            {
                kvm.KullaniciId = klnc.kullaniciId;
            }
            res = ky.KullaniciGuncelle(kvm, file[0]);
            if (file[0] != null)
            {
                //filename = Path.GetFileName(file[0].FileName);
                path = Path.Combine(Server.MapPath("~/Content/Image/Profil"), filename);
                Image imgnew = ResizeImage.Resize(Image.FromStream(file[0].InputStream), 0, 473);  //son eklediğim alan

                //file[0].SaveAs(path);
                imgnew.Save(path);
            }
            if (res.Errors.Count > 0)
            {
                res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                return(View(kvm));
            }
            if (file != null && file.Count > 1)
            {
                for (int i = 1; i <= file.Count - 1; i++)
                {
                    if (file != null && file[i].ContentLength > 0)
                    {
                        filename     = Path.GetFileName(file[i].FileName);
                        path         = Path.Combine(Server.MapPath("~/Content/Image/Profil"), filename);
                        kvm.fotograf = file[i].FileName;
                        KullaniciYönetici ky1 = new KullaniciYönetici();
                        BusinessLayerResult <KullaniciFoto> res1 = ky1.KullaniciFotosuYukle(kvm.Username, file[i]);
                        file[i].SaveAs(path);
                    }
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            ResizeImage resizeImage = new ResizeImage();
            AddImage    addImagi    = new AddImage();

            string[] images;
            resizeImage.Notify += DisplayEvent;

            addImagi.PathImage(@"C:\Users\Mikalai\source\repos\MultithreadingResizeJPG\drawings", out images);

            foreach (var j in images)
            {
                ThreadPool.QueueUserWorkItem(resizeImage.ResizedImagen, j);
            }

            Console.ReadKey();
        }
Esempio n. 21
0
        public static Image network(
            string src,
            Key key     = null,
            float scale = 1.0f,
            ImageFrameBuilder frameBuilder       = null,
            ImageLoadingBuilder loadingBuilder   = null,
            ImageErrorWidgetBuilder errorBuilder = null,
            float?width              = null,
            float?height             = null,
            Color color              = null,
            BlendMode colorBlendMode = BlendMode.srcIn,
            BoxFit?fit = null,
            AlignmentGeometry alignment          = null,
            ImageRepeat repeat                   = ImageRepeat.noRepeat,
            Rect centerSlice                     = null,
            bool gaplessPlayback                 = false,
            bool matchTextDirection              = false,
            FilterQuality filterQuality          = FilterQuality.low,
            IDictionary <string, string> headers = null,
            int?cacheWidth  = null,
            int?cacheHeight = null
            )
        {
            var image = ResizeImage.resizeIfNeeded(cacheWidth: cacheWidth, cacheHeight: cacheHeight,
                                                   new NetworkImage(url: src, scale: scale, headers: headers));

            return(new Image(
                       key: key,
                       image: image,
                       frameBuilder: frameBuilder,
                       loadingBuilder: loadingBuilder,
                       errorBuilder: errorBuilder,
                       width: width,
                       height: height,
                       color: color,
                       colorBlendMode: colorBlendMode,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       centerSlice: centerSlice,
                       matchTextDirection: matchTextDirection,
                       gaplessPlayback: gaplessPlayback,
                       filterQuality: filterQuality
                       ));
        }
Esempio n. 22
0
        public void It_calculates_constain_correctly()
        {
            var resizedImage = new ResizeImage(theImage)
                .Constrain()
                .ToSize(200, 200)
                .Save();

            resizedImage.Width.Should().Be(200);
            resizedImage.Height.Should().Be(150);

            resizedImage = new ResizeImage(theImage)
                .Constrain()
                .ToSize(465, 250)
                .Save();

            resizedImage.Width.Should().Be(333);
            resizedImage.Height.Should().Be(250);
        }
Esempio n. 23
0
    public IEnumerator LoadFromURLRoutine(Image mediaObj, string mediaPath, bool resizeToFill)
    {
        var mediaRequest = new WWW(mediaPath);

        yield return(mediaRequest);

        if (string.IsNullOrEmpty(mediaRequest.error))
        {
            mediaObj.sprite = Sprite.Create(mediaRequest.texture, new Rect(0, 0, mediaRequest.texture.width, mediaRequest.texture.height), new Vector2(0.5f, 0.5f));

            if (resizeToFill)
            {
                ResizeImage.ResizeToFill(mediaRequest.texture, mediaObj.rectTransform);
            }
        }

        mediaRequest.Dispose();
    }
Esempio n. 24
0
        public static Image memory(
            byte[] bytes,
            Key key     = null,
            float scale = 1.0f,
            ImageFrameBuilder frameBuilder       = null,
            ImageErrorWidgetBuilder errorBuilder = null,
            float?width              = null,
            float?height             = null,
            Color color              = null,
            BlendMode colorBlendMode = BlendMode.srcIn,
            BoxFit?fit                  = null,
            Alignment alignment         = null,
            ImageRepeat repeat          = ImageRepeat.noRepeat,
            Rect centerSlice            = null,
            bool matchTextDirection     = false,
            bool gaplessPlayback        = false,
            FilterQuality filterQuality = FilterQuality.low,
            int?cacheWidth              = default,
            int?cacheHeight             = null
            )
        {
            // ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, MemoryImage(bytes, scale: scale));
            var memoryImage = new MemoryImage(bytes: bytes, scale: scale);

            return(new Image(
                       key: key,
                       ResizeImage.resizeIfNeeded(cacheWidth: cacheWidth, cacheHeight: cacheHeight,
                                                  new MemoryImage(bytes: bytes, scale: scale)),
                       frameBuilder: frameBuilder,
                       null,
                       errorBuilder: errorBuilder,
                       width: width,
                       height: height,
                       color: color,
                       colorBlendMode: colorBlendMode,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       centerSlice: centerSlice,
                       matchTextDirection: matchTextDirection,
                       gaplessPlayback: gaplessPlayback,
                       filterQuality: filterQuality
                       ));
        }
Esempio n. 25
0
        public ImageResult ResizeImage(ResizeImage resizeParam)
        {
            var result = new ImageResult
            {
                Message = OpMessage.Success
            };

            try
            {
                imageFactory.Resize(new Size(resizeParam.Param.Heigth, resizeParam.Param.Width)).Save(outStream);
            }
            catch (Exception ex)
            {
                result.Message = OpMessage.InvalidInputParameter;
                return(result);
            }
            result.Result = outStream.ToArray();
            return(result);
        }
Esempio n. 26
0
        private string UploadImage(int id)
        {
            string returns = "";
            var    ext     = Path.GetExtension(upHinhanh.FileName).ToLower();

            if (ext.Equals(".jpg") || ext.Equals(".png") || ext.Equals(".jpeg"))
            {
                var filename = UnicodeUtility.UrlRewriting(txtTenTin.Text);
                var path     = Server.MapPath("~/images/news/" + id / 200 + "/" + id + "/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                upHinhanh.SaveAs(path + filename + ext);
                ResizeImage.ImageCrop(upHinhanh.FileBytes, path + "168.109." + filename + ext, 168, 109, 60);
                returns = filename + ext;
            }
            return(returns);
        }
Esempio n. 27
0
        public MeasurementPointPhoto GetMeasurementPointPhotoThumbnail(int photoId)
        {
            var photo = _context.MEASUREPOINT_RECORD_IMAGES.Find(photoId);

            if (photo == null || photo.Data == null)
            {
                return(new MeasurementPointPhoto()
                {
                    Id = -1
                });
            }

            return(new MeasurementPointPhoto()
            {
                Id = photoId,
                Title = photo.Title,
                Comment = photo.Comment,
                Photo = Convert.ToBase64String(ResizeImage.GetThumbnail(photo.Data))
            });
        }
Esempio n. 28
0
        private string UploadImage(int id)
        {
            string returns = "";
            var    ext     = Path.GetExtension(Upload_Images.FileName).ToLower();

            if (ext.Equals(".jpg") || ext.Equals(".png") || ext.Equals(".jpeg"))
            {
                var filename = UnicodeUtility.UrlRewriting(TB_Name.Text);
                var path     = Server.MapPath("~/images/product/" + id / 200 + "/" + id + "/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                Upload_Images.SaveAs(path + filename + ext);
                ResizeImage.ImageCrop(Upload_Images.FileBytes, path + "208.129." + filename + ext, 208, 129, 60);
                ResizeImage.ImageCrop(Upload_Images.FileBytes, path + "256.158." + filename + ext, 256, 158, 60);
                returns = filename + ext;
            }
            return(returns);
        }
Esempio n. 29
0
        public EquipmentPhotosViewModel GetCompartMandatoryImagePhotoThumbnail(int photoId)
        {
            var photo = _context.INSPECTION_COMPARTTYPE_IMAGES.Find(photoId);

            if (photo == null || photo.Data == null)
            {
                return(new EquipmentPhotosViewModel()
                {
                    Id = -1
                });
            }

            return(new EquipmentPhotosViewModel()
            {
                Id = photoId,
                Title = photo.Title,
                Description = photo.Comment,
                Photo = Convert.ToBase64String(ResizeImage.Get160by120(photo.Data))
            });
        }
Esempio n. 30
0
        public void AddMetaDataAndProcessImage(ImageModel image, string inputPath, string outputPath)
        {
            var imageList = imageMetadata.Images.ToList();
            var nextId    = imageList.Last().Id + 1;

            var newImageModel = new ImageModel
            {
                Id       = nextId,
                Location = image.Location,
                Name     = image.Name,
                Filename = $"{nextId}_{image.Name}"
            };

            ResizeImage.Process(inputPath, $@"{outputPath}\raw\{newImageModel.Filename}", ResizeImage.ImageType.Raw);
            ResizeImage.Process(inputPath, $@"{outputPath}\preview\{newImageModel.Filename}", ResizeImage.ImageType.Preview);
            ResizeImage.Process(inputPath, $@"{outputPath}\thumbnail\{newImageModel.Filename}", ResizeImage.ImageType.Thumbnail);

            imageList.Add(newImageModel);
            imageMetadata.Images = imageList;
        }
Esempio n. 31
0
    public IEnumerator LoadFromURLRoutine(List <Image> mediaObjList, List <string> mediaPathList, bool resizeToFill)
    {
        for (int i = 0; i < mediaPathList.Count; i++)
        {
            var mediaRequest = new WWW(mediaPathList[i]);
            yield return(mediaRequest);

            if (string.IsNullOrEmpty(mediaRequest.error))
            {
                mediaObjList[i].sprite = Sprite.Create(mediaRequest.texture, new Rect(0, 0, mediaRequest.texture.width, mediaRequest.texture.height), new Vector2(0.5f, 0.5f));

                if (resizeToFill)
                {
                    ResizeImage.ResizeToFill(mediaRequest.texture, mediaObjList[i].rectTransform);
                }
            }

            mediaRequest.Dispose();
        }
    }
Esempio n. 32
0
        private List <ImageDTO> backgroundPreprocessing(List <ImageDTO> imageDTOs, List <ListView> inFormListView)
        {
            int    lengthGaussianFilter  = Convert.ToInt32(numLengthGaussian.Value);
            double weightGaussianFilter  = Convert.ToDouble(numWeightGaussian.Value);
            var    imageListGrayscalling = new ImageList {
                ImageSize = new Size(200, 200)
            };
            var imageListGaussian = new ImageList {
                ImageSize = new Size(200, 200)
            };
            var imageListBinary = new ImageList {
                ImageSize = new Size(200, 200)
            };

            Parallel.For(0, imageDTOs.Count, i =>
            {
                ImageDTO imageDTO     = imageDTOs[i];
                preprocessing         = new Preprocessing.Preprocessing(imageDTO.Raw, lengthGaussianFilter, weightGaussianFilter);
                imageDTO.GrayScalling = preprocessing.GrayscalingImage;
                imageDTO.Gaussian     = preprocessing.FilterImage;
                resizeImage           = new ResizeImage(preprocessing.RemoveBorderImage, Constants.FIX_WIDTH, Constants.FIX_HEIGHT);
                imageDTO.Binary       = resizeImage.Output;

                imageDTOs[i] = imageDTO;
            });
            List <string> classNames = new List <string>();

            for (int i = 0; i < imageDTOs.Count; i++)
            {
                ImageDTO imageDTO = imageDTOs[i];
                imageListGrayscalling.Images.Add(imageDTO.ClassName, imageDTO.GrayScalling);
                imageListGaussian.Images.Add(imageDTO.ClassName, imageDTO.Gaussian);
                imageListBinary.Images.Add(imageDTO.ClassName, imageDTO.Binary);
                classNames.Add(imageDTO.ClassName);
            }

            setImagetoListView(inFormListView[0] /*listViewGrayscallingTraining*/, imageListGrayscalling, classNames.ToArray());
            setImagetoListView(inFormListView[1] /*listViewGaussianFilteringTraining*/, imageListGaussian, classNames.ToArray());
            setImagetoListView(inFormListView[2] /*listViewBinerisasiTraining*/, imageListBinary, classNames.ToArray());
            return(imageDTOs);
        }
Esempio n. 33
0
        public Stream Get(ResizeImage request)
        {
            var imagePath = UploadsDir.CombineWith(request.Id + ".png");
            if (request.Id == null || !File.Exists(imagePath))
                throw HttpError.NotFound(request.Id + " was not found");

            using (var stream = File.OpenRead(imagePath))
            using (var img = Image.FromStream(stream))
            {
                var parts = request.Size == null ? null : request.Size.Split('x');
                int width = img.Width;
                int height = img.Height;

                if (parts != null && parts.Length > 0)
                    int.TryParse(parts[0], out width);

                if (parts != null && parts.Length > 1)
                    int.TryParse(parts[1], out height);

                return Resize(img, width, height);
            }
        }