Beispiel #1
0
        /// <summary> Creates a texture using anisotropic filtering, primarily meant for regular texture use. </summary>
        public Texture(string location, int uniform)
        {
            UniformLocation = uniform;

            if (LOADED_TEXTURES.ContainsKey(location))
            {
                this.TextureID = LOADED_TEXTURES[location];
            }
            else
            {
                ImageResult image;
                using (FileStream stream = File.OpenRead(location)) {
                    image = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);
                }

                float anisotropicLevel = MathHelper.Clamp(16, 1f, MaxAnisotrophy);

                TextureID = GL.GenTexture();
                GL.BindTexture(TextureTarget.Texture2D, TextureID);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
                GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)All.TextureMaxAnisotropy, anisotropicLevel);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
                              image.Width, image.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Data);
                GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);

                LOADED_TEXTURES.Add(location, TextureID);
            }
        }
Beispiel #2
0
 private ImageResult LoadImage(string path)
 {
     using (var stream = File.OpenRead(path))
     {
         return(ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha));
     }
 }
Beispiel #3
0
        /// <summary>
        /// Given an image, use AI to review the image and extract any text that is embedded within it. Note that it takes two requests to Azure to fulfill this method.
        /// </summary>
        /// <param name="image">The image to process.</param>
        /// <returns>A result object specifying whether there was embedded text, and what the embedded text was.</returns>
        public ImageResult ExtractTextFromImage(byte[] image)
        {
            try
            {
                var result = new ImageResult();

                var callbackUrl = MakeOcrAnalysisRequestToAzure(image);

                Thread.Sleep(1000);                 // need to give the AI time to OCR the text.

                var wordList = GetOcrAnalysisResultFromAzure(callbackUrl);

                var builder = new StringBuilder();

                foreach (var word in wordList)
                {
                    if (builder.Length > 0)
                    {
                        builder.Append(" ");
                    }

                    builder.Append(word);
                }

                result.EmbeddedText = builder.ToString();
                return(result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(new ImageResult {
                    Status = ImageResult.ResultStatus.Error, Exception = ex
                });
            }
        }
Beispiel #4
0
        public ImageResult RotateImage(RotateImage rotate)
        {
            var result = new ImageResult
            {
                Message = OpMessage.Success
            };

            try
            {
                if (rotate.Param.RotateLeft)
                {
                    imageFactory.Rotate(270).Save(outStream);
                }
                if (rotate.Param.RotateRight)
                {
                    imageFactory.Rotate(90).Save(outStream);
                }
                if (rotate.Param.RotateByDegrees != 0)
                {
                    imageFactory.Rotate(rotate.Param.RotateByDegrees % 360).Save(outStream);
                }
            }
            catch (Exception ex)
            {
                result.Message = OpMessage.InvalidInputParameter;
                return(result);
            }
            result.Result = outStream.ToArray();
            return(result);
        }
        public ImageResult UploadFile(HttpPostedFileBase file, string fileName)
        {
            ImageResult imageResult = new ImageResult {
                Success = true, ErrorMessage = null
            };
            var path =
                Path.Combine(HttpContext.Current.Request.MapPath(UploadPath), fileName);
            string extension = Path.GetExtension(file.FileName);

            //make sure the file is valid
            if (!ValidateExtension(extension))
            {
                imageResult.Success      = false;
                imageResult.ErrorMessage = "Invalid Extension";
                return(imageResult);
            }

            try
            {
                file.SaveAs(path);
                imageResult.ImageName = Path.ChangeExtension(fileName, "");
                imageResult.FullPath  = path;
                return(imageResult);
            }
            catch (Exception ex)
            {
                // you might NOT want to show the exception error for the user
                // this is generaly logging or testing

                imageResult.Success      = false;
                imageResult.ErrorMessage = ex.Message;
                return(imageResult);
            }
        }
        public async ValueTask <(bool succeed, Error error, ImageResult result)> CreateIamgeResourceAsync(byte[] base64Image)
        {
            var unq_name = $"{Guid.NewGuid().ToString()}-{DateTime.UtcNow.ToUnix()}";
            var end      = new ImageResult();

            try {
                var error = default(string);
                (end.OriginImagePath, error) = await CreateImageByCompressPercentAsync(base64Image, unq_name, origin, 0.5);

                if (string.IsNullOrEmpty(end.OriginImagePath))
                {
                    return(false, Error.Create(Errors.CompressFileFailed, error), null);
                }
                (end.ThumbnailPath, error) = await CreateImageByCompressPercentAsync(base64Image, unq_name, thumbnail, 0.1, true);

                if (string.IsNullOrEmpty(end.ThumbnailPath))
                {
                    return(false, Error.Create(Errors.CompressFileFailed, error), null);
                }
                (end.Width, end.Height) = ImageCompressor.BinarySize(base64Image);
            } catch (Exception e) {
                return(false, Error.Create(Errors.CreateFileFailed, e.Message), null);
            }
            return(true, Error.Empty, end);
        }
Beispiel #7
0
        public ImageResult FlipImage(FlipImage flipParam)
        {
            var result = new ImageResult
            {
                Message = OpMessage.Success
            };

            try
            {
                if (flipParam.Param.FlipHorizontally && flipParam.Param.FlipVertically)
                {
                    imageFactory.Flip(false, true).Save(outStream);
                }
                else if (!flipParam.Param.FlipHorizontally)
                {
                    imageFactory.Flip(true, false).Save(outStream);
                }
                else
                {
                    imageFactory.Flip(true, false).Save(outStream);
                    imageFactory.Flip(false, true).Save(outStream);
                }
            }
            catch (Exception ex)
            {
                result.Message = OpMessage.InvalidInputParameter;
                return(result);
            }

            result.Result = outStream.ToArray();
            return(result);
        }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (var dlg = new OpenFileDialog())
                {
                    dlg.Filter =
                        "PNG Files (*.png)|*.png|JPEG Files (*.jpg)|*.jpg|BMP Files (*.bmp)|*.bmp|PSD Files (*.psd)|*.psd|TGA Files (*.tga)|*.tga|GIF Files (*.gif)|*.gif|All Files (*.*)|*.*";
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    _fileName = dlg.FileName;

                    var bytes = File.ReadAllBytes(_fileName);

                    using (var stream = File.OpenRead(_fileName))
                    {
                        _loadedImage = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);
                    }
                    SetImage();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error", ex.Message);
            }
        }
        public ActionResult BarCodeDisplay(string id, bool showText = true, int thickness = 3, int height = 70)
        {
            string barcodesavepath = ConfigurationManager.AppSettings["BarCodeSavePath"];
            string filepath        = barcodesavepath;
            var    barcode         = new Code39BarCode()
            {
                BarCodeText     = id,
                Height          = height,
                ShowBarCodeText = showText
            };

            if (thickness == 2)
            {
                barcode.BarCodeWeight = BarCodeWeight.Medium;
            }
            else if (thickness == 3)
            {
                barcode.BarCodeWeight = BarCodeWeight.Large;
            }


            ImageResult result = this.Image(barcode.Generate(), "image/gif", id, filepath);

            //added this hack because the users in mexico were having the travel card display prior to the bar codes being written.

            return(result);
        }
 public ProcessingPipelineContext(ImageResult result, ClientHints clientHints, ImageWizardOptions imageWizardOptions, IEnumerable <string> urlFilters)
 {
     Result             = result;
     ClientHints        = clientHints;
     ImageWizardOptions = imageWizardOptions;
     UrlFilters         = new Queue <string>(urlFilters);
 }
