Exemplo n.º 1
0
        internal CompositionImage GetCompositionImage(string cacheKey)
        {
            // create image and add to cache
            BitmapSource image = CreateImage();

            // Freeze the bitmap - this means any thread can access it, as well
            // as perhaps providing some performance benefit.
            if (image != null)
                image.Freeze();

            ImageProperties properties = new ImageProperties
            {
                UniqueKey = cacheKey,
                CacheProviderKey = Util.Util.CalculateShaHash(cacheKey),
                ColourDepth = this.ColourDepth,
                Format = this.ImageFormat,
                JpegCompressionLevel = this.JpegCompressionLevel
            };
            if (image != null)
            {
                properties.Width = image.PixelWidth;
                properties.Height = image.PixelHeight;
            }
            properties.IsImagePresent = (image != null);
            return new CompositionImage(properties, image);
        }
Exemplo n.º 2
0
 public CompositionImage(ImageProperties properties, BitmapSource image)
 {
     Properties = properties;
     Image = image;
 }
Exemplo n.º 3
0
 public static string GetFileName(ImageProperties imageProperties)
 {
     return Util.Util.CalculateShaHash(imageProperties.UniqueKey);
 }
Exemplo n.º 4
0
        public Task<GeneratedImage> GenerateImageAsync()
        {
            // Create image in separate thread, and wait for result.
            var context = new ImageGenerationContext(HttpContext.Current);

            return new TaskFactory(DispatcherTaskScheduler.Default)
                .StartNew(() =>
                {
                    var image = CreateImage(context);

                    var properties = new ImageProperties
                    {
                        ColorDepth = ColorDepth,
                        Format = ImageFormat,
                        JpegCompressionLevel = JpegCompressionLevel
                    };
                    if (image != null)
                    {
                        image.Freeze();
                        properties.Width = image.PixelWidth;
                        properties.Height = image.PixelHeight;
                    }
                    properties.IsImagePresent = (image != null);
                    return new GeneratedImage(properties, image);
                });
        }
Exemplo n.º 5
0
        public GeneratedImage GenerateImage()
        {
            // create image
            BitmapSource image = CreateImage();

            var properties = new ImageProperties
            {
                ColourDepth = ColourDepth,
                Format = ImageFormat,
                JpegCompressionLevel = JpegCompressionLevel
            };
            if (image != null)
            {
                properties.Width = image.PixelWidth;
                properties.Height = image.PixelHeight;
            }
            properties.IsImagePresent = (image != null);
            return new GeneratedImage(properties, image);
        }
Exemplo n.º 6
0
 public GeneratedImage(ImageProperties properties, BitmapSource image)
 {
     Properties = properties;
     Image = image;
 }
Exemplo n.º 7
0
 public GeneratedImage(ImageProperties properties, BitmapSource image)
 {
     Properties = properties;
     Image      = image;
 }