コード例 #1
0
        private void InitializeCompositionVariables()
        {
            var bounds          = ApplicationView.GetForCurrentView().VisibleBounds;
            var maxWindowWidth  = bounds.Width.ToFloat();
            var maxWindowHeight = bounds.Height.ToFloat();
            var maxWindowRadius = Math.Max(maxWindowWidth, maxWindowHeight);

            // Setup sky visual's size, position, opacity, etc.
            _skyVisual             = Sky.ContainerVisual();
            _skyVisual.Size        = new Vector2(maxWindowRadius * SkyVisualAreaRatio);
            _skyVisual.Offset      = new Vector3(-SkyVisualRadius + maxWindowWidth / 2.0f, -SkyVisualRadius + maxWindowHeight / 2.0f, 0.0f);
            _skyVisual.CenterPoint = new Vector3(SkyVisualRadius, SkyVisualRadius, 0.0f);
            _skyVisual.Opacity     = 0;

            _compositor = _skyVisual.Compositor;
            _reading    = _compositor.CreatePropertySet();
            _reading.InsertVector3("Offset", new Vector3(0.0f, 0.0f, 0.0f));
            _imageLoader         = ImageLoaderFactory.CreateImageLoader(_compositor);
            _circleBrush         = _compositor.CreateSurfaceBrush();
            _circleBrush.Surface = _imageLoader.LoadImageFromUri(new Uri(StarUriString));

            if (_inclinometer != null)
            {
                SetupSkyVisualOffsetExpressionAnimation();
            }
        }
コード例 #2
0
        /// <summary>Create instance of the DEX</summary>
        /// <param name="loader">Loader type</param>
        public DexFile(IImageLoader loader)
        {
            if (loader == null)
            {
                throw new ArgumentNullException("loader");
            }

            this._loader            = loader;
            this._loader.Endianness = EndianHelper.Endian.Little;

            this._header = this.PtrToStructure <DexApi.header_item>(0);
            if (!this._header.IsValid)
            {
                throw new InvalidOperationException("Invalid DEX header");
            }

            switch (this.header.endian_tag)
            {
            case DexApi.ENDIAN.ENDIAN:
                this._loader.Endianness = EndianHelper.Endian.Little;
                break;

            case DexApi.ENDIAN.REVERSE_ENDIAN:
                this._loader.Endianness = EndianHelper.Endian.Big;
                this._header            = this.PtrToStructure <DexApi.header_item>(0);    //TODO: Check it
                break;
            }
        }
コード例 #3
0
        private void SamplePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // Get backing visual from shadow container and interop compositor
            _shadowContainer = ElementCompositionPreview.GetElementVisual(ShadowContainer);
            _compositor = _shadowContainer.Compositor;

            // Get CompositionImage, its sprite visual
            _image = VisualTreeHelperExtensions.GetFirstDescendantOfType<CompositionImage>(ShadowContainer);
            _imageVisual = _image.SpriteVisual;

            // Load mask asset onto surface using helpers in SamplesCommon
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
            _imageMaskSurface = _imageLoader.CreateCircleSurface(200, Colors.White);

            // Create surface brush for mask
            CompositionSurfaceBrush mask = _compositor.CreateSurfaceBrush();
            mask.Surface = _imageMaskSurface.Surface;
            
            // Get surface brush from composition image
            CompositionSurfaceBrush source = _image.SurfaceBrush as CompositionSurfaceBrush;

            // Create mask brush for toggle mask functionality
            _maskBrush = _compositor.CreateMaskBrush();
            _maskBrush.Mask = mask;
            _maskBrush.Source = source;

            // Initialize toggle mask
            _isMaskEnabled = false;
        }
コード例 #4
0
        public BorderPlayground()
        {
            _compositor  = ElementCompositionPreview.GetElementVisual(this).Compositor;
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);

            this.InitializeComponent();
        }
コード例 #5
0
    public void DoesNotThrowIfMultipleConvertersRegistered()
    {
        IServiceCollection services = new ServiceCollection();

        ImageLoaderCoreSetup.Configure(services);

        IImageConverter ic1 = Substitute.For <IImageConverter>();

        ic1.SupportedExtensions.Returns(new[]
        {
            ".jpg",
            ".jpeg"
        });

        services = services.AddSingleton(ic1);

        IImageConverter ic2 = Substitute.For <IImageConverter>();

        ic2.SupportedExtensions.Returns(new[]
        {
            ".png"
        });

        services = services.AddSingleton(ic2);

        IServiceProvider serviceProvider = services.BuildServiceProvider();

        IImageLoader il = serviceProvider.GetRequiredService <IImageLoader>();

        Assert.NotNull(il);
    }