Beispiel #11
0
        /// <summary>
        /// Map an ImageResult from the Bing Search Utilities to a internal Image Grabber
        /// ImageQueryResult object
        /// </summary>
        /// <param name="imageResult"></param>
        /// <returns></returns>
        public static ImageQueryResult MapImageQueryResultFromImageResult(ImageResult imageResult)
        {
            var imageQueryResult = new ImageQueryResult()
            {
                ID = imageResult.ID,

                Title = imageResult.Title,

                MediaUrl = imageResult.MediaUrl,

                SourceUrl = imageResult.SourceUrl,

                DisplayUrl = imageResult.DisplayUrl,

                Width = imageResult.Width,

                Height = imageResult.Height,

                FileSize = imageResult.FileSize,

                ContentType = imageResult.ContentType,

                ThumbnailResult = GetThumbnailResultFromThumbnail(imageResult.Thumbnail)
            };

            return(imageQueryResult);
        }
Beispiel #12
0
        /// <summary>
        /// Takes an img guid, queries the database for that image then returns an img result
        /// </summary>
        /// <param name="gEventGUID">guid of the event</param>
        /// <returns>Image Result</returns>
        public ActionResult ShowPhoto(string id)
        {
            MVCEventBench.Models.dbEventModel db = new MVCEventBench.Models.dbEventModel();

            //TODO: Add error handling here for when the id is null
            Guid gGuid = new Guid(id);

            IEnumerable <MVCEventBench.Models.Image> result = from r in db.Image
                                                              where r.gEvent == gGuid
                                                              select r;


            MVCEventBench.Models.Image imgToShow = new MVCEventBench.Models.Image();

            //TODO: There should only ever be one here. Handle the case where no image is found.
            foreach (MVCEventBench.Models.Image img in result)
            {
                imgToShow.gEventImageGUID = img.gEventImageGUID;
                imgToShow.imgContent      = img.imgContent;
                imgToShow.strFileName     = img.strFileName;
                imgToShow.strMIMEType     = img.strMIMEType;
            }

            //Pass back an image result
            ImageResult imgResult = new ImageResult(imgToShow.imgContent, imgToShow.strMIMEType);

            return(imgResult);
        }
Beispiel #13
0
 public AdPod(ImageResult image, string adUnit)
     : base("Advertisement", image)
 {
     AdUnit = adUnit;
     RowSpan = 2;
     ColSpan = 1;
 }
        private ImageResult[] ConvertDataResults(SauceNaoDataResult[] results)
        {
            var rg = new List <ImageResult>();

            foreach (var sn in results)
            {
                if (sn.Urls != null)
                {
                    string?url = sn.Urls.FirstOrDefault(u => u != null) !;

                    string?siteName = sn.Index != 0 ? sn.Index.ToString() : null;

                    // var x = new BasicSearchResult(url, sn.Similarity,
                    //  sn.WebsiteTitle, sn.Creator, sn.Material, sn.Character, siteName);
                    var x = new ImageResult()
                    {
                        Url         = new Uri(url),
                        Similarity  = sn.Similarity,
                        Description = sn.WebsiteTitle,
                        Artist      = sn.Creator,
                        Source      = sn.Material,
                        Characters  = sn.Character,
                        Site        = siteName
                    };


                    rg.Add(x);
                }
            }

            return(rg.ToArray());
        }
 /// <summary>
 /// Upload product image with 2 size(large and small)
 /// </summary>
 /// <param name="file"></param>
 /// <param name="counter"></param>
 /// <returns></returns>
 public bool UploadProductImages(HttpPostedFileBase file, out string largeFileName, Int32 counter = 0)
 {
     try
     {
         ImageUpload largeImage = new ImageUpload {
             SavePath = DisplayProductConstants.LargeProductImageFolderPath
         };
         ImageUpload smallImage = new ImageUpload {
             SavePath = DisplayProductConstants.SmallProductImageFolderPath
         };
         var    fileName      = Path.GetFileName(file.FileName);
         string finalFileName = "ProductImage_" + ((counter).ToString()) + "_" + fileName;
         if (System.IO.File.Exists(HttpContext.Request.MapPath("~" + DisplayProductConstants.LargeProductImageFolderPath + finalFileName)) || System.IO.File.Exists(HttpContext.Request.MapPath("~" + DisplayProductConstants.SmallProductImageFolderPath + finalFileName)))
         {
             return(UploadProductImages(file, out largeFileName, ++counter));
         }
         ImageResult uploadLargeImage = largeImage.UploadProductImage(file, finalFileName, 1000);
         ImageResult uploadSmallImage = smallImage.UploadProductImage(file, finalFileName, 700);
         largeFileName = uploadSmallImage.ImageName;
         return(true);
     }
     catch (Exception)
     {
         largeFileName = null;
         return(false);
     }
 }
