public Image Process(byte[] buffer, out IImageFormat mime)
        {
            var pcx = new PCX(buffer);

            var image = new Image <Rgb24>(pcx.Width, pcx.Height);

            image.ComposeBitmap(pcx.Bitmap, pcx.Colors.ToColorArray().ToImageSharpColors());

            mime = new PcxFormat();

            return(image);
        }
Beispiel #2
0
        public Bitmap LoadNearTileTexture(string tileName)
        {
            Bitmap toReturn;
            var    tileFullPath = Path.Combine(_terrainDB.CurrentTheaterTextureBaseFolderPath, tileName);

            var tileInfo = new FileInfo(tileFullPath);

            if (string.Equals(tileInfo.Extension, ".PCX", StringComparison.InvariantCultureIgnoreCase))
            {
                var textureSubfolder = !string.IsNullOrWhiteSpace(_terrainDB.TileSet) ? "TEXTURE_" + _terrainDB.TileSet: "TEXTURE";
                tileFullPath = Path.Combine(Path.Combine(_terrainDB.CurrentTheaterTextureBaseFolderPath, textureSubfolder), Path.GetFileNameWithoutExtension(tileInfo.Name) + ".DDS");
                tileInfo     = new FileInfo(tileFullPath);
            }
            if (tileInfo.Exists)
            {
                try
                {
                    toReturn = DDS.Load(tileFullPath);
                    return(toReturn);
                }
                catch (Exception e)
                {
                    Log.Debug(e.Message, e);
                }
            }

            if (!_terrainDB.TextureDotZipFileEntries.ContainsKey(tileName.ToLowerInvariant()))
            {
                return(null);
            }
            var thisEntry = _terrainDB.TextureDotZipFileEntries[tileName.ToLowerInvariant()];

            using (var zipStream = _terrainDB.TextureZipFile.GetInputStream(thisEntry))
            {
                var rawBytes = new byte[zipStream.Length];
                zipStream.Read(rawBytes, 0, rawBytes.Length);
                toReturn = PCX.LoadFromBytes(rawBytes);
            }
            return(toReturn);
        }
 public PAL Process(byte[] buffer)
 {
     byte[] components = PCX.ExtractPalette(new BinaryReader(new MemoryStream(buffer)));
     return(new PAL(components.ToColorArray().ToDAC()));
 }