コード例 #6
0
        private int BuildImage(string uri, TextureInfo textureInfo)
        {
            int name = -1;

            // wrapped in this nasty try/catch because bad memory is touched when we're
            // rendering to a thumbnail (different glContext).  driver bug?  :_(
            try
            {
                string filename = uri.Replace(@"file:\\\", "");

                string       ext    = Path.GetExtension(filename);
                IImageLoader loader = m_imageLoaderRegistry.GetLoader(ext);
                Image        image;

                using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
                    image = loader.LoadImage(stream);

                name = TryCreateOpenGlTextureFromImage(image, textureInfo);
            }
            catch (System.IO.IOException e)
            {
                // excessive error messages adds minutes to a large level that is missing textures
                if (m_missingTextureReports++ < 10)
                {
                    Outputs.WriteLine(OutputMessageType.Error, e.Message);
                }
            }
            catch (Exception e)
            {
                Outputs.WriteLine(OutputMessageType.Error, e.Message);
                Outputs.WriteLine(OutputMessageType.Info, e.StackTrace);
            }

            return(name);
        }
コード例 #7
0
        public ThreadedImageCache(int aMaxSize, int aDownscaleImageSize, int aThreadCount, IImageLoader <ImageType> aImageLoader, int aPendingRequestLimit)
        {
            iPendingRequestLimit = aPendingRequestLimit;
            iLockObject          = new object();
            iDownscaleImageSize  = aDownscaleImageSize;
            iMaxCacheSize        = aMaxSize;
            iImageCache          = new Dictionary <string, IImage <ImageType> >();
            iImageCacheFailures  = new List <string>();
            iImageCacheUsage     = new List <string>();
            iImageLoader         = aImageLoader;

            iEvent             = new ManualResetEvent(false);
            iPendingRequests   = new List <ImageRequest>();
            iExecutingRequests = new List <ImageRequest>();
            iIsRunning         = true;

            iThreads = new List <Thread>();

            for (int i = 0; i < aThreadCount; i++)
            {
                Thread t = new Thread(ProcessRequests);
                t.IsBackground = true;
                t.Name         = "ImageCache" + i;
                t.Start();
                iThreads.Add(t);
            }
        }
コード例 #8
0
        private void SamplePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // Get backing visual from shadow container and interop compositor
            _shadowContainer = ElementCompositionPreview.GetElementVisual(ShadowContainer);
            _compositor      = _shadowContainer.Compositor;

            // Get CompositionImage, its sprite visual
            _image       = VisualTreeHelperExtensions.GetFirstDescendantOfType <CompositionImage>(ShadowContainer);
            _imageVisual = _image.SpriteVisual;

            // Load mask asset onto surface using helpers in SamplesCommon
            _imageLoader      = ImageLoaderFactory.CreateImageLoader(_compositor);
            _imageMaskSurface = _imageLoader.CreateCircleSurface(200, Colors.White);

            // Create surface brush for mask
            CompositionSurfaceBrush mask = _compositor.CreateSurfaceBrush();

            mask.Surface = _imageMaskSurface.Surface;

            // Get surface brush from composition image
            CompositionSurfaceBrush source = _image.SurfaceBrush as CompositionSurfaceBrush;

            // Create mask brush for toggle mask functionality
            _maskBrush        = _compositor.CreateMaskBrush();
            _maskBrush.Mask   = mask;
            _maskBrush.Source = source;

            // Initialize toggle mask
            _isMaskEnabled = false;
        }
コード例 #9
0
 public ReconstructedImageBuilder(int width, int height, IImageLoader imageLoader, double newImagePercentage)
 {
     _imageLoader        = imageLoader;
     _newImagePercentage = newImagePercentage;
     _oldImagePercentage = (1 - _newImagePercentage);
     _newImage           = new Bitmap(width, height);
 }
コード例 #10
0
 public ThumbnailsCollection(IFiveHundredPxClient client, IImageLoader imageLoader)
 {
     _client      = client;
     _imageLoader = imageLoader;
     _currentPage = 0;
     HasMoreItems = true;
 }
