/// <summary> /// Loads an image with multiple frames of renderable data, each /// frame is of size CellW x CellH, with no spacing. /// </summary> /// <param name="path">Memory location (or url) of image file to load.</param> /// <param name="cellW">Width of each cell in image.</param> /// <param name="cellH">Height of each cell in image.</param> /// <param name="cache">If set to true this image is added to the resource cache to save loading /// time when this image is requested again.</param> /// <param name="flags">Describes how this image should be loaded, rendered and stored.</param> /// <returns>A new image instance containing the image data found at the given url.</returns> public static Image LoadImage(object path, int cellW, int cellH, ImageFlags flags, bool cache) { if (ResourceManager.ResourceIsCached(path.ToString()) == true) { DebugLogger.WriteLog("Loading image " + path.ToString() + " from cache."); Image cacheImage = (Image)ResourceManager.RetrieveResource(path.ToString()); if (cacheImage.Width == cellW && cacheImage.Height == cellH && cacheImage.HorizontalSpacing == 0 && cacheImage.VerticalSpacing == 0) { return(cacheImage); } } DebugLogger.WriteLog("Loading image from " + path.ToString() + "."); Image image = new Image(path, cellW, cellH, flags); if (cache == true) { if ((flags & ImageFlags.Dynamic) != 0) { throw new Exception("Dynamic images cannot be cached."); } ResourceManager.CacheResource(path.ToString(), image); } return(image); }
void Init(Context ctx, int w, int h, IntPtr data, ImageFlags flags) { Context = ctx; Width = w; Height = h; ID = nvgCreateImageRGBA(ctx.ctx, w, h, (int)flags, data); }
public Image(Context ctx, int w, int h, byte[] data, ImageFlags flags) { GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); Init(ctx, w, h, handle.AddrOfPinnedObject(), flags); handle.Free(); }
public static HeaderRecord Initialized(ImageType type, ImageFlags flags, long size, int blockSize, int blockExtra) { HeaderRecord result = new HeaderRecord(); result._fileVersion = new FileVersion(0x00010001); result.HeaderSize = 400; result.ImageType = type; result.Flags = flags; result.Comment = "Created by .NET ThinkAway"; result.LegacyGeometry = new GeometryRecord(); result.DiskSize = size; result.BlockSize = blockSize; result.BlockExtraSize = blockExtra; result.BlockCount = (int)((size + blockSize - 1) / blockSize); result.BlocksAllocated = 0; result.BlocksOffset = ((PreHeaderRecord.Size + result.HeaderSize + 511) / 512) * 512; result.DataOffset = (uint)(((result.BlocksOffset + (result.BlockCount * 4) + 511) / 512) * 512); result.UniqueId = Guid.NewGuid(); result.ModificationId = Guid.NewGuid(); result.LChsGeometry = new GeometryRecord(); return result; }
public static HeaderRecord Initialized(ImageType type, ImageFlags flags, long size, int blockSize, int blockExtra) { HeaderRecord result = new HeaderRecord(); result._fileVersion = new FileVersion(0x00010001); result.HeaderSize = 400; result.ImageType = type; result.Flags = flags; result.Comment = "Created by .NET DiscUtils"; result.LegacyGeometry = new GeometryRecord(); result.DiskSize = size; result.BlockSize = blockSize; result.BlockExtraSize = blockExtra; result.BlockCount = (int)((size + blockSize - 1) / blockSize); result.BlocksAllocated = 0; result.BlocksOffset = (PreHeaderRecord.Size + result.HeaderSize + 511) / 512 * 512; result.DataOffset = (uint)((result.BlocksOffset + result.BlockCount * 4 + 511) / 512 * 512); result.UniqueId = Guid.NewGuid(); result.ModificationId = Guid.NewGuid(); result.LChsGeometry = new GeometryRecord(); return(result); }
internal PageInfo(Image img) { this.HorizontalResolution = img.HorizontalResolution; this.WidthPixels = (int)img.PhysicalDimension.Width; this.WidthInches = img.PhysicalDimension.Width / this.HorizontalResolution; this.VerticalResolution = img.VerticalResolution; this.HeightPixels = (int)img.PhysicalDimension.Height; this.HeightInches = img.PhysicalDimension.Height / this.VerticalResolution; this.AspectRatio = this.WidthInches / this.HeightInches; this.ImageFlags = (ImageFlags)img.Flags; this.PixelFormat = img.PixelFormat; this.ImageFormat = ImageHelper.GetImageFormat_Instance(img.RawFormat.Guid); this.ImageFormatName = ImageHelper.GetImageFormat_Name(img); this.PaletteFlags = (PaletteFlags)img.Palette.Flags; this.PaletteEntries = img.Palette.Entries; this.ImageProperties = new ImageProperty[img.PropertyIdList.Length]; for (int i = 0; i < img.PropertyIdList.Length; i++) { int propid = img.PropertyIdList[i]; PropertyItem prop = img.GetPropertyItem(propid); this.ImageProperties[i] = new ImageProperty(prop); } }
public Image(Context ctx, string filename, ImageFlags flags) { ID = nvgCreateImage(ctx.ctx, filename, (int)flags); int w, h; nvgImageSize(ctx.ctx, ID, out w, out h); Width = w; Height = h; Console.WriteLine("Image Width: {0} Height: {1}", w, h); }
//=========== READING ============ #region Reading /**<summary>Reads the image entry.</summary>*/ public void Read(BinaryReader reader) { StartAddress = reader.ReadUInt32(); Width = reader.ReadInt16(); Height = reader.ReadInt16(); XOffset = reader.ReadInt16(); YOffset = reader.ReadInt16(); Flags = (ImageFlags)reader.ReadUInt16(); Unused = reader.ReadUInt16(); }
/** <summary> Constructs a palette image with the specified dimensions and compression type. </summary> */ public PaletteImage(int width, int height, int xOffset, int yOffset, ImageFlags compressionType) { this.pixels = new byte[width, height]; this.entry = new ImageEntry(); this.entry.Flags = compressionType; this.entry.Width = (short)width; this.entry.Height = (short)height; this.entry.XOffset = (short)xOffset; this.entry.YOffset = (short)yOffset; }
//========= CONSTRUCTORS ========= #region Constructors /**<summary>Constructs the default image entry.</summary>*/ public ImageEntry() { StartAddress = 0; Width = 0; Height = 0; XOffset = 0; YOffset = 0; Flags = ImageFlags.None; Unused = 0; }
/** <summary> Constructs a palette image with the specified dimensions and compression type. </summary> */ public PaletteImage(Size size, Point offset, ImageFlags compressionType) { this.pixels = new byte[size.Width, size.Height]; this.entry = new ImageEntry(); this.entry.Flags = compressionType; this.entry.Width = (short)size.Width; this.entry.Height = (short)size.Height; this.entry.XOffset = (short)offset.X; this.entry.YOffset = (short)offset.Y; }
public bool hasFlag(ImageFlags imgFlag) { bool ret = OgrePINVOKE.Image_hasFlag(swigCPtr, (int)imgFlag); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
//========= CONSTRUCTORS ========= #region Constructors /**<summary>Constructs the default image entry.</summary>*/ public ImageEntry() { this.StartAddress = 0; this.Width = 0; this.Height = 0; this.XOffset = 0; this.YOffset = 0; this.Flags = ImageFlags.None; this.Unused = 0; }
//=========== READING ============ #region Reading /**<summary>Reads the image entry.</summary>*/ public void Read(BinaryReader reader) { this.StartAddress = reader.ReadUInt32(); this.Width = reader.ReadInt16(); this.Height = reader.ReadInt16(); this.XOffset = reader.ReadInt16(); this.YOffset = reader.ReadInt16(); this.Flags = (ImageFlags)reader.ReadUInt16(); this.Unused = reader.ReadUInt16(); }
public int Read(FileVersion version, byte[] buffer, int offset) { if (version.Major == 0) { ImageType = (ImageType)EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0); Flags = (ImageFlags)EndianUtilities.ToUInt32LittleEndian(buffer, offset + 4); Comment = EndianUtilities.BytesToString(buffer, offset + 8, 256).TrimEnd('\0'); LegacyGeometry = new GeometryRecord(); LegacyGeometry.Read(buffer, offset + 264); DiskSize = EndianUtilities.ToInt64LittleEndian(buffer, offset + 280); BlockSize = EndianUtilities.ToInt32LittleEndian(buffer, offset + 288); BlockCount = EndianUtilities.ToInt32LittleEndian(buffer, offset + 292); BlocksAllocated = EndianUtilities.ToInt32LittleEndian(buffer, offset + 296); UniqueId = EndianUtilities.ToGuidLittleEndian(buffer, offset + 300); ModificationId = EndianUtilities.ToGuidLittleEndian(buffer, offset + 316); ParentId = EndianUtilities.ToGuidLittleEndian(buffer, offset + 332); HeaderSize = 348; BlocksOffset = HeaderSize + PreHeaderRecord.Size; DataOffset = (uint)(BlocksOffset + BlockCount * 4); BlockExtraSize = 0; ParentModificationId = Guid.Empty; } else if (version.Major == 1 && version.Minor == 1) { HeaderSize = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0); ImageType = (ImageType)EndianUtilities.ToUInt32LittleEndian(buffer, offset + 4); Flags = (ImageFlags)EndianUtilities.ToUInt32LittleEndian(buffer, offset + 8); Comment = EndianUtilities.BytesToString(buffer, offset + 12, 256).TrimEnd('\0'); BlocksOffset = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 268); DataOffset = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 272); LegacyGeometry = new GeometryRecord(); LegacyGeometry.Read(buffer, offset + 276); DiskSize = EndianUtilities.ToInt64LittleEndian(buffer, offset + 296); BlockSize = EndianUtilities.ToInt32LittleEndian(buffer, offset + 304); BlockExtraSize = EndianUtilities.ToInt32LittleEndian(buffer, offset + 308); BlockCount = EndianUtilities.ToInt32LittleEndian(buffer, offset + 312); BlocksAllocated = EndianUtilities.ToInt32LittleEndian(buffer, offset + 316); UniqueId = EndianUtilities.ToGuidLittleEndian(buffer, offset + 320); ModificationId = EndianUtilities.ToGuidLittleEndian(buffer, offset + 336); ParentId = EndianUtilities.ToGuidLittleEndian(buffer, offset + 352); ParentModificationId = EndianUtilities.ToGuidLittleEndian(buffer, offset + 368); if (HeaderSize > 384) { LChsGeometry = new GeometryRecord(); LChsGeometry.Read(buffer, offset + 384); } } else { throw new IOException("Unrecognized file version: " + version); } return((int)HeaderSize); }
/// <summary> /// Creates image by loading it from the specified chunk of memory. /// </summary> /// <returns>Handle to the image.</returns> public static int CreateImageMem(this Nvg nvg, ImageFlags imageFlags, byte[] data) { ImageResult result = ImageResult.FromMemory(data, ColorComponents.RedGreenBlueAlpha); if (result == null) { return(0); } int image = CreateImageRgba(nvg, (uint)result.Width, (uint)result.Height, imageFlags, data); return(image); }
public int CreateTexture(TextureType type, int w, int h, ImageFlags imageFlags, byte[] d) { var texture = new Texture2D(_device, w, h); if (d != null) { texture.SetData(d); } _textures.Add(texture); return(_textures.Count); }
public ImageEditForm(TRibbonImage image, ImageFlags flags) : this() { Bitmap uIImage; _image = image; _flags = flags; _bitmap = new Bitmap(64, 64, PixelFormat.Format32bppArgb); ClearBitmap(_bitmap); _filename = image.Owner.BuildAbsoluteFilename(image.Source); if (File.Exists(_filename)) { uIImage = AlphaBitmap.TryAlphaBitmapFromFile(_filename); try { Graphics canvas = Graphics.FromImage(_bitmap); canvas.DrawImage(uIImage, new Point((64 - uIImage.Width) / 2, (64 - uIImage.Height) / 2)); canvas.Dispose(); } finally { uIImage.Dispose(); } } EditImageFile.Text = _image.Source; if (_image.MinDpi == 0) { ComboBoxMinDpi.SelectedIndex = 0; } else if (_image.MinDpi < 108) { ComboBoxMinDpi.SelectedIndex = 1; } else if (_image.MinDpi < 132) { ComboBoxMinDpi.SelectedIndex = 2; } else if (_image.MinDpi < 156) { ComboBoxMinDpi.SelectedIndex = 3; } else { ComboBoxMinDpi.SelectedIndex = 4; } EditResourceId.Value = _image.Id; EditSymbol.Text = _image.Symbol; UpdateControls(); }
/// <summary> /// Copy constructor /// </summary> /// <param name="img"> </param> public Image(Image img) : base() { this.width = img.width; this.height = img.height; this.depth = img.depth; this.size = img.size; this.numMipMaps = img.numMipMaps; this.flags = img.flags; this.format = img.format; this.buffer = img.buffer; //TODO //m_bAutoDelete }
public static bool GetImageFlags(string realFileName, out ImageFlags flags, out string error) { error = null; unsafe { bool result = OgreImageManager.getImageFlags(RenderingSystem.realRoot, realFileName, out uint uflags, out IntPtr errPointer); string err = OgreNativeWrapper.GetOutString(errPointer); if (err != null) error = string.Format("Error in file \"{0}\" ({1}).", realFileName, err); } flags = (ImageFlags)uflags; return(result); }
private ImageFlags GetFlags(bool applyPalettes, bool showBoxes, ImageFlags flipFlags) { var result = flipFlags; if (applyPalettes) { result |= ImageFlags.Palettes; } if (showBoxes) { result |= ImageFlags.Boxes; } return(result); }
/// <summary> /// Initializes a blank image of size Width x Height with 1 frame. /// </summary> /// <param name="width">Width of image to create.</param> /// <param name="height">Height of image to create.</param> public Image(int width, int height, ImageFlags flags) { _width = width; _height = height; _flags = flags; _frames = new IImageFrame[1]; _frames[0] = GraphicsManager.CreateImageFrame(new PixelMap(_width, _height)); // Are we dynamic? If not we don't need the full pixelmaps data so lets destroy it and // free up a bit of memory. if ((_flags & ImageFlags.Dynamic) == 0 && _fullPixelMap != null) { _frames[0].PixelMap.Data = null; //GC.Collect(); } }
internal void SetValues(ImageFlags Flags) { this.HasFlags = (Flags > 0); if (Flags > 0) { this.HasAlpha = ((Flags & ImageFlags.HasAlpha) > 0); this.HasRealDPI = ((Flags & ImageFlags.HasRealDpi) > 0); this.HasRealPixelSize = ((Flags & ImageFlags.HasRealPixelSize) > 0); this.IsTranslucent = ((Flags & ImageFlags.HasTranslucent) > 0); this.IsPartiallyScalable = ((Flags & ImageFlags.PartiallyScalable) > 0); this.IsScalable = ((Flags & ImageFlags.Scalable) > 0); this.ColorSpaceCMYK = ((Flags & ImageFlags.ColorSpaceCmyk) > 0); this.ColorSpaceGRAY = ((Flags & ImageFlags.ColorSpaceGray) > 0); this.ColorSpaceRGB = ((Flags & ImageFlags.ColorSpaceRgb) > 0); this.ColorSpaceYCBCR = ((Flags & ImageFlags.ColorSpaceYcbcr) > 0); this.ColorSpaceYCCK = ((Flags & ImageFlags.ColorSpaceYcck) > 0); } }
/// <summary> /// Initilizes a new image from a file. /// </summary> /// <param name="path">Memory location (or url) of image file to load.</param> public Image(object path, ImageFlags flags) { if ((path is PixelMap) == false) { if (path is string) { _url = (string)path; } _fullPixelMap = PixelMapFactory.LoadPixelMap(path); } else { _fullPixelMap = (path as PixelMap).Copy(); } if (_fullPixelMap == null) { return; } PixelMap map = _fullPixelMap.Copy(); map.Mask(GraphicsManager.ColorKey); _mask = GraphicsManager.ColorKey; _width = _fullPixelMap.Width; _height = _fullPixelMap.Height; _flags = flags; _frames[0] = GraphicsManager.CreateImageFrame(map); // Are we dynamic? If not we don't need the full pixelmaps data so lets destroy it and // free up a bit of memory. if ((_flags & ImageFlags.Dynamic) == 0 && _fullPixelMap != null) { _fullPixelMap.Data = null; _frames[0].PixelMap.Data = null; //GC.Collect(); } }
public void Load(Vector2D <uint> size, ImageFlags flags, Rendering.Texture type, ReadOnlySpan <byte> data) { _format = (type == Rendering.Texture.Rgba) ? Format.R8G8B8A8Unorm : Format.R8Unorm; Id = ++_idCounter; Size = size; _type = type; _mipLevelCount = CalculateMipLevelCount(); _image = CreateImage(type); TextureType = type; _flags = flags; _memory = BindImageMemory(); if ((data == null) || (data.Length == 0)) { data = FakeData(); } Upload(data); _imageView = CreateImageView(); _sampler = CreateSampler(); }
/// <summary> /// Initilizes a new image with mutliple frame cells spaced evenly out from a file. /// </summary> /// <param name="path">Memory location (or url) of image file to load.</param> /// <param name="cellW">Width of each cell in image.</param> /// <param name="cellH">Height of each cell in image.</param> /// <param name="cellHSeperation">Vertical seperation of each cell in image.</param> /// <param name="cellVSeperation">Horizontal seperation of each cell in image.</param> public Image(object path, int cellW, int cellH, int cellHSeperation, int cellVSeperation, ImageFlags flags) { if ((path is PixelMap) == false) { if (path is string) { _url = (string)path; } _fullPixelMap = PixelMapFactory.LoadPixelMap(path); } else { _fullPixelMap = (path as PixelMap).Copy(); } if (_fullPixelMap == null) { return; } _width = cellW; _height = cellH; _hSpacing = cellHSeperation; _vSpacing = cellVSeperation; _flags = flags; CreateFrames(); // Are we dynamic? If not we don't need the full pixelmaps data so lets destroy it and // free up a bit of memory. if ((_flags & ImageFlags.Dynamic) == 0 && _fullPixelMap != null) { _fullPixelMap.Data = null; for (int i = 0; i < _frames.Length; i++) { _frames[i].PixelMap.Data = null; } //GC.Collect(); } }
public void Load(Vector2D <uint> size, ImageFlags flags, Rendering.Texture type, ReadOnlySpan <byte> data) { Id = ++_idCounter; _textureID = _gl.GenTexture(); Size = size; TextureType = type; _flags = flags; Bind(); _renderer.CheckError("tex paint tex"); SetPixelStore(); Load(data); MinFilter(); MagFilter(); RepeatX(); RepeatY(); ResetPixelStore(); Mipmaps(); _renderer.CheckError("create tex"); Unbind(); }
/// <summary> /// Creates image by loading it from the disk from specified file name. /// </summary> /// <returns>Handle to the image.</returns> public static int CreateImage(this Nvg nvg, string fileName, ImageFlags imageFlags) { Stream stream; try { stream = File.OpenRead(fileName); } catch { return(0); } ImageResult result = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha); if (result == null) { return(0); } int image = CreateImageRgba(nvg, (uint)result.Width, (uint)result.Height, imageFlags, result.Data); stream.Close(); stream.Dispose(); return(image); }
public int Read(FileVersion version, byte[] buffer, int offset) { if (version.Major == 0) { ImageType = (ImageType)Utilities.ToUInt32LittleEndian(buffer, offset + 0); Flags = (ImageFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 4); Comment = Utilities.BytesToString(buffer, offset + 8, 256).TrimEnd(new char[] { '\0' }); LegacyGeometry = new GeometryRecord(); LegacyGeometry.Read(buffer, offset + 264); DiskSize = Utilities.ToInt64LittleEndian(buffer, offset + 280); BlockSize = Utilities.ToInt32LittleEndian(buffer, offset + 288); BlockCount = Utilities.ToInt32LittleEndian(buffer, offset + 292); BlocksAllocated = Utilities.ToInt32LittleEndian(buffer, offset + 296); UniqueId = Utilities.ToGuidLittleEndian(buffer, offset + 300); ModificationId = Utilities.ToGuidLittleEndian(buffer, offset + 316); ParentId = Utilities.ToGuidLittleEndian(buffer, offset + 332); HeaderSize = 348; BlocksOffset = HeaderSize + PreHeaderRecord.Size; DataOffset = (uint)(BlocksOffset + (BlockCount * 4)); BlockExtraSize = 0; ParentModificationId = Guid.Empty; } else if (version.Major == 1 && version.Minor == 1) { HeaderSize = Utilities.ToUInt32LittleEndian(buffer, offset + 0); ImageType = (ImageType)Utilities.ToUInt32LittleEndian(buffer, offset + 4); Flags = (ImageFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 8); Comment = Utilities.BytesToString(buffer, offset + 12, 256).TrimEnd(new char[] { '\0' }); BlocksOffset = Utilities.ToUInt32LittleEndian(buffer, offset + 268); DataOffset = Utilities.ToUInt32LittleEndian(buffer, offset + 272); LegacyGeometry = new GeometryRecord(); LegacyGeometry.Read(buffer, offset + 276); DiskSize = Utilities.ToInt64LittleEndian(buffer, offset + 296); BlockSize = Utilities.ToInt32LittleEndian(buffer, offset + 304); BlockExtraSize = Utilities.ToInt32LittleEndian(buffer, offset + 308); BlockCount = Utilities.ToInt32LittleEndian(buffer, offset + 312); BlocksAllocated = Utilities.ToInt32LittleEndian(buffer, offset + 316); UniqueId = Utilities.ToGuidLittleEndian(buffer, offset + 320); ModificationId = Utilities.ToGuidLittleEndian(buffer, offset + 336); ParentId = Utilities.ToGuidLittleEndian(buffer, offset + 352); ParentModificationId = Utilities.ToGuidLittleEndian(buffer, offset + 368); if (HeaderSize > 384) { LChsGeometry = new GeometryRecord(); LChsGeometry.Read(buffer, offset + 384); } } else { throw new IOException("Unrecognized file version: " + version); } return (int)HeaderSize; }
/// <summary> /// Creates a blank image of size Width x Height with 1 frame. /// </summary> /// <param name="width">Width of image to create.</param> /// <param name="height">Height of image to create.</param> /// <param name="flags">Describes how this image should be loaded, rendered and stored.</param> /// <returns>A new Image instance.</returns> public static Image CreateImage(int width, int height, ImageFlags flags) { return new Image(width, height, flags); }
public static Image LoadImage(object path, ImageFlags flags) { return LoadImage(path, flags, true); }
/// <summary> /// Initilizes a new image from a file. /// </summary> /// <param name="path">Memory location (or url) of image file to load.</param> public Image(object path, ImageFlags flags) { if ((path is PixelMap) == false) { if (path is string) _url = (string)path; _fullPixelMap = PixelMapFactory.LoadPixelMap(path); } else _fullPixelMap = (path as PixelMap).Copy(); if (_fullPixelMap == null) return; PixelMap map = _fullPixelMap.Copy(); map.Mask(GraphicsManager.ColorKey); _mask = GraphicsManager.ColorKey; _width = _fullPixelMap.Width; _height = _fullPixelMap.Height; _flags = flags; _frames[0] = GraphicsManager.CreateImageFrame(map); // Are we dynamic? If not we don't need the full pixelmaps data so lets destroy it and // free up a bit of memory. if ((_flags & ImageFlags.Dynamic) == 0 && _fullPixelMap != null) { _fullPixelMap.Data = null; _frames[0].PixelMap.Data = null; //GC.Collect(); } }
public int CreateTexture(Texture type, Vector2D <uint> size, ImageFlags imageFlags, ReadOnlySpan <byte> data) { ref var tex = ref TextureManager.AllocTexture();
/// <summary> /// Loads an image with multiple frames of renderable data, each /// frame is of size CellW x CellH, with a horizontal seperation of cellHSeperation /// and a vertical seperation of cellVSeperation. /// </summary> /// <param name="path">Memory location (or url) of image file to load.</param> /// <param name="cellW">Width of each cell in image.</param> /// <param name="cellH">Height of each cell in image.</param> /// <param name="cellHSeperation">Vertical seperation of each cell in image.</param> /// <param name="cellVSeperation">Horizontal seperation of each cell in image.</param> /// <param name="cache">If set to true this image is added to the resource cache to save loading /// time when this image is requested again.</param> /// <param name="flags">Describes how this image should be loaded, rendered and stored.</param> /// <returns>A new image instance containing the image data found at the given url.</returns> public static Image LoadImage(object path, int cellW, int cellH, int cellHSeperation, int cellVSeperation, ImageFlags flags, bool cache) { if (ResourceManager.ResourceIsCached(path.ToString()) == true) { DebugLogger.WriteLog("Loading image " + path.ToString() + " from cache."); Image cacheImage = (Image)ResourceManager.RetrieveResource(path.ToString()); if (cacheImage.Width == cellW && cacheImage.Height == cellH && cacheImage.HorizontalSpacing == cellHSeperation && cacheImage.VerticalSpacing == cellVSeperation) return cacheImage; } DebugLogger.WriteLog("Loading image from " + path.ToString() + "."); Image image = new Image(path, cellW, cellH, cellHSeperation, cellVSeperation, flags); if (cache == true) { if ((flags & ImageFlags.Dynamic) != 0) throw new Exception("Dynamic images cannot be cached."); ResourceManager.CacheResource(path.ToString(), image); } return image; }
public bool HasFlag(ImageFlags flag) { return(_flags.HasFlag(flag)); }
void Init(Context ctx, int w, int h, IntPtr data, ImageFlags flags){ Context = ctx; Width = w; Height = h; ID = nvgCreateImageRGBA(ctx.ctx, w, h, (int)flags, data); }
public static Image LoadImage(object path, int cellW, int cellH, int cellHSeperation, int cellVSeperation, ImageFlags flags) { return LoadImage(path, cellW, cellH, cellHSeperation, cellVSeperation, flags, true); }
/// <summary> /// Copy constructor /// </summary> /// <param name="img"> </param> public Image( Image img ) : base() { this.width = img.width; this.height = img.height; this.depth = img.depth; this.size = img.size; this.numMipMaps = img.numMipMaps; this.flags = img.flags; this.format = img.format; this.buffer = img.buffer; //TODO //m_bAutoDelete }
public static Image LoadImage(object path, int cellW, int cellH, ImageFlags flags) { return LoadImage(path, cellW, cellH, flags, true); }
public void ShowImages(TRibbonCommand command, ImageFlags flags) { ListViewItem item; _images = null; _command = command; _flags = flags; if (_command != null) { if ((ImageFlags.Large & flags) != 0) { if ((ImageFlags.HighContrast & flags) != 0) { _images = _command.LargeHighContrastImages; } else { _images = _command.LargeImages; } } else if ((ImageFlags.HighContrast & flags) != 0) { _images = _command.SmallHighContrastImages; } else { _images = _command.SmallImages; } } listView.BeginUpdate(); try { listView.Items.Clear(); _imageList.Images.Clear(); _actionAddImage.Enabled = (_images != null); _actionRemoveImage.Enabled = false; _actionEditImage.Enabled = false; if (_images == null) { return; } foreach (TRibbonImage image in _images) { item = listView.Items.Add(new ListViewItem()); SetImageItem(item, image); } if (listView.Items.Count > 0) { listView.Items[0].Selected = true; } } finally { listView.EndUpdate(); } }
/// <summary> /// Initilizes a new image with mutliple frame cells spaced evenly out from a file. /// </summary> /// <param name="path">Memory location (or url) of image file to load.</param> /// <param name="cellW">Width of each cell in image.</param> /// <param name="cellH">Height of each cell in image.</param> /// <param name="cellHSeperation">Vertical seperation of each cell in image.</param> /// <param name="cellVSeperation">Horizontal seperation of each cell in image.</param> public Image(object path, int cellW, int cellH, int cellHSeperation, int cellVSeperation, ImageFlags flags) { if ((path is PixelMap) == false) { if (path is string) _url = (string)path; _fullPixelMap = PixelMapFactory.LoadPixelMap(path); } else _fullPixelMap = (path as PixelMap).Copy(); if (_fullPixelMap == null) return; _width = cellW; _height = cellH; _hSpacing = cellHSeperation; _vSpacing = cellVSeperation; _flags = flags; CreateFrames(); // Are we dynamic? If not we don't need the full pixelmaps data so lets destroy it and // free up a bit of memory. if ((_flags & ImageFlags.Dynamic) == 0 && _fullPixelMap != null) { _fullPixelMap.Data = null; for (int i = 0; i < _frames.Length; i++) _frames[i].PixelMap.Data = null; //GC.Collect(); } }
public Image FromDynamicImage( byte[] buffer, int width, int height, int depth, PixelFormat format, bool autoDelete, int numFaces, int numMipMaps ) { this.width = width; this.height = height; this.depth = depth; this.format = format; this.numMipMaps = numMipMaps; this.flags = 0; if ( PixelUtil.IsCompressed( format ) ) this.flags |= ImageFlags.Compressed; if ( depth != 1 ) this.flags |= ImageFlags.Volume; if ( numFaces == 6 ) this.flags |= ImageFlags.CubeMap; if ( numFaces != 6 && numFaces != 1 ) throw new Exception( "Number of faces currently must be 6 or 1." ); this.size = CalculateSize( numMipMaps, numFaces, width, height, depth, format ); SetBuffer( buffer ); return this; }
/// <summary> /// Checks if the specified flag is set on this image. /// </summary> /// <param name="flag">The flag to check for.</param> /// <returns>True if the flag is set, false otherwise.</returns> public bool HasFlag(ImageFlags flag) { return (flags & flag) > 0; }