static TopWallpaperRenderer()
        {
            ScreenArea = new Rect(0, 0, 412, 240);

            var defTopAlt = new BitmapImage();
            defTopAlt.BeginInit();
            //defTopAlt.StreamSource = (Stream) Extensions.GetResources(@"TopAlt_DefMask\.png").First().Value;
            defTopAlt.UriSource = new Uri(@"pack://application:,,,/ThemeEditor.WPF;component/Resources/TopAlt_DefMask.png");
            defTopAlt.CacheOption = BitmapCacheOption.OnLoad;
            defTopAlt.EndInit();

            var bgrData = defTopAlt.GetBgr24Data();
            RawTexture rTex = new RawTexture(defTopAlt.PixelWidth, defTopAlt.PixelHeight, RawTexture.DataFormat.A8);
            rTex.Encode(bgrData);
            DefaultTopSquares = new TextureViewModel(rTex, null);

            RenderToolFactory.RegisterTool<PenTool, Pen>
                (key => new Pen(new SolidColorBrush(key.Color)
                {
                    Opacity = key.Opacity
                },
                            key.Width));

            RenderToolFactory.RegisterTool<SolidColorBrushTool, Brush>
                (key => new SolidColorBrush(key.Color)
                {
                    Opacity = key.Opacity
                });

            RenderToolFactory.RegisterTool<LinearGradientBrushTool, Brush>
                (key => new LinearGradientBrush(key.ColorA, key.ColorB, key.Angle)
                {
                    Opacity = key.Opacity
                });

            RenderToolFactory.RegisterTool<ImageBrushTool, Brush>
                (key => new ImageBrush(key.Image)
                {
                    TileMode = key.Mode,
                    ViewportUnits = key.ViewportUnits,
                    Viewport = key.Viewport,
                    Opacity = key.Opacity
                });

            Type ownerType = typeof(TopWallpaperRenderer);
            IsEnabledProperty
                .OverrideMetadata(ownerType, new FrameworkPropertyMetadata(false, OnIsEnabledChanged));

            ClipToBoundsProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(true, null, (o, value) => true));
            WidthProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(412.0, null, (o, value) => 412.0));
            HeightProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(240.0, null, (o, value) => 240.0));

            EffectProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(default(WarpEffect),
                    null,
                    (o, value) => ((TopWallpaperRenderer) o).GetWarpEffectInstance()));
        }
Пример #2
0
 private BitmapSource DecodeTexture(RawTexture model)
 {
     BitmapSource bmp;
     switch (model.Format)
     {
         default:
         case RawTexture.DataFormat.Invalid:
         {
             return null;
         }
         case RawTexture.DataFormat.Bgr888:
         case RawTexture.DataFormat.Bgr565:
         {
             var rgb888 = model.Decode();
             bmp = BitmapSource.Create(model.Width,
                 model.Height,
                 96,
                 96,
                 PixelFormats.Bgr24,
                 null,
                 rgb888,
                 model.Width * 3);
             break;
         }
         case RawTexture.DataFormat.A8:
         {
             var rgb888 = model.Decode();
             var alpha = GscToAlpha(rgb888);
             bmp = BitmapSource.Create(model.Width,
                 model.Height,
                 96,
                 96,
                 PixelFormats.Bgra32,
                 null,
                 alpha,
                 model.Width * 4);
             break;
         }
     }
     bmp.Freeze();
     return bmp;
 }
Пример #3
0
 public void EncodeTexture(BitmapSource bitmap, RawTexture.DataFormat targetFormat)
 {
     var bgrData = bitmap.GetBgr24Data();
     Model.Encode(bgrData, bitmap.PixelWidth, bitmap.PixelHeight, targetFormat);
     Invalidate();
 }
Пример #4
0
 public TextureViewModel(RawTexture model, string tag) : base(model, tag) {}
Пример #5
0
 public ImageSize(int x, int y, RawTexture.DataFormat format) : this()
 {
     X = x;
     Y = y;
     Format = format;
 }
Пример #6
0
 protected SMDH(bool inter)
 {
     AppTitles = new AppTitle[16];
     SmallIcon = new RawTexture(24, 24, RawTexture.DataFormat.Bgr565);
     LargeIcon = new RawTexture(48, 48, RawTexture.DataFormat.Bgr565);
 }