コード例 #11
0
 public TwoStepImageCache(IImageLoader slowLoader, IImageLoader fastLoader, IReceiveImage receiver, int maxCacheSize)
 {
     _innerCache = new ImageCache(this, maxCacheSize);
     _slowLoader = slowLoader;
     _fastLoader = fastLoader;
     _receiver   = receiver;
 }
コード例 #12
0
 /// <summary>
 /// Registers <paramref name="loader"/> that will be used for loading images with <paramref name="extensions"/>
 /// </summary>
 /// <param name="extensions">Supported extensions</param>
 /// <param name="loader"></param>
 public void RegisterLoader(IEnumerable <string> extensions, IImageLoader loader)
 {
     foreach (string extension in extensions)
     {
         extensionLoaderMap[extension] = loader;
     }
 }
コード例 #13
0
 public VkPostCreator(IVkConfiguration config, IImageLoader imageLoader, IVkPoster vkPoster)
 {
     _config    = config;
     _vkPoster  = vkPoster;
     _imgLoader = imageLoader;
     _logger    = LogManager.GetLogger(this.GetType().Name);
 }
コード例 #14
0
        private static async Task <int> Main(string[] args)
        {
            Console.WriteLine(value: "Credfeto.Gallery.OutputBuilder");

            AlterPriority();

            ServiceCollection serviceCollection = Startup.RegisterServices(args);

            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

            ILoggerFactory loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>();

            loggerFactory.AddSerilog();

            ILogger logging = loggerFactory.CreateLogger(categoryName: "Credfeto.Gallery.OutputBuilder");

            ISettings      settings      = serviceProvider.GetService <ISettings>();
            IImageSettings imageSettings = serviceProvider.GetService <IImageSettings>();

            logging.LogInformation($"Source: {settings.RootFolder}");
            logging.LogInformation($"Output: {settings.DatabaseOutputFolder}");
            logging.LogInformation($"Credfeto.Gallery.Image: {settings.ImagesOutputPath}");
            logging.LogInformation($"Thumb:  {imageSettings.ThumbnailSize}");

            foreach (int resize in imageSettings.ImageMaximumDimensions)
            {
                logging.LogInformation($"Resize: {resize}");
            }

            try
            {
                IShortUrls shortUrls = serviceProvider.GetService <IShortUrls>();

                await shortUrls.LoadAsync();

                IImageLoader imageLoader = serviceProvider.GetService <IImageLoader>();

                logging.LogInformation($"Supported Extensions: {string.Join(separator: ", ", values: imageLoader.SupportedExtensions)}");

                IGalleryBuilder galleryBuilder = serviceProvider.GetService <IGalleryBuilder>();

                await galleryBuilder.ProcessGalleryAsync(imageSettings);

                return(0);
            }
            catch (Exception exception)
            {
                Console.WriteLine(format: "Error: {0}", arg0: exception.Message);
                Console.WriteLine(format: "Stack Trace: {0}", arg0: exception.StackTrace);

                return(1);
            }
            finally
            {
                IBrokenImageTracker brokenImageTracker = serviceProvider.GetService <IBrokenImageTracker>();

                await DumpBrokenImagesAsync(brokenImageTracker : brokenImageTracker, settings : settings, logging : logging);
            }
        }
コード例 #15
0
ファイル: SpriteManager.cs プロジェクト: jlopresti/cassette
 public SpriteManager(ISpritingSettings config, IImageLoader imageLoader, Func<byte[], string> generateSpriteUrl, IPngOptimizer pngOptimizer)
 {
     this.pngOptimizer = pngOptimizer;
     this.config = config;
     this.generateSpriteUrl = generateSpriteUrl;
     SpriteContainer = new SpriteContainer(imageLoader, config);
     Errors = new List<SpriteException>();
 }
コード例 #16
0
        public ImageDataBuilder(string imagePath, IRegionCreationStrategy regionCreationStrategy, IRegionCreationStrategy subRegionCreationStrategy, IImageLoader imageLoader)
        {
            _imagePath = imagePath;
            _regionCreationStrategy = regionCreationStrategy;
            _imageLoader            = imageLoader;

            _averageGreyByRegionCalculator = new AverageGreyByRegionCalculator(subRegionCreationStrategy);
        }
コード例 #17
0
 public CollectionLoader(ICollectionRepo collectionRepo, ICollectionRelationshipRepo collectionRelationshipRepo, IAttributeLoader attributeLoader, IImageLoader imageLoader, IItemLoader itemLoader)
 {
     _collectionRelationshipRepo = collectionRelationshipRepo;
     _collectionRepo             = collectionRepo;
     _attributeLoader            = attributeLoader;
     _imageLoader = imageLoader;
     _itemLoader  = itemLoader;
 }
