/// <summary> /// Create a map from a Texture /// </summary> public void CreateMap(MapDepth depth, Bitmap tex) { // If the Texture is null, abort if (tex == null) { throw new ArgumentNullException(nameof(tex)); } // Set _data _data = tex; // Variables _width = tex.Width; _height = tex.Height; Depth = depth; _rowWidth = _width * _bpp; // We're compiled _isCompiled = true; }
// Create a map from a Texture2D public override void CreateMap(MapDepth depth, Texture2D tex) { // If the Texture is null, abort if (tex == null) { Debug.Log("[OD] ERROR: Failed to load map"); return; } // Set _data _data = tex; // Variables _width = tex.width; _height = tex.height; Depth = depth; _rowWidth = _width * _bpp; // We're compiled _isCompiled = true; }
// Create a map from a Texture2D public override void CreateMap(MapDepth depth, Texture2D tex) { // If the Texture is null, abort if (tex == null) { Debug.Log("[OD] ERROR: Failed to load map"); return; } // Set _data _data = tex; // Variables name = tex.name; _width = tex.width; _height = tex.height; Depth = depth; _rowWidth = _width * _bpp; // We're compiled _isCompiled = true; }
/// <summary> /// Create a map from a Texture2D /// </summary> public override void CreateMap(MapDepth depth, Texture2D tex) { // If the Texture is null, abort if (tex == null) { Debug.Log("[OD] ERROR: Failed to load map"); return; } if (OnDemandStorage.UseManualMemoryManagement) { _name = tex.name; _width = tex.width; _height = tex.height; _bpp = (Int32)depth; _rowWidth = _width * _bpp; switch (depth) { case MapDepth.Greyscale: { if (tex.format != TextureFormat.Alpha8) { CreateGreyscaleFromRgb(tex); } else { CreateGreyscaleFromAlpha(tex); } break; } case MapDepth.HeightAlpha: { CreateHeightAlpha(tex); break; } case MapDepth.RGB: { CreateRgb(tex); break; } case MapDepth.RGBA: { CreateRgba(tex); break; } default: throw new ArgumentOutOfRangeException(nameof(depth), depth, null); } _isCompiled = true; // Clean up what we don't need anymore DestroyImmediate(tex); } else { // Set _data Data = tex; // Variables _width = tex.width; _height = tex.height; Depth = depth; _bpp = 4; _rowWidth = _width * _bpp; // We're compiled _isCompiled = true; } }
public void CreateMap(MapDepth depth, string path) { string fullPath = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("GameData", path)); byte[] bytes = File.ReadAllBytes(fullPath); TGAHeader tex = new TGAHeader(bytes); this._name = Path.GetFileNameWithoutExtension(fullPath); ; this._width = tex.width; this._height = tex.height; this._bpp = (int)depth; this._rowWidth = this._width * this._bpp; switch (depth) { case MapDepth.Greyscale: GreyscaleFromRGB(tex, bytes); break; case MapDepth.HeightAlpha: HeightAlpha(tex, bytes); break; case MapDepth.RGB: RGB(tex, bytes); break; case MapDepth.RGBA: RGBA(tex, bytes); break; } this._isCompiled = true; }