Beispiel #1
0
        /// <summary>Applies the image data so it's ready for rendering.</summary>
        public void UpdateDimensions(LayoutBox box)
        {
            int w = (int)box.InnerWidth;
            int h = (int)box.InnerHeight;

            DynamicTexture img = ImageData_;

            if (w == img.Width && h == img.Height)
            {
                // No change. Stop there.
                return;
            }

            // Resize the texture (clearing it):
            img.Resize(w, h, true);
        }
        /// <summary>Applies the image data so it's ready for rendering.</summary>
        public void ApplyImageData()
        {
            // Grab the canvas:
            Element element = canvas;

            // Grab its computed style:
            ComputedStyle computed = element.style.Computed;

            if (ImageData == null)
            {
                ImageData = new DynamicTexture();
            }

            // Resize the texture:
            ImageData.Resize(computed.PixelWidth, computed.PixelHeight, false);

            if (ImageData.Width != 0 && ImageData.Height != 0)
            {
                if (Package == null)
                {
                    //We now need a package to actually display it.

                    // Create the package:
                    Package = new ImagePackage(ImageData);

                    // Apply it to the element:
                    if (computed.BGImage == null)
                    {
                        computed.BGImage = new BackgroundImage(element);
                    }
                    computed.BGImage.SetImage(Package);
                }

                // Run the change event:
                element.Run("onchange");

                apply();
            }
        }