コード例 #18
0
 public SettingViewModel(ILeanCloudWallpaperServiceWithCache leanCloudWallpaperServiceWithCache, IBingoWallpaperSettings settings, IBingoShareService bingoShareService, IAppToastService appToastService, IImageLoader imageLoader)
 {
     _leanCloudWallpaperServiceWithCache = leanCloudWallpaperServiceWithCache;
     _settings          = settings;
     _bingoShareService = bingoShareService;
     _appToastService   = appToastService;
     _imageLoader       = imageLoader;
 }
コード例 #19
0
 /// <summary>Dispose managed objects</summary>
 /// <param name="disposing">Dispose managed objects</param>
 protected virtual void Dispose(Boolean disposing)
 {
     if (disposing && this._loader != null)
     {
         this._loader.Dispose();
         this._loader = null;
     }
 }
コード例 #20
0
 public RecursiveDirectoryFillProvider(string sourceDirectory, IRegionCreationStrategy fillRegionCreationStrategy, IRegionCreationStrategy averageGryRegionCreationStrategy, IImageLoader imageLoader, string searchString = "*.bmp")
 {
     _sourceDirectory                  = sourceDirectory;
     _searchString                     = searchString;
     _fillRegionCreationStrategy       = fillRegionCreationStrategy;
     _averageGryRegionCreationStrategy = averageGryRegionCreationStrategy;
     _imageLoader = imageLoader;
 }
コード例 #21
0
ファイル: SpriteManager.cs プロジェクト: WS-QA/cassette
 public SpriteManager(ISpritingSettings config, IImageLoader imageLoader, Func <byte[], string> generateSpriteUrl, IPngOptimizer pngOptimizer)
 {
     this.pngOptimizer      = pngOptimizer;
     this.config            = config;
     this.generateSpriteUrl = generateSpriteUrl;
     SpriteContainer        = new SpriteContainer(imageLoader, config);
     Errors = new List <SpriteException>();
 }
コード例 #22
0
        private CompositionSurfaceBrush CreateBrushFromAsset(string name, out Size size)
        {
            IImageLoader imageLoader          = ImageLoaderFactory.CreateImageLoader(m_compositor);
            CompositionDrawingSurface surface = imageLoader.LoadImageFromUri(new Uri("ms-appx:///Assets/" + name));

            size = surface.Size;
            return(m_compositor.CreateSurfaceBrush(surface));
        }
        /// <summary>
        /// Initialize Composition
        /// </summary>
        private void InitializeComposition()
        {
            // Retrieve an instance of the Compositor from the backing Visual of the Page
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            // Create a root visual from the Compositor
            _root = _compositor.CreateContainerVisual();

            // Set the root ContainerVisual as the XAML Page Visual
            ElementCompositionPreview.SetElementChildVisual(this, _root);

            // Assign initial values to variables used to store updated offsets for the visuals
            float posXUpdated = _posX;
            float posYUpdated = _posY;

            // Create a list of image brushes that can be applied to a visual
            string[] imageNames =
            {
                "01.png",
                "02.png",
                "03.png",
                "04.png",
                "05.png",
                "06.png",
                "07.png",
                "08.png",
                "60Banana.png",
                "60Lemon.png",
                "60Vanilla.png",
                "60Mint.png",
                "60Orange.png",
                "110Strawberry.png",
                "60SprinklesRainbow.png"
            };
            List <CompositionSurfaceBrush> imageBrushList = new List <CompositionSurfaceBrush>();
            IImageLoader imageFactory = ImageLoaderFactory.CreateImageLoader(_compositor);

            for (int k = 0; k < imageNames.Length; k++)
            {
                var surface = imageFactory.LoadImageFromUri(new Uri("ms-appx:///Assets/Images/Composition/ImplicitAnimation/" + imageNames[k]));
                imageBrushList.Add(_compositor.CreateSurfaceBrush(surface));
            }

            // Create nxn matrix of visuals where n=row/ColumnCount-1 and passes random image brush to the function
            // that creates a visual
            for (int i = 1; i < _rowCount; i++)
            {
                posXUpdated = i * _distance;
                for (int j = 1; j < _columnCount; j++)
                {
                    CompositionSurfaceBrush brush = imageBrushList[randomBrush.Next(imageBrushList.Count)];

                    posYUpdated = j * _distance;
                    _root.Children.InsertAtTop(CreateChildElement(brush, posXUpdated, posYUpdated));
                }
            }
            EnableAnimationOnChildren(EnableAnimations.IsChecked.GetValueOrDefault());
        }