Beispiel #16
0
        public static Texture Load(string filename)
        {
            ImageResult image;

            using (var stream = File.OpenRead(filename))
            {
                image = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);
            }

            Texture tex = new Texture();

            tex.Width  = image.Width;
            tex.Height = image.Height;

            GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);

            GL.CreateTextures(TextureTarget.Texture2D, 1, out tex.ID);

            int[] texparam = new int[]
            {
                (int)TextureMinFilter.Linear,
                (int)TextureMagFilter.Linear
            };
            GL.TextureParameterI(tex.ID, TextureParameterName.TextureMinFilter, ref texparam[0]);
            GL.TextureParameterI(tex.ID, TextureParameterName.TextureMagFilter, ref texparam[1]);

            GL.TextureStorage2D(tex.ID, 1, SizedInternalFormat.Rgba8, image.Width, image.Height);
            GL.TextureSubImage2D(tex.ID, 0, 0, 0, image.Width, image.Height, PixelFormat.Rgba, PixelType.UnsignedByte, image.Data);

            GL.PixelStore(PixelStoreParameter.UnpackAlignment, 4);

            return(tex);
        }
Beispiel #17
0
        /// <summary>
        /// Query Locally for Results
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        private IList <ImageResult> QueryLocal(string query)
        {
            try
            {
                query = query.ToLowerInvariant();
                var items = this.storage.QueryByPartition <BingQueryEntry>(query);
                if (null != items)
                {
                    var results = new List <ImageResult>(items.Count());
                    foreach (var item in items)
                    {
                        var img = new ImageResult()
                        {
                            ThumbnailUrl = item.ThumbnailUrl,
                            Url          = item.Url,
                        };

                        results.Add(img);
                    }

                    return(results.OrderBy(x => Guid.NewGuid()).ToList());
                }
            }
            catch
            {
            }

            return(null);
        }
Beispiel #18
0
        public async Task <ImageResult> SelectFromGalleryAsync(bool allowMultiple = false)
        {
            bool result = await CheckPermissions();

            if (result && await CheckSoftware())
            {
                var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
                {
                    PhotoSize = PhotoSize.Medium
                });

                if (file == null)
                {
                    return(null);
                }

                Debug.WriteLine($"File Location: {file.Path}");

                ImageSource imageSource = ImageSource.FromStream(() =>
                {
                    var stream = file.GetStream();
                    return(stream);
                });

                if (null != imageSource)
                {
                    ImageResult res = new ImageResult();
                    res.Paths.Append(file.Path);
                    res.Pictures.Add(imageSource);
                    return(res);
                }
            }
            return(null);
        }
Beispiel #19
0
        /// <summary>
        /// Creates and loads and new image
        /// </summary>
        /// <param name="fileLocation">Location of the image</param>
        /// <param name="filp">Filp the image on load</param>
        /// <exception cref="FileNotFoundException"></exception>
        public Image(string fileLocation, bool filp)
        {
            if (!File.Exists(fileLocation))
            {
                throw new FileNotFoundException("Image doesn't exist!", fileLocation);
            }

            //Filp image on load, if we want to filp it
            if (filp)
            {
                StbImage.stbi_set_flip_vertically_on_load(1);
            }

            //Open stream
            FileStream imageStream = File.OpenRead(fileLocation);

            //Create image
            ImageResult image = ImageResult.FromStream(imageStream);

            Data   = image.Data;
            Width  = image.Width;
            Height = image.Height;

            //IDK if this was purposely done, but the enum number matches to the channels count of what the enum is
            Channels = (int)image.SourceComp;
        }
        /// <summary>
        /// Gets a list of visually similar products from an image URL.
        /// </summary>
        /// <param name="url">The URL of an image.</param>
        /// <returns>List of visually similar products' images.</returns>
        public async Task <ImageResult> GetSimilarImagesAsync(string url)
        {
            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", ApiKey);

                string apiUrl = BingApiUrl + $"&imgUrl={HttpUtility.UrlEncode(url)}";

                var text = await httpClient.GetStringAsync(apiUrl);

                var response = JsonConvert.DeserializeObject <BingImageResponse>(text);

                ImageResult result = new ImageResult();
                if (response.bestRepresentativeQuery.displayText != null)
                {
                    result.suggestedText = response.bestRepresentativeQuery.displayText;
                }
                result.similarImages = response
                                       ?.visuallySimilarImages
                                       ?.Select(i => new SimilarImage
                {
                    HostPageDisplayUrl = i.hostPageDisplayUrl,
                    HostPageUrl        = i.hostPageUrl,
                    Name         = i.name,
                    ThumbnailUrl = i.thumbnailUrl,
                    WebSearchUrl = i.webSearchUrl
                })
                                       .ToList();
                return(result);
            }
        }
Beispiel #21
0
        /// <summary>
        ///
        /// </summary>
        private void CleanImage()
        {
            ImageSource.GetInformation().Dispose();
            ImageTarget.GetInformation().Dispose();
            ImageResult.GetInformation().Dispose();

            if (ImageSource.Source != null)
            {
                ImageSource.Source = null;
            }
            if (ImageTarget.Source != null)
            {
                ImageTarget.Source = null;
            }
            if (ImageResult.Source != null)
            {
                ImageResult.Source = null;
            }

            ImageSource.ToolTip = null;
            ImageTarget.ToolTip = null;
            ImageResult.ToolTip = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.WaitForFullGCComplete();
        }
