Пример #1
0
 public DllImageData(Resource resource, string filename, LayerMipmapCount lm, ImageFormat format, GliFormat originalFormat)
     : base(format, lm, GetSize(resource))
 {
     Resource       = resource;
     Filename       = filename;
     OriginalFormat = originalFormat;
 }
Пример #2
0
 public Resource(uint format, Size3 size, LayerMipmapCount lm)
 {
     Id = Dll.image_allocate(format, size.Width, size.Height, size.Depth, lm.Layers, lm.Mipmaps);
     if (Id == 0)
     {
         throw new Exception("error allocating image: " + Dll.GetError());
     }
 }
Пример #3
0
        public Texture3D(int numMipmaps, Size3 size, Format format, bool createUav, bool createRt = true)
        {
            Size        = size;
            LayerMipmap = new LayerMipmapCount(1, numMipmaps);
            Format      = format;

            handle = new SharpDX.Direct3D11.Texture3D(Device.Get().Handle, CreateTextureDescription(createUav, createRt));

            CreateTextureViews(createUav, createRt);
        }
Пример #4
0
        public TextureArray2D(LayerMipmapCount lm, Size3 size, Format format, bool createUav)
        {
            Debug.Assert(size.Depth == 1);
            Size        = size;
            LayerMipmap = lm;
            this.Format = format;

            handle = new SharpDX.Direct3D11.Texture2D(Device.Get().Handle, CreateTextureDescription(createUav));

            CreateTextureViews(createUav);
        }
Пример #5
0
        public Image(Resource resource, string filename, LayerMipmapCount lm, ImageFormat format, GliFormat originalFormat)
        {
            Resource       = resource;
            Filename       = filename;
            Format         = format;
            OriginalFormat = originalFormat;
            // load relevant information

            Layers = new List <Layer>(lm.Layers);
            for (var curLayer = 0; curLayer < lm.Layers; ++curLayer)
            {
                Layers.Add(new Layer(resource, curLayer, lm.Mipmaps));
            }
        }
Пример #6
0
        public async Task ApplyToModels(ModelsEx models)
        {
            // clear images
            if (ImportMode == ViewerConfig.ImportMode.Replace)
            {
                models.Images.Clear();
            }

            var import       = new ImportDialogController(models);
            var layerMipmaps = new LayerMipmapCount(NumLayers, NumMipmaps);
            var imgSize      = new Size3(Width, Height, Depth);

            // add images from config
            foreach (var img in Images)
            {
                if (img.Data == null)
                {
                    await import.ImportImageAsync(img.Filename, img.Alias);
                }
                else
                {
                    Debug.Assert(img.Format != null);
                    var fmt = new ImageFormat(img.Format.Value);

                    // load base 64 bytes
                    var bytes = System.Convert.FromBase64String(img.Data);
                    bytes = Compression.Decompress(bytes);
                    var      bi  = new ByteImageData(bytes, layerMipmaps, imgSize, fmt);
                    ITexture tex = null;
                    if (bi.Is3D)
                    {
                        tex = new Texture3D(bi);
                    }
                    else
                    {
                        tex = new TextureArray2D(bi);
                    }

                    try
                    {
                        models.Images.AddImage(tex, false, img.Filename, fmt.GliFormat, img.Alias);
                    }
                    catch (Exception e)
                    {
                        tex?.Dispose();
                        models.Window.ShowErrorDialog(e);
                    }
                }
            }
        }
Пример #7
0
 public abstract T CreateT(LayerMipmapCount lm, Size3 size, Format format,
                           bool createUav);
Пример #8
0
 public ITexture Create(LayerMipmapCount lm, Size3 size, Format format, bool createUav)
 {
     return(CreateT(lm, size, format, createUav));
 }
Пример #9
0
        public static DllImageData CreateImage(ImageFormat format, Size3 size, LayerMipmapCount lm)
        {
            var res = new Resource((uint)format.GliFormat, size, lm);

            return(new DllImageData(res, "tmp", lm, format, format.GliFormat));
        }
Пример #10
0
 public override Texture3D CreateT(LayerMipmapCount lm, Size3 size, Format format, bool createUav)
 {
     Debug.Assert(lm.Layers == 1);
     return(new Texture3D(lm.Mipmaps, size, format, createUav));
 }
Пример #11
0
 public ByteImageData(byte[] data, LayerMipmapCount lm, Size3 size, ImageFormat format)
     : base(format, lm, size)
 {
     handle = GCHandle.Alloc(data, GCHandleType.Pinned);
     ptr    = handle.AddrOfPinnedObject();
 }
Пример #12
0
 public override TextureArray2D CreateT(LayerMipmapCount lm, Size3 size, Format format, bool createUav)
 {
     return(new TextureArray2D(lm, size, format, createUav));
 }
Пример #13
0
 protected ImageData(ImageFormat format, LayerMipmapCount layerMipmap, Size3 size)
 {
     Format      = format;
     LayerMipmap = layerMipmap;
     Size        = size;
 }