예제 #1
0
파일: Image.cs 프로젝트: kimduquan/DMIS
 public static Stream CreateResizedImageFile(Stream originalStream, string ext, double x, double y, double q, string contentType)
 {
     return(ImageResizer.CreateResizedImageFile(originalStream, x, y, q, getImageFormat(contentType)));
 }
예제 #2
0
파일: Image.cs 프로젝트: kimduquan/DMIS
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            Stream     imageStream;
            BinaryData binaryData;
            var        propNameParam = context.Request.QueryString["NodeProperty"];
            var        propertyName  = string.Empty;
            var        widthParam    = context.Request.QueryString["width"];
            var        heightParam   = context.Request.QueryString["height"];

            if (!string.IsNullOrEmpty(propNameParam))
            {
                propertyName = propNameParam.Replace("$", "#");
                binaryData   = this.GetBinary(propertyName);
            }
            else
            {
                binaryData = this.Binary;
            }

            if (DocumentPreviewProvider.Current != null && DocumentPreviewProvider.Current.IsPreviewOrThumbnailImage(NodeHead.Get(this.Id)))
            {
                // get preview image with watermark or redaction if necessary
                imageStream = string.IsNullOrEmpty(propertyName)
                    ? DocumentPreviewProvider.Current.GetRestrictedImage(this)
                    : DocumentPreviewProvider.Current.GetRestrictedImage(this, propertyName);
            }
            else
            {
                imageStream = binaryData.GetStream();
            }

            //set compressed encoding if necessary
            if (MimeTable.IsCompressedType(this.Extension))
            {
                context.Response.Headers.Add("Content-Encoding", "gzip");
            }

            context.Response.ContentType = binaryData.ContentType;

            imageStream.Position = 0;

            if (!string.IsNullOrEmpty(widthParam) && !string.IsNullOrEmpty(heightParam))
            {
                int width;
                int height;
                if (!int.TryParse(widthParam, out width))
                {
                    width = 200;
                }
                if (!int.TryParse(heightParam, out height))
                {
                    height = 200;
                }

                // compute a new, resized stream on-the-fly
                using (var resizedStream = ImageResizer.CreateResizedImageFile(imageStream, width, height, 80, getImageFormat(binaryData.ContentType)))
                {
                    resizedStream.CopyTo(context.Response.OutputStream);
                }
            }
            else
            {
                imageStream.CopyTo(context.Response.OutputStream);
            }

            imageStream.Close();
        }
예제 #3
0
파일: Image.cs 프로젝트: kimduquan/DMIS
 public Stream GetDynamicThumbnailStream(int width, int height, string contentType)
 {
     return(ImageResizer.CreateResizedImageFile(Binary.GetStream(), width, height, 80, getImageFormat(contentType)));
 }