Exemple #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);
        }
 public CompositionImage(ImageProperties properties, BitmapSource image)
 {
     Properties = properties;
     Image = image;
 }
Exemple #3
0
 public static string GetFileName(ImageProperties imageProperties)
 {
     return Util.Util.CalculateShaHash(imageProperties.UniqueKey);
 }
        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);
                });
        }
Exemple #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);
        }
 public GeneratedImage(ImageProperties properties, BitmapSource image)
 {
     Properties = properties;
     Image = image;
 }
 public GeneratedImage(ImageProperties properties, BitmapSource image)
 {
     Properties = properties;
     Image      = image;
 }