コード例 #24
0
        /// <summary>Create instance of OBJ file reader</summary>
        /// <param name="loader">Image loader</param>
        public ObjFile(IImageLoader loader)
        {
            if (loader == null)
            {
                throw new ArgumentNullException("loader");
            }

            this._loader = loader;
        }
コード例 #25
0
ファイル: ElfFile.cs プロジェクト: DKorablin/ElfReader
        /// <summary>Create instance of the ELF file reader</summary>
        /// <param name="loader">Stream of data</param>
        /// <exception cref="InvalidOperationException">Invalid ELF header</exception>
        public ElfFile(IImageLoader loader)
        {
            this._header = new ElfHeader(loader);

            if (!this.Header.IsValid)
            {
                throw new InvalidOperationException("Invalid ELF header");
            }
        }
コード例 #26
0
 public FilterHandler(IImageLoader imageLoader)
 {
     _imageloader              = imageLoader;
     _imageloader.ImageLoaded += () =>
     {
         PropertyChanged.Notify(this, "ExecuteFilterCommand");
         ResultImage = null;
     };
 }
コード例 #27
0
        void HandleDone(object sender, System.EventArgs args)
        {
            Log.DebugTimerPrint(timer, "Loading image took {0}");
            IImageLoader loader = sender as IImageLoader;

            if (loader != this.loader)
            {
                return;
            }

            Pixbuf prev = this.Pixbuf;

            if (Pixbuf != loader.Pixbuf)
            {
                Pixbuf = loader.Pixbuf;
            }

            if (Pixbuf == null)
            {
                // FIXME: Do we have test cases for this ???

                // FIXME in some cases the image passes completely through the
                // pixbuf loader without properly loading... I'm not sure what to do about this other
                // than try to load the image one last time.
                try {
                    Log.Warning("Falling back to file loader");
                    Pixbuf = PhotoLoader.Load(item.Collection, item.Index);
                } catch (Exception e) {
                    LoadErrorImage(e);
                }
            }

            if (loader.Pixbuf != null)             //FIXME: this test in case the photo was loaded with the direct loader
            {
                PixbufOrientation = Accelerometer.GetViewOrientation(loader.PixbufOrientation);
            }
            else
            {
                PixbufOrientation = ImageOrientation.TopLeft;
            }

            if (Pixbuf == null)
            {
                LoadErrorImage(null);
            }
            else
            {
                ZoomFit();
            }

            progressive_display = true;

            if (prev != this.Pixbuf && prev != null)
            {
                prev.Dispose();
            }
        }
コード例 #28
0
 /// <summary>Create instance of PE header reader</summary>
 /// <param name="loader">Image loader</param>
 /// <exception cref="T:ArgumentNullException">loader is null</exception>
 public PEHeader(IImageLoader loader)
 {
     if (loader == null)
     {
         throw new ArgumentNullException("loader");
     }
     this._loader            = loader;
     this._loader.Endianness = EndianHelper.Endian.Little;
 }
コード例 #29
0
ファイル: ImageLoaderRegistry.cs プロジェクト: Joxx0r/ATF
        /// <summary>
        /// Registers and associates the supplied image loader with the given file extension.
        /// Throws exception if the current file extension is already registered.</summary>
        /// <param name="fileExtension">File extension (with leading ".") to register</param>
        /// <param name="loader">IImageLoader object to associate with fileExtension</param>
        /// <exception cref="InvalidOperationException">Loader is already registered with the extension</exception>
        public void RegisterImageLoader(string fileExtension, IImageLoader loader)
        {
            string upperCase= fileExtension.ToUpperInvariant();
            if (m_imageLoaders.ContainsKey(upperCase))
                throw new InvalidOperationException(
                    "Loader is already registered under extension '" + fileExtension + "'");

            m_imageLoaders.Add(upperCase, loader);
        }
コード例 #30
0
ファイル: ThumbnailLoader.cs プロジェクト: trylock/viewer
 public ThumbnailLoader(
     IImageLoader imageLoader,
     IAttributeStorage storage,
     IFileSystem fileSystem)
 {
     _fileSystem  = fileSystem;
     _imageLoader = imageLoader;
     _storage     = storage;
 }
