Esempio n. 1
0
        public void TestRead()
        {
            pcx.Read(TestUtils.GetResourceStream("carpet.pcx"));
            Assert.AreEqual(16, pcx.Width);
            Assert.AreEqual(16, pcx.Height);
            Assert.AreEqual(72, pcx.Hdpi);
            Assert.AreEqual(72, pcx.Vdpi);
            Assert.AreEqual(256, pcx.Data.Length);

            byte[]  increasing = new byte[256];
            Color[] palette    = new Color[256];

            for (int i = 0; i < 256; ++i)
            {
                increasing[i] = (byte)i;
                palette[i]    = new Color(255, i, i, i);
            }

            Assert.AreEqual(increasing, pcx.Data);
            Assert.AreEqual(palette, pcx.Palette);
        }
Esempio n. 2
0
        public Bitmap LoadPCX(Stream fs, out System.Drawing.Color[] palette)
        {
            PCXImage img = new PCXImage();

            img.Read(fs);

            Bitmap     res     = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);
            BitmapData bmpData =
                res.LockBits(new Rectangle(0, 0, img.Width, img.Height),
                             System.Drawing.Imaging.ImageLockMode.ReadWrite,
                             res.PixelFormat);
            IntPtr ptr    = bmpData.Scan0;
            int    stride = img.Width * 3;

            byte[] rgbData = img.GetRGBData();
            for (int y = 0; y < res.Height; ++y)
            {
                System.Runtime.InteropServices.Marshal.Copy(rgbData, y * stride, ptr + y * bmpData.Stride, stride);
            }
            res.UnlockBits(bmpData);

            palette = Utils.LDPaletteToGDIPalette(img.Palette);
            return(res);
        }
Esempio n. 3
0
 /// <summary>
 /// Loads water map
 /// </summary>
 /// <returns></returns>
 internal byte[,] LoadWaterMap()
 {
     return(PCXImage.Read(OpenDatFile("water.pcx")));
 }
Esempio n. 4
0
 /// <summary>
 /// Loads the offset map
 /// </summary>
 /// <returns></returns>
 internal byte[,] LoadOffsetMap()
 {
     return(PCXImage.Read(OpenDatFile("offset.pcx")));
 }
Esempio n. 5
0
 /// <summary>
 /// Loads the terrain map
 /// </summary>
 /// <returns></returns>
 internal byte[,] LoadTerrainMap()
 {
     return(PCXImage.Read(OpenDatFile("terrain.pcx")));
 }