Beispiel #22
0
		public ActionResult UploadImageInTempSession(HttpPostedFileBase[] files)
		{
			try
			{
				if (files == null)
					throw new Exception("Файлы не могут быть загружены");
				var fls = CommonHelper.Instance.TempFiles;
				var currentLst = new List<ImageResult>();
				foreach (var httpPostedFileBase in files)
				{
					if (!fls.Select(c => c.Name).Contains(httpPostedFileBase.FileName))
					{
						var imageRes = new ImageResult
						{
							GuidId = Guid.NewGuid(),
							Name = httpPostedFileBase.FileName,
							ImageData = new byte[httpPostedFileBase.ContentLength]
						};
						httpPostedFileBase.InputStream.Read(imageRes.ImageData, 0, httpPostedFileBase.ContentLength);
						fls.Add(imageRes);
						currentLst.Add(imageRes);
					}
					else
					{
						currentLst.Add(fls.FirstOrDefault(c => c.Name == httpPostedFileBase.FileName));
					}
				}
				return Json(currentLst[0].GuidId.ToString(), JsonRequestBehavior.AllowGet);
			}
			catch (Exception e)
			{
				throw new HttpException(500, e.Message);
			}

		}
Beispiel #23
0
        private async void CameraRoll_Tapped(object sender, EventArgs e)
        {
            viewModel.VisibleLoad = true;
            //viewModel.VisibleLoad = true;
            ImageResult imageResult = await DependencyService.Get <IPicturePicker>().GetImageStreamAsync();

            if (imageResult != null && imageResult.ImageSource != null)
            {
                byte[] imageAsBytesOrig = null;
                using (var memoryStream = new MemoryStream())
                {
                    imageResult.ImageSource.CopyTo(memoryStream);
                    imageAsBytesOrig = memoryStream.ToArray();
                }



                var imageAsBytes = DependencyService.Get <IImageResizer>().ResizeImage(imageAsBytesOrig, 800, 800);



                await SaveRelatedItem(imageAsBytes, imageResult.FileName);

                //ImageSource photoSource = ImageSource.FromStream(() => new MemoryStream(imageAsBytes));

                //PhotoImage.IsVisible = true;
            }
            else
            {
            }
            viewModel.VisibleLoad = false;
        }
        protected async Task DownloadFanArtAsync(int gameId)
        {
            ImageResult result = await _gamesDbApi.GetGameImagesAsync(gameId).ConfigureAwait(false);

            if (result == null || result.Data == null || result.Data.BaseUrl == null || result.Data.Images == null)
            {
                return;
            }

            Image[] images;
            if (!result.Data.Images.TryGetValue(gameId.ToString(), out images) || images == null)
            {
                return;
            }

            ServiceRegistration.Get <ILogger>().Debug("GameTheGamesDbWrapper Download: Begin saving images for game {0}", gameId);

            string baseUrl = result.Data.BaseUrl.Large;

            foreach (Image image in images)
            {
                await _gamesDbApi.DownloadImageAsync(gameId, baseUrl, image).ConfigureAwait(false);
            }

            ServiceRegistration.Get <ILogger>().Debug("GameTheGamesDbWrapper Download: Finished saving images for game {0}", gameId);
        }
Beispiel #25
0
        public FileResult Qr(string id, string scale)
        {
            if (!id.IsShortCode())
            {
                throw new HttpException(404, "Not Found");
            }

            int qrScale = 1;

            if (!string.IsNullOrEmpty(scale))
            {
                Int32.TryParse(scale, out qrScale);
            }

            if (qrScale > 45)
            {
                qrScale = 45;
            }

            Url entity = base.GetEntityById(id);

            if (entity != null)
            {
                var img = QRGenerator.GenerateImage(entity.ShortHref, qrScale);
                if (img != null)
                {
                    ImageResult image = new ImageResult(img);
                    return(image);
                }
            }

            return(null);
        }
