GetCached() public method

public GetCached ( string relativeFilePath, int width, int height, ImageMod imageMod, string hexBackgroundColour, AnchorPosition anchor, OutputFormat outputFormat ) : byte[]
relativeFilePath string
width int
height int
imageMod ImageMod
hexBackgroundColour string
anchor AnchorPosition
outputFormat OutputFormat
return byte[]
コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            this.context = context;
            var service = new ImageService(context);

            setContentType();
            setClientCaching();

            switch (imageMod)
            {
            case ImageMod.Raw:
                context.Response.BinaryWrite(string.IsNullOrEmpty(QueryString["MaxSize"])
                                                                                                        ? service.Get(fileName, maxWidth, maxHeight, outputFormat)
                                                                                                        : service.Get(fileName, maxSize, outputFormat));
                break;

            case ImageMod.SpecifiedCrop:
                context.Response.BinaryWrite(service.GetAndCrop(fileName, width, height, widthRatio, heightRatio, leftRatio, topRatio, outputFormat));
                break;

            default:
                context.Response.BinaryWrite(cacheEnabled
                                                                        ? service.GetCached(fileName, width, height, imageMod, hexBackGroundColour, anchor, outputFormat)
                                                                        : service.Get(fileName, width, height, imageMod, hexBackGroundColour, anchor, outputFormat));
                break;
            }
        }
コード例 #2
0
ファイル: ServiceTest.cs プロジェクト: cimex/ImageManager
        public void should_get_cached_image()
        {
            IFileService fileService = new FileService(context);
            IImageService service = new ImageService(fileService, context);

            var width = 600;
            var height = 30;
            Assert.That(context.Cache.Count == 0);
            var image = service.GetCached(fileName, width, height, ImageMod.Scale, "FFAADD", null, OutputFormat.Png);
            Assert.That(context.Cache.Count > 0);

            foreach (DictionaryEntry cacheItem in context.Cache)
            {
                Debug.WriteLine(cacheItem.Key);
            }

            image = service.GetCached(fileName, width, height, ImageMod.Scale, "FFAADD", null, OutputFormat.Png);
            Assert.That(image, Is.Not.Null);
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            this.context = context;
            var service = new ImageService(context);

            setContentType();
            setClientCaching();

            switch (imageMod)
            {
                case ImageMod.Raw:
                    context.Response.BinaryWrite(string.IsNullOrEmpty(QueryString["MaxSize"])
                                                    ? service.Get(fileName, maxWidth, maxHeight, outputFormat)
                                                    : service.Get(fileName, maxSize, outputFormat));
                    break;
                case ImageMod.SpecifiedCrop:
                    context.Response.BinaryWrite(service.GetAndCrop(fileName, width, height, widthRatio, heightRatio, leftRatio, topRatio, outputFormat));
                    break;
                default:
                    context.Response.BinaryWrite(cacheEnabled
                                                 	? service.GetCached(fileName, width, height, imageMod, hexBackGroundColour, anchor, outputFormat)
                                                 	: service.Get(fileName, width, height, imageMod, hexBackGroundColour, anchor, outputFormat));
                    break;
            }
        }