コード例 #31
0
 /// <summary>
 /// Creates the circle used in the circle brush if not already created.
 /// </summary>
 private void EnsureCircleBrush()
 {
     if (_circleBrush == null)
     {
         _imageLoader   = ImageLoaderFactory.CreateImageLoader(_compositor);
         _circleSurface = _imageLoader.CreateManagedSurfaceFromUri(new Uri(CircleImagePath));
         _circleBrush   = _compositor.CreateSurfaceBrush(_circleSurface.Surface);
     }
 }
コード例 #32
0
 /// <summary>
 /// Creates the circle used in the circle brush if not already created.
 /// </summary>
 private void EnsureCircleBrush()
 {
     if (_circleBrush == null)
     {
         _imageLoader   = ImageLoaderFactory.CreateImageLoader(_compositor);
         _circleSurface = _imageLoader.CreateCircleSurface(200, Colors.White);
         _circleBrush   = _compositor.CreateSurfaceBrush(_circleSurface.Surface);
     }
 }
コード例 #33
0
ファイル: Image.cs プロジェクト: git-thinh/limada
 public void SetCustomLoaderSource(IImageLoader imageLoader, string fileName, ImageTagSet tags)
 {
     sources = new [] {
         new NativeImageSource {
             CustomImageLoader = imageLoader,
             Source            = fileName,
             Tags = tags
         }
     };
 }
コード例 #34
0
ファイル: ImageCache.cs プロジェクト: ashmind/gallery
        public ImageCache(
            ILocation cacheRoot,
            IImageFormat cacheFormat,
            IImageLoader imageLoader,
            ICacheDependencyProvider[] dependencyProviders
            )
        {
            this.CacheRoot = cacheRoot;

            this.CacheFormat = cacheFormat;
            this.imageLoader = imageLoader;
            this.dependencyProviders = dependencyProviders;
        }
コード例 #35
0
        public ImageHandler(string baseRoute, IImageCache cache, IImageLoader[] loaders, Func<Type, string, object> convert = null, params Type[] declaredTypes)
        {
            if (loaders == null) throw new ArgumentNullException(nameof(loaders));

            baseRoute = baseRoute ?? "";
            if (baseRoute != "" && !baseRoute.EndsWith("/")) baseRoute += "/";

            this.baseRoute = "/" + baseRoute;
            this.cache = cache;
            this.loaders = loaders.ToArray();
            this.invoker = new ExtensionMethodInvoker(convert, new[] { typeof(ImageFiltering) }.Concat(declaredTypes).ToArray());

            Image.MaxWidth = Image.MaxHeight = 5000;
        }
コード例 #36
0
        /// <summary>
        /// Creates an instance of the ColorBloomTransitionHelper. 
        /// Any visuals to be later created and animated will be hosted within the specified UIElement.
        /// </summary>
        public ColorBloomTransitionHelper(UIElement hostForVisual)
        {
            this.hostForVisual = hostForVisual;

            // we have an element in the XAML tree that will host our Visuals
            var visual = ElementCompositionPreview.GetElementVisual(hostForVisual);
            _compositor = visual.Compositor;

            // create a container
            // adding children to this container adds them to the live visual tree
            _containerForVisuals = _compositor.CreateContainerVisual();
            ElementCompositionPreview.SetElementChildVisual(hostForVisual, _containerForVisuals);

            // initialize the ImageLoader and create the circle mask
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
            _circleMaskSurface = _imageLoader.CreateManagedSurfaceFromUri(new Uri("ms-appx:///Samples/SDK 10586/TransitionAnimation-ColorBloom/CircleOpacityMask.png"));
        }
コード例 #37
0
        /// <summary>
        /// Creates an instance of the ColorBloomTransitionHelper. 
        /// Any visuals to be later created and animated will be hosted within the specified UIElement.
        /// </summary>
        public ColorBloomTransitionHelper(UIElement hostForVisual)
        {
            this.hostForVisual = hostForVisual;

            // we have an element in the XAML tree that will host our Visuals
            var visual = ElementCompositionPreview.GetElementVisual(hostForVisual);
            _compositor = visual.Compositor;

            // create a container
            // adding children to this container adds them to the live visual tree
            _containerForVisuals = _compositor.CreateContainerVisual();
            ElementCompositionPreview.SetElementChildVisual(hostForVisual, _containerForVisuals);

            // initialize the ImageLoader and create the circle mask
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
            _circleMaskSurface = _imageLoader.CreateCircleSurface(200, Colors.White);
        }