Beispiel #26
0
        private MeshTexture TextureFromFile(string filename, string directory, string typeName)
        {
            string resPath = directory + @"\" + filename;

            MeshTexture texture = new MeshTexture
            {
                Type = typeName,
                Path = filename
            };

            // load texture file with StbImage
            var io      = new System.IO.FileStream(resPath, System.IO.FileMode.Open);
            var resLoad = ImageResult.FromStream(io);

            int             width = resLoad.Width, height = resLoad.Height;
            ColorComponents nrComponents = resLoad.SourceComp;

            if (resLoad != null)
            {
                PixelInternalFormat format = 0;
                if (nrComponents == ColorComponents.Grey)
                {
                    format = PixelInternalFormat.CompressedRed;
                }
                else if (nrComponents == ColorComponents.RedGreenBlue)
                {
                    format = PixelInternalFormat.Rgb;
                }
                else if (nrComponents == ColorComponents.RedGreenBlueAlpha)
                {
                    format = PixelInternalFormat.Rgba;
                }

                // send necessary actions to dispatcher
                Dispatcher.ActionsQueue.Enqueue(() =>
                {
                    // load and generate the texture
                    GL.GenTextures(1, out texture.ID);

                    GL.BindTexture(TextureTarget.Texture2D, texture.ID);
                    GL.TexImage2D(TextureTarget.Texture2D, 0, format, width, height, 0, (PixelFormat)format, PixelType.UnsignedByte, resLoad.Data);
                    GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);

                    // set the texture wrapping/filtering options (on the currently bound texture object)
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)OpenTK.Graphics.OpenGL4.TextureWrapMode.Repeat);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)OpenTK.Graphics.OpenGL4.TextureWrapMode.Repeat);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                });
            }
            else
            {
                // TODO: throw new exception, although not necessarily - it's already implemented in ImageResult.FromResult
            }

            // explicitly destroy I/O stream object
            io.Dispose();

            return(texture);
        }
        bool TryGetPlatformImages(string platformId, out ImageResult result)
        {
            if (_platformImages.TryGetValue(platformId, out result))
            {
                return(true);
            }

            try
            {
                string json;
                using (WebClient client = new WebClient())
                    json = client.DownloadString($"https://api.thegamesdb.net/v1/Platforms/Images?apikey={API_KEY}&platforms_id={platformId}");
                result = JsonConvert.DeserializeObject <ImageResult>(json);
            }
            catch (Exception ex)
            {
                Logger.LogError("Error retrieving online platform images - {0}", ex.Message);
                result = null;
            }

            if (result == null)
            {
                Logger.LogError("Failed to retrieve online platform images");
                return(false);
            }

            _platformImages.TryAdd(platformId, result);
            return(true);
        }
        // GET: ImageProxy
        public ActionResult Index(string url)
        {
            var imageResult = (ImageResult) HttpContext.Cache.Get(url);
            if (imageResult == null)
            {
                ImageFormat format;

                Image image;
                using (var client = new WebClient())
                {
                    try
                    {
                        var data = client.DownloadData(url);
                        var contentType = client.ResponseHeaders["Content-Type"];
                        format = mimeTypes[contentType];
                        var ms = new MemoryStream();
                        ms.Write(data, 0, data.Length);
                        image = System.Drawing.Image.FromStream(ms);

                    }
                    catch (WebException exception)
                    {
                        return new HttpNotFoundResult();
                    }
                }
                imageResult = new ImageResult {Image = image, ImageFormat = format};

                HttpContext.Cache.Add(url, imageResult, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
            }
            return imageResult;
        }
        public ActionResult Create(CreateProductPostRequest productRequest)
        {
            productRequest.CreateBy = User.Identity.GetUserName();
            if (User.IsInRole("Administrator"))
            {
                productRequest.Status = (int)Define.Status.Active;
            }
            else
            {
                productRequest.Status = (int)Define.Status.WaitingCreate;
            }
            if (ModelState.IsValid)
            {
                var file = Request.Files["coverImage"];
                //HttpPostedFileBase file = coverImage;
                if (file != null && file.ContentLength > 0)
                {
                    if (file.ContentLength > 0)
                    {
                        // width + height will force size, care for distortion
                        //Exmaple: ImageUpload imageUpload = new ImageUpload { Width = 800, Height = 700 };

                        // height will increase the width proportionally
                        //Example: ImageUpload imageUpload = new ImageUpload { Height= 600 };

                        // width will increase the height proportionally
                        ImageUpload imageUpload = new ImageUpload {
                            Width = 600
                        };

                        // rename, resize, and upload
                        //return object that contains {bool Success,string ErrorMessage,string ImageName}
                        ImageResult imageResult = imageUpload.RenameUploadFile(file);
                        if (imageResult.Success)
                        {
                            // Add new image to database
                            var photo = new share_Images
                            {
                                ImageName = imageResult.ImageName,
                                ImagePath = Path.Combine(ImageUpload.LoadPath, imageResult.ImageName)
                            };
                            var imageId = service.AddImage(photo);
                            // Add product
                            productRequest.CoverImageId = imageId;
                            productRequest.CreateBy     = User.Identity.GetUserName();
                            service.AddProduct(productRequest);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            // use imageResult.ErrorMessage to show the error
                            ViewBag.Error = imageResult.ErrorMessage;
                        }
                    }
                }
            }
            PopulateStatusDropDownList();
            ViewBag.BrandId = PopulateListBrand(productRequest.BrandId);
            return(View("Create1", productRequest));
        }
        public ActionResult ThumbImage(string pCodeSupport)
        {
            
            Image img = null;
            ImageResult imageResult = null;

            try
            {
                Support support = DataManager.ListeSupports.Find(item => item.Code == pCodeSupport);

                if (support.Icone != null)
                {

                    MemoryStream ms = new MemoryStream(support.Icone);

                    using (Image tempImage = Image.FromStream(ms))
                    {
                        imageResult = new ImageResult(tempImage, 200, tempImage.Height);
                    }

                }

                return imageResult;
            }
            catch (Exception ex)
            {
                img = new Bitmap(1, 1);
                return new ImageResult(img, 1, 1);
            }
            finally
            {
                if (img != null) img.Dispose();
            }
        }
    IEnumerator LoadThumbnail(ImageResult imageResult, OnActorableSearchResult resultCallback)
    {
        if (imageResult.thumbnailUrl.IsNullOrEmpty())
        {
            yield break;
        }

        WWW temp = new WWW(imageResult.thumbnailUrl);

        yield return(temp);

        if (temp == null || !temp.error.IsNullOrEmpty())
        {
            yield break;
        }

        ActorableSearchResult _newresult = new ActorableSearchResult();

        _newresult.preferredRotation             = Quaternion.identity;
        _newresult.preferredScaleFunction        = (go) => new Vector3(1f, 1f, 1f);
        _newresult.renderableReference.assetType = AssetType.Image;
        _newresult.name = imageResult.name;
        _newresult.renderableReference.uri = new ImageVoosAsset(imageResult.url).GetUri();
        _newresult.thumbnail = temp.texture;
        resultCallback(_newresult);
    }
Beispiel #32
0
        protected override SearchResult Process(HtmlDocument doc, SearchResult sr)
        {
            var documentNode = doc.DocumentNode;

            var findings = documentNode.SelectNodes("//*[contains(@class, 'findings-row')]");

            if (findings == null || !findings.Any())
            {
                //sr.Filter = true;
                return(sr);
            }

            //Debug.WriteLine(findings.Count);

            var list = new List <ImageResult>();

            foreach (var t in findings)
            {
                var sub = t.SelectNodes("td");

                var imgNode       = sub[0];
                var distNode      = sub[1];
                var scoreNode     = sub[2];
                var postedNode    = sub[3];
                var titleNode     = sub[4];
                var authorNode    = sub[5];
                var subredditNode = sub[6];


                string?dist      = distNode.InnerText;
                string?score     = scoreNode.InnerText;
                string?posted    = postedNode.InnerText;
                string?title     = titleNode.InnerText;
                string?author    = authorNode.InnerText;
                string?subreddit = subredditNode.InnerText;

                string link = titleNode.FirstChild.Attributes["href"].DeEntitizeValue;

                var bsr = new ImageResult()
                {
                    Artist      = author,
                    Description = title,
                    Source      = subreddit,
                    Url         = new Uri(link),
                    Date        = DateTime.Parse(posted)
                };


                list.Add(bsr);
            }

            var best = list[0];

            sr.PrimaryResult.UpdateFrom(best);

            sr.OtherResults.AddRange(list);

            return(sr);
        }
Beispiel #33
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Jord.FontToTextureAtlas converts BMFont to LibGDX TextureAtlas.");
                Console.WriteLine("Usage: ToMyraStylesheetConverter <input.fnt> <output.atlas>");

                return;
            }

            try
            {
                var data = new BitmapFont();
                data.Load(args[0]);

                ImageResult imageResult = null;
                using (var stream = File.OpenRead(data.Pages[0].FileName))
                {
                    imageResult = ImageResult.FromStream(stream);
                }

                using (var stream = File.OpenWrite(args[1]))
                    using (var writer = new StreamWriter(stream))
                    {
                        var page = data.Pages[0];
                        writer.WriteLine();
                        writer.WriteLine(page.FileName);
                        writer.WriteLine("size: {0},{1}", imageResult.Width, imageResult.Height);
                        writer.WriteLine("format: RGBA8888");
                        writer.WriteLine("filter: Nearest,Nearest");
                        writer.WriteLine("repeat: none");

                        var characters = data.Characters.Values.OrderBy(c => c.Char);
                        foreach (var character in characters)
                        {
                            if (character.Char <= 32 || character.Char >= 128)
                            {
                                continue;
                            }

                            var bounds = character.Bounds;

                            writer.WriteLine(character.Char.ToString());
                            writer.WriteLine("  rotate: false");
                            writer.WriteLine("  xy: {0},{1}", bounds.X, bounds.Y);
                            writer.WriteLine("  size: {0},{1}", bounds.Width, bounds.Height);
                            writer.WriteLine("  orig: {0},{1}", bounds.Width, bounds.Height);
                            writer.WriteLine("  offset: 0, 0");
                            writer.WriteLine("  index: -1");
                        }

                        writer.WriteLine();
                    }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Beispiel #34
0
        public static Task <ImageResult> LoadAndDispose(Stream stream)
        {
            var image = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);

            stream.Dispose();
            Conversion.stbi__vertical_flip(image.Data, image.Width, image.Height, 4);
            return(Task.FromResult(image));
        }
