public DllImageData(Resource resource, string filename, LayerMipmapCount lm, ImageFormat format, GliFormat originalFormat) : base(format, lm, GetSize(resource)) { Resource = resource; Filename = filename; OriginalFormat = originalFormat; }
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()); } }
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); }
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); }
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)); } }
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); } } } }
public abstract T CreateT(LayerMipmapCount lm, Size3 size, Format format, bool createUav);
public ITexture Create(LayerMipmapCount lm, Size3 size, Format format, bool createUav) { return(CreateT(lm, size, format, createUav)); }
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)); }
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)); }
public ByteImageData(byte[] data, LayerMipmapCount lm, Size3 size, ImageFormat format) : base(format, lm, size) { handle = GCHandle.Alloc(data, GCHandleType.Pinned); ptr = handle.AddrOfPinnedObject(); }
public override TextureArray2D CreateT(LayerMipmapCount lm, Size3 size, Format format, bool createUav) { return(new TextureArray2D(lm, size, format, createUav)); }
protected ImageData(ImageFormat format, LayerMipmapCount layerMipmap, Size3 size) { Format = format; LayerMipmap = layerMipmap; Size = size; }