コード例 #38
0
        private void SamplePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // Get backing visual from shadow container and interop compositor
            _shadowContainer = ElementCompositionPreview.GetElementVisual(ShadowContainer);
            _compositor = _shadowContainer.Compositor;

            // Get CompositionImage, its sprite visual
            _image = VisualTreeHelperExtensions.GetFirstDescendantOfType<CompositionImage>(ShadowContainer);
            _imageVisual = _image.SpriteVisual;
           
            // Add drop shadow to image visual
            _shadow = _compositor.CreateDropShadow();
            _imageVisual.Shadow = _shadow;

            // Initialize sliders to shadow defaults - with the exception of offset
            BlurRadiusSlider.Value  = _shadow.BlurRadius;   //defaults to 9.0f
            OffsetXSlider.Value     = _shadow.Offset.X;     //defaults to 0
            OffsetYSlider.Value     = _shadow.Offset.Y;     //defaults to 0
            RedSlider.Value         = _shadow.Color.R;      //defaults to 0 (black.R)
            GreenSlider.Value       = _shadow.Color.G;      //defaults to 0 (black.G) 
            BlueSlider.Value        = _shadow.Color.B;      //defaults to 0 (black.B) 

            // Load mask asset onto surface using helpers in SamplesCommon
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
            _imageMaskSurface = _imageLoader.CreateManagedSurfaceFromUri(new Uri("ms-appx:///Assets/CircleMask.png"));

            // Create surface brush for mask
            CompositionSurfaceBrush mask = _compositor.CreateSurfaceBrush();
            mask.Surface = _imageMaskSurface.Surface;
            
            // Get surface brush from composition image
            CompositionSurfaceBrush source = _image.SurfaceBrush as CompositionSurfaceBrush;

            // Create mask brush for toggle mask functionality
            _maskBrush = _compositor.CreateMaskBrush();
            _maskBrush.Mask = mask;
            _maskBrush.Source = source;

            // Initialize toggle mask and animation to false
            _isMaskEnabled = false;
            _isAnimationEnabled = false;
          
        }
コード例 #39
0
ファイル: SpriteContainer.cs プロジェクト: jlopresti/cassette
 public SpriteContainer(IImageLoader imageLoader, ISpritingSettings settings)
 {
     ImageLoader = imageLoader;
     this.settings = settings;
 }
コード例 #40
0
 public DuplicateImageFinder(IImageLoader imageLoader)
 {
     this.imageLoader = imageLoader;
 }
コード例 #41
0
ファイル: PhotoImageView.cs プロジェクト: Yetangitu/f-spot
        void Load(SafeUri uri)
        {
            timer = Log.DebugTimerStart ();
            if (loader != null)
                loader.Dispose ();

            loader = ImageLoader.Create (uri);
            loader.AreaPrepared += HandlePixbufPrepared;
            loader.AreaUpdated += HandlePixbufAreaUpdated;
            loader.Completed += HandleDone;
            loader.Load (uri);
        }
コード例 #42
0
ファイル: Image.cs プロジェクト: RandallFlagg/xwt
 public void SetCustomLoaderSource(IImageLoader imageLoader, string fileName, ImageTagSet tags)
 {
     sources = new [] {
         new NativeImageSource {
             CustomImageLoader = imageLoader,
             Source = fileName,
             Tags = tags
         }
     };
 }
