Ejemplo n.º 1
0
        //protected Stream ImageStream;

        public RDTTextureViewModel(RedBaseClass data, RedDocumentViewModel file)
        {
            Header = "Texture Preview";
            File   = file;
            _data  = data;

            SetupImage();
        }
Ejemplo n.º 2
0
        public RDTTextureViewModel(Stream stream, RedDocumentViewModel file)
        {
            Header = "Preview";
            File   = file;
            //_data = data;
            //ImageStream = stream;

            _ = LoadImageFromStream(stream);
        }
Ejemplo n.º 3
0
        public RDTDataViewModel(RedBaseClass data, RedDocumentViewModel file)
        {
            OnDemandLoadingCommand = new DelegateCommand <TreeViewNode>(ExecuteOnDemandLoading, CanExecuteOnDemandLoading);
            OpenImportCommand      = new Functionality.Commands.DelegateCommand <ICR2WImport>(ExecuteOpenImport);
            //ExportChunkCommand = new DelegateCommand<ChunkViewModel>((p) => ExecuteExportChunk(p), (p) => CanExportChunk(p));

            File   = file;
            _data  = data;
            Header = _data.GetType().Name;

            //RootChunk = Chunks[0];

            //if (Chunks != null)
            //{
            //    foreach (ChunkViewModel item in Chunks)
            //    {
            //        item.WhenAnyValue(x => x.IsDirty).Subscribe(x => IsDirty |= x);
            //    }
            //}
            //_file.WhenAnyValue(x => x).Subscribe(x => IsDirty |= true);
        }
Ejemplo n.º 4
0
 public RDTDataViewModel(string header, RedBaseClass data, RedDocumentViewModel file) : this(data, file)
 {
     Header = header;
 }
Ejemplo n.º 5
0
 public RDTMeshViewModel(CMesh data, RedDocumentViewModel file)
 {
     Header = "Preview";
     File   = file;
     _data  = data;
 }
        public RDTInkTextureAtlasViewModel(inkTextureAtlas atlas, CBitmapTexture xbm, RedDocumentViewModel file) : base(xbm, file)
        {
            _atlas = atlas;
            Header = "Part Mapping";
            Width  = xbm.Width;
            Height = xbm.Height;

            Bitmap sourceBitmap;

            using (var outStream = new MemoryStream())
            {
                BitmapEncoder enc = new TiffBitmapEncoder();
                enc.Frames.Add(BitmapFrame.Create((BitmapSource)Image));
                enc.Save(outStream);
                sourceBitmap = new Bitmap(outStream);
            }

            var destBitmap = new Bitmap((int)Math.Round(Width), (int)Math.Round(Height), System.Drawing.Imaging.PixelFormat.Format64bppArgb);

            using (var gfx = Graphics.FromImage(destBitmap))
            {
                // this is doesn't account for premultipied alpha, so the opacity mask is still needed
                var matrix = new ColorMatrix(new float[][]
                {
                    new float[] { 1, 0, 0, 0, 0 },
                    new float[] { 0, 1, 0, 0, 0 },
                    new float[] { 0, 0, 1, 0, 0 },
                    new float[] { 0, 0, 0, 1, 0 },
                    new float[] { 0, 0, 0, 0, 0 },
                });
                //matrix.Matrix03 = 1F;
                //matrix.Matrix13 = TintColor.Alpha / 3F;
                //matrix.Matrix23 = TintColor.Alpha / 3F;
                //matrix.Matrix40 = TintColor.R / 255F;
                //matrix.Matrix41 = TintColor.G / 255F;
                //matrix.Matrix42 = TintColor.B / 255F;

                var attributes = new ImageAttributes();

                attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                gfx.DrawImage(sourceBitmap, new Rectangle(0, 0, (int)Width, (int)Height), 0, 0, Width, Height, GraphicsUnit.Pixel, attributes);
            }

            sourceBitmap.Dispose();

            Image = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                destBitmap.GetHbitmap(),
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());

            foreach (var part in atlas.Slots[0].Parts)
            {
                OverlayItems.Add(new InkTextureAtlasMapperViewModel(part, xbm, atlas.Slots[0].Texture.DepotPath.ToString(), file.RelativePath, (BitmapSource)Image));
            }
        }