Beispiel #35
0
 public ActionResult ShowMenuIcon(int id)
 {
     IAppMenuRepository repository = DependencyResolver.Current.GetService(typeof(IAppMenuRepository)) as IAppMenuRepository;
     AppMenu menu = repository.Find(id);
     if (menu.MenuIconName.IsNotNullOrEmpty())
     {
         ImageResult result = new ImageResult(menu.MenuIcon, "image/jpeg");
         return result;
     }
     return null;
 }
        public ActionResult AvatarByUId(Int32 id)
        {
            int? picId = NHibernateHelper.UniqueResult<MemberDetails>("PicId", "Id", id).PicId;
            //This is method for getting the image information
            // including the image byte array from the image column in
            // a database.
            MemberUploads image = NHibernateHelper.UniqueResult<MemberUploads>(null, "Id", picId.HasValue ? picId : 0);
            //As you can see the use is stupid simple.  Just get the image bytes and the
            //  saved content type.  See this is where the contentType comes in real handy.
            ImageResult result = new ImageResult(image.FileDetail, image.FileContentT);

            return result;
        }
Beispiel #37
0
        public static AdPod CreateAd(AdType type)
        {
            ImageResult i;
            switch (type)
            {
                case AdType.Normal:
                    i = new ImageResult("lala", 300, 250);
                    //return new AdPod(i, "10054695");
                    return new AdPod(i, "10043055");

                case AdType.Snapped:
                    i = new ImageResult("", 292, 60);
                    return new AdPod(i, "10050472");
            }

            return null;
        }
Beispiel #38
0
 public ActionResult ShowOrganizationLogo(int? id, int? organizationId)
 {
     if (organizationId.HasValue && organizationId.Value > 0)
     {
         id = organizationId;
     }
     IOrganizationRepository organizationRepository = DependencyResolver.Current.GetService(typeof(IOrganizationRepository)) as IOrganizationRepository;
     Organization organization = organizationRepository.Find(id.Value);
     if (organization.Logo != null)
     {
         ImageResult result = new ImageResult(organization.Logo, "image/jpeg");
         return result;
     }
     else
     {
         string imgPath = Url.Content("~/Content/Images/no-photo.jpg");
         ImageResult result = new ImageResult(imgPath, "image/jpeg");
         return result;
     }
 }
Beispiel #39
0
 public ActionResult ShowCompanyLogo(int? id, int? companyId)
 {
     if (companyId.HasValue && companyId.Value > 0)
     {
         id = companyId;
     }
     ICompanyRepository companyRepository = DependencyResolver.Current.GetService(typeof(ICompanyRepository)) as ICompanyRepository;
     Company company = companyRepository.Find(id.Value);
     if (company.Logo != null)
     {
         ImageResult result = new ImageResult(company.Logo, "image/jpeg");
         return result;
     }
     else
     {
         string imgPath = Url.Content("~/Content/Images/no-photo.jpg");
         ImageResult result = new ImageResult(imgPath, "image/jpeg");
         return result;
     }
 }
Beispiel #40
0
 public ActionResult ShowApplicantPhoto(int? id,int? applicantId)
 {
     if (applicantId.HasValue && applicantId.Value>0)
     {
         id = applicantId;
     }
     IApplicantRepository applicantRepository = DependencyResolver.Current.GetService(typeof(IApplicantRepository)) as IApplicantRepository;
     Applicant applicant = applicantRepository.Find(id.Value);
     if (applicant.Photo != null)
     {
         ImageResult result = new ImageResult(applicant.Photo, "image/jpeg");
         return result;
     }
     else
     {
         string imgPath = Url.Content("~/Content/Images/no-photo.jpg");
         ImageResult result = new ImageResult(imgPath, "image/jpeg");
         return result;
     }
 }
Beispiel #41
0
 public ImageResult DefineSizeOfImage(string size, ImageResult image)
 {
     if (string.IsNullOrEmpty(size) || image == null)
     {
         return image;
     }
     var result = image.Clone();
     var sizeResult = size.Split('x');
     if (sizeResult.Count() <= 1 || sizeResult.Count() > 2)
     {
         return image;
     }
     int width, height;
     int.TryParse(sizeResult[0], out width);
     int.TryParse(sizeResult[1], out height);
     result.ImageData = WebRock.Utils.FileUtils.ImageUtils.CreateIconSimple(result.ImageData, new Size(width, height));
     return result;
 }
Beispiel #42
0
 public static ImageResult CreateImageResult(global::System.Guid ID)
 {
     ImageResult imageResult = new ImageResult();
     imageResult.ID = ID;
     return imageResult;
 }
Beispiel #43
0
 public void AddToImageResultSet(ImageResult imageResult)
 {
     base.AddObject("ImageResultSet", imageResult);
 }
Beispiel #44
0
 public ActionResult ShowProfileIcon(int id)
 {
     User user = null;
     if (id == 0)
     {
         user = CurrentLoggedInUser;
     }
     else
     {
         user = userRepository.Find(id);
     }
     if (user.Photo!=null)
     {
         ImageResult result = new ImageResult(user.Photo, "image/jpeg");
         return result;
     }
     return null;
 }