コード例 #43
0
        /// <summary>
        /// Initialize Composition
        /// </summary>
        private void InitializeComposition()
        {

            // Retrieve an instance of the Compositor from the backing Visual of the Page
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            // Create a root visual from the Compositor
            _root = _compositor.CreateContainerVisual();

            // Set the root ContainerVisual as the XAML Page Visual           
            ElementCompositionPreview.SetElementChildVisual(this, _root);

            // Assign initial values to variables used to store updated offsets for the visuals          
            float posXUpdated = _posX;
            float posYUpdated = _posY;


            //Create a list of image brushes that can be applied to a visual
            string[] imageNames = { "60Banana.png", "60Lemon.png", "60Vanilla.png", "60Mint.png", "60Orange.png", "110Strawberry.png", "60SprinklesRainbow.png" };
            _imageBrushList = new List<CompositionSurfaceBrush>();
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
            for (int k = 0; k < imageNames.Length; k++)
            {
                var surface = _imageLoader.LoadImageFromUri(new Uri("ms-appx:///Samples/SDK 14393/ImplicitAnimationTransformer/" + imageNames[k]));
                _imageBrushList.Add(_compositor.CreateSurfaceBrush(surface));
            }

            // Create nxn matrix of visuals where n=row/ColumnCount-1 and passes random image brush to the function
            // that creates a visual
            for (int i = 1; i < _rowCount; i++)
            {
                posXUpdated = i * _distance;
                for (int j = 1; j < _columnCount; j++)
                {
                    CompositionSurfaceBrush brush = _imageBrushList[randomBrush.Next(_imageBrushList.Count)];

                    posYUpdated = j * _distance;
                    _root.Children.InsertAtTop(CreateChildElement(brush, posXUpdated, posYUpdated));
                }
            }

            // Update the default animation state
            UpdateAnimationState(EnableAnimations.IsChecked == true);
        }
コード例 #44
0
 /// <summary>
 /// Creates the circle used in the circle brush if not already created.
 /// </summary>
 private void EnsureCircleBrush()
 {
     if (_circleBrush == null)
     {
         _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
         _circleSurface = _imageLoader.CreateCircleSurface(200, Colors.White);
         _circleBrush = _compositor.CreateSurfaceBrush(_circleSurface.Surface);
     }
 }
コード例 #45
0
ファイル: Image.cs プロジェクト: RandallFlagg/xwt
 public StreamImageLoader(Toolkit toolkit, IImageLoader loader)
 {
     this.toolkit = toolkit;
     this.loader = loader;
 }
コード例 #46
0
ファイル: Image.cs プロジェクト: RandallFlagg/xwt
 public static Image FromCustomLoader(IImageLoader loader, string fileName)
 {
     return FromCustomLoader (loader, fileName, null);
 }
コード例 #47
0
        //private async Task HideStatusBar()
        //{
        //    //if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
        //    //{
        //    //    var statusBar = StatusBar.GetForCurrentView();
        //    //    await statusBar.HideAsync();
        //    //}
        //}

        private void InitializeCompositionVariables()
        {
            var bounds = ApplicationView.GetForCurrentView().VisibleBounds;
            var maxWindowWidth = bounds.Width.ToFloat();
            var maxWindowHeight = bounds.Height.ToFloat();
            var maxWindowRadius = Math.Max(maxWindowWidth, maxWindowHeight);

            // Setup sky visual's size, position, opacity, etc.
            _skyVisual = Sky.ContainerVisual();
            _skyVisual.Size = new Vector2(maxWindowRadius * SkyVisualAreaRatio);
            _skyVisual.Offset = new Vector3(-SkyVisualRadius + maxWindowWidth / 2.0f, -SkyVisualRadius + maxWindowHeight / 2.0f, 0.0f);
            _skyVisual.CenterPoint = new Vector3(SkyVisualRadius, SkyVisualRadius, 0.0f);
            _skyVisual.Opacity = 0;

            _compositor = _skyVisual.Compositor;
            _reading = _compositor.CreatePropertySet();
            _reading.InsertVector3("Offset", new Vector3(0.0f, 0.0f, 0.0f));
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
            _circleBrush = _compositor.CreateSurfaceBrush();
            _circleBrush.Surface = _imageLoader.LoadImageFromUri(new Uri(StarUriString));

            if (_inclinometer != null) SetupSkyVisualOffsetExpressionAnimation();
        }
コード例 #48
0
 /// <summary>
 /// Creates the circle used in the circle brush if not already created.
 /// </summary>
 private void EnsureCircleBrush()
 {
     if (_circleBrush == null)
     {
         _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
         _circleSurface = _imageLoader.CreateManagedSurfaceFromUri(new Uri(CircleImagePath));
         _circleBrush = _compositor.CreateSurfaceBrush(_circleSurface.Surface);
     }
 }
コード例 #49
0
ファイル: Image.cs プロジェクト: RandallFlagg/xwt
        internal static Image FromCustomLoader(IImageLoader loader, string fileName, ImageTagSet tags)
        {
            var toolkit = Toolkit.CurrentEngine;
            if (toolkit == null)
                throw new ToolkitNotInitializedException ();

            var ld = new StreamImageLoader (toolkit, loader);
            return LoadImage (ld, fileName, tags);
        }