Beispiel #45
0
        //TODO

        public ActionResult ThumbImage2(string url)
        {
            Image img = ObtenirThumbnail(url);
            ImageResult imageResult = new ImageResult(img);

            return imageResult;

        }
        public ActionResult FlairImage(int id, int? width)
        {
            width = width ?? 220;
            width = Math.Max(width.Value, 220);

            MemoryStream imageStream;

            var imageBytes = HttpRuntime.Cache[GetFLairCacheKey(id, width.Value)] as byte[];
            if (imageBytes != null)
            {
                imageStream = new MemoryStream(imageBytes);
            }
            else
            {
                imageStream = new MemoryStream();
                var url = Settings.Host + Url.Action("flairdetail", new { id = id, width = width.Value });
                var image = _snapshotService.GetSnapshot(url, 74, width.Value + 20);
                image.Save(imageStream, ImageFormat.Png);
                imageStream.Flush();
                imageStream.Position = 0;
                imageBytes = imageStream.ReadToEnd();
                HttpRuntime.Cache.Add(GetFLairCacheKey(id, width.Value), imageBytes, null, DateTime.Now.AddMinutes(Settings.FlairCacheMinutes), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
                imageStream.Position = 0;
            }

            var result = new ImageResult(imageStream, "image/png");
            return result;
        }
Beispiel #47
0
		public async Task<FileContentResult> GetAvatar(string size = null)
		{
			var maybeSize = size.MaybeAs<string>().Bind(c => c.Split('-').Skip(1).Take(1).Last()).GetOrDefault("");
			var result = new ImageResult
			{
				ImageData = CommonHelper.Instance.CurrentUser.Avatar ?? WebRock.Utils.FileUtils.IOUtils.GetDataFromUrl(@"D:\examples\Examples\ForWebDevelopmentProject\FWD.UI.Web\Content\Images\default_avatar.png")
			};
			var reworkedImage = CommonHelper.Instance.DefineSizeOfImage(maybeSize, result);
			return await Task.Factory.StartNew(() => File(reworkedImage.MaybeAs<ImageResult>().Bind(c => c.ImageData).GetOrDefault(null), "image/gif"));
		}
 /// <summary>
 /// 拷贝的构造函数。
 /// </summary>
 /// <param name="imageResult">ImageResult 对象实例。</param>
 /// <exception cref="ArgumentNullException">imageResult 为空时抛出异常。</exception>
 public ImageResult(ImageResult imageResult)
 {
     if (imageResult == null) throw new ArgumentNullException("imageResult", Resources.ArgumentIsNotNull);
     this.ImageURL = imageResult.ImageURL;
     if (imageResult.ImageParameter != null)
         this.ImageParameter = new ImageParameter(imageResult.ImageParameter);
     if (imageResult.ImageData != null)
     {
         using (MemoryStream ms = new MemoryStream(imageResult.ImageData))
         {
             this.ImageData = ms.ToArray();
         }
     }
 }
 public static bool SentWith(this UpdateTileMessage message, ImageResult image)
 {
     return message != null && message.Image == image;
 }
 public static bool SentWith(this SetLockScreenMessage message, ImageResult image)
 {
     return message != null && message.Image == image;
 }
 public UpdateTileMessage(ImageResult image)
 {
     Image = image;
 }
Beispiel #52
0
        public ActionResult ThumbImage(string jaquette, int width, int height)
        {
            ImageResult imageResult = null;
            Image img = null;

            try
            {
                if (String.IsNullOrEmpty(jaquette))
                {
                    //TODO : revoir l'accès au fichier
                    //using (img = Image.FromFile(@"D:\Jaymz\Documents\Boulot\Mes projets Visual Studio\MediaGestion\MediaGestion.Vues\Content\Images\fichiervide.png"))
                    //{
                    //    imageResult = new ImageResult(img, width/2, height/2);
                    //}

                    img = new Bitmap(1, 1);
                    imageResult = new ImageResult(img, width / 2, height / 2);
                }
                else
                {
                    using (img = Image.FromFile(@"D:\Jaymz\Images\Pochettes\Jeux\" + jaquette))
                    {

                        imageResult = new ImageResult(img, width, height);
                       
                    }
                }

                return imageResult;
            }
            catch (Exception ex)
            {
                img = new Bitmap(1, 1);
                return new ImageResult(img, width / 2, height / 2);
            }

        }
        /// <summary>
        /// ThumbImage
        /// </summary>
        /// <param name="pCodeMachine">pCodeMachine</param>
        /// <returns>ActionResult</returns>
        public ActionResult ThumbPhoto(string pCodeMachine, int pTaille)
        {
            Image img = null;
            ImageResult imageResult = null;

            try
            {
                Machine machine = DataManager.ListeMachines.Find(item => item.Code == pCodeMachine);

                if (machine.Logo != null)
                {
                    MemoryStream ms = new MemoryStream(machine.Photo);

                    using (Image tempImage = Image.FromStream(ms))
                    {
                        imageResult = new ImageResult(tempImage, pTaille, tempImage.Height);
                    }
                }

                return imageResult;
            }
            catch (Exception)
            {
                img = new Bitmap(1, 1);
                return new ImageResult(img, 1, 1);
            }
            finally
            {
                if (img != null) img.Dispose();
            }
        }
Beispiel #54
0
        private ImageResult UploadFile(HttpPostedFileBase file, string fileName)
        {
            ImageResult imageResult = new ImageResult { Success = true, ErrorMessage = null };

            var path = Path.Combine(HttpContext.Current.Request.MapPath(UploadPath), fileName);
            string extension = Path.GetExtension(file.FileName);

            //make sure the file is valid
            if (!ValidateExtension(extension))
            {
                imageResult.Success = false;
                imageResult.ErrorMessage = "Invalid Extension";
                return imageResult;
            }

            try
            {
                file.SaveAs(path);

                Image imgOriginal = Image.FromFile(path);

                //pass in whatever value you want
                Image imgActual = Scale(imgOriginal);
                imgOriginal.Dispose();
                imgActual.Save(path);
                imgActual.Dispose();

                imageResult.ImageName = fileName;

                return imageResult;
            }
            catch (Exception ex)
            {
                // you might NOT want to show the exception error for the user
                // this is generally logging or testing

                imageResult.Success = false;
                imageResult.ErrorMessage = ex.Message;
                return imageResult;
            }
        }
 public ShareImageResultsMessage(ImageResult image, DataTransferManager sender, SettableDataRequestedEventArgs args)
     : base(sender, args)
 {
     Image = image;
 }
Beispiel #56
0
 public ActionResult ShowVendorLogo(int? id, int? vendorId)
 {
     if (vendorId.HasValue && vendorId.Value > 0)
     {
         id = vendorId;
     }
     IVendorRepository vendorRepository = DependencyResolver.Current.GetService(typeof(IVendorRepository)) as IVendorRepository;
     Vendor vendor = vendorRepository.Find(id.Value);
     if (vendor.Logo != null)
     {
         ImageResult result = new ImageResult(vendor.Logo, "image/jpeg");
         return result;
     }
     else
     {
         string imgPath = Url.Content("~/Content/Images/no-photo.jpg");
         ImageResult result = new ImageResult(imgPath, "image/jpeg");
         return result;
     }
 }
 public SetLockScreenMessage(ImageResult image)
 {
     Image = image;
 }
Beispiel #58
0
        public ImageResult VerifyCodeAction()
        {
            VerifyCode v = new VerifyCode();
            v.Length = 4;
            v.FontSize = 20;
            v.Chaos = true;
            v.BackgroundColor = Color.White;
            v.ChaosColor =  Color.LightGray;
            v.CodeSerial = "2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,k,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,K,M,N,P,Q,R,S,T,U,V,W,X,Y,Z";
            v.Colors = new Color[] {Color.Black,Color.Red,Color.DarkBlue,Color.Green,Color.Orange,Color.Brown,Color.DarkCyan,Color.Purple};
            v.Fonts = new string[] {"Arial", "Georgia"};
            v.Padding = 2;
            string code = v.CreateVerifyCode();                //取随机码

            ImageResult res = new ImageResult(code,v);

            Session["CheckCode"] = code.ToUpper();// 使用Session取验证码的值

            return res;
        }
        public ActionResult ShowImage(int id, string documentName)
        {
            const string fileBasePath = SPEDU.Common.Utility.AppConstant.ImagePath.ImageFolderPath;
            string filePath = string.Empty;
            if (documentName.IsNotNullOrEmpty() && id > 0)
            {
                string physicalPath = System.Web.HttpContext.Current.Server.MapPath(fileBasePath) + documentName;
                if (System.IO.File.Exists(physicalPath))
                {
                    filePath = Url.Content(fileBasePath + documentName);
                }
                else
                {
                    var iDocumentInfoRepository = DependencyResolver.Current.GetService(typeof(IDocumentInfoRepository)) as IDocumentInfoRepository;
                    var documentInfo = iDocumentInfoRepository.GetById(id);
                    if (documentInfo != null && documentInfo.DocumentName.IsNotNullOrEmpty())
                    {
                        documentName = documentInfo.DocumentName;
                        if (!System.IO.File.Exists(physicalPath))
                        {
                            CreateDirectory(fileBasePath);
                            if (!System.IO.File.Exists(physicalPath))
                            {
                                ImageHelper.WriteFile(physicalPath, documentInfo.DocumentByte);
                            }

                        }
                        filePath = Url.Content(fileBasePath + documentName);
                    }

                }
            }

            if (filePath.IsNullOrEmpty() || !filePath.IsImage())
            {
                filePath = Url.Content("~/Theme/img/no-image.png");
                documentName = "no-photo.jpg";
            }
            var result = new ImageResult(filePath, ImageHelper.GetMIMEType(documentName));
            return result;
        }
Beispiel #60
0
		public ActionResult UploadImageByLink(string url)
		{
			try
			{
				if (string.IsNullOrEmpty(url))
				{
					throw new Exception("Ссылка не может быть пустой");
				}
				//using (var client = new WebClient())
				//{
				//var random = new Random();
				//string fileName = "File Name " + random.Next(0, 999999)+".jpeg";
				//client.DownloadFile(url, url.Substring(url.LastIndexOf('/')));

				var request = WebRequest.Create(url);

				using (var response = request.GetResponse())
				{
					using (var stream = response.GetResponseStream())
					{
						var img = Bitmap.FromStream(stream);
						var imageRes = new ImageResult
						{
							GuidId = Guid.NewGuid(),
							Name = url.Substring(url.LastIndexOf('/')),
							ImageData = GetByteArrayFromImage(img)
						};
						CommonHelper.Instance.TempFiles.Add(imageRes);
						return Json(imageRes.GuidId.ToString(), JsonRequestBehavior.AllowGet);
					}
				}
				//}
			}
			catch (Exception e)
			{
				throw new HttpException(500, e.Message);
			}
		}