示例#1
0
    public static void Main(string[] args)
    {
        string filename    = args[0];
        string palettename = args[1];

        Console.WriteLine("grp file {0}", filename);
        Console.WriteLine("palette file {0}", palettename);

        FileStream fs = File.OpenRead(filename);

        Grp grp = new Grp();

        ((MpqResource)grp).ReadFromStream(fs);
        Pcx pal = new Pcx();

        pal.ReadFromStream(File.OpenRead(palettename), -1, -1);

        for (int i = 0; i < grp.FrameCount; i++)
        {
            BMP.WriteBMP(String.Format("output{0:0000}.bmp", i),
                         grp.GetFrame(i),
                         grp.Width, grp.Height,
                         pal.Palette);
        }
    }
示例#2
0
    public static void Main(string[] args)
    {
        MpqContainer mpq = new MpqContainer();

        mpq.Add(new MpqArchive("/home/toshok/src/starcraft/sc-cd/install.exe"));
        mpq.Add(new MpqArchive("/home/toshok/src/starcraft/starcraft/StarDat.mpq"));

        Fnt fnt = (Fnt)mpq.GetResource("files\\font\\font16.fnt");

        Console.WriteLine("loading font palette");
        Stream palStream = (Stream)mpq.GetResource("glue\\Palmm\\tFont.pcx");
        Pcx    pcx1      = new Pcx();

        pcx1.ReadFromStream(palStream, -1, -1);

        Painter.InitializePainter(false, 300);

        Surface textSurf1 = GuiUtil.ComposeText(str1, fnt, pcx1.Palette);
        Surface textSurf2 = GuiUtil.ComposeText(str2, fnt, pcx1.Palette);
        Surface textSurf3 = GuiUtil.ComposeText(str3, fnt, pcx1.Palette);
        Surface textSurf4 = GuiUtil.ComposeText(str4, fnt, pcx1.Palette);

        Surface backgroundSurface = new Surface(Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

        backgroundSurface.Fill(new Rectangle(new Point(0, 0), backgroundSurface.Size), Color.Red);

        Painter.Add(Layer.UI,
                    delegate(DateTime now) {
            int y = 0;
            Painter.Blit(textSurf1, new Point(0, y)); y += textSurf1.Height;
            Painter.Blit(textSurf2, new Point(0, y)); y += textSurf2.Height;
            Painter.Blit(textSurf3, new Point(0, y)); y += textSurf3.Height;
            Painter.Blit(textSurf4, new Point(0, y)); y += textSurf4.Height;
        });

        Painter.Add(Layer.Background,
                    delegate(DateTime now) {
            Painter.Blit(backgroundSurface);
        });

        Events.KeyboardUp += delegate(object o, KeyboardEventArgs keyargs) {
            if (keyargs.Key == Key.Escape)
            {
                Events.QuitApplication();
            }
        };

        Events.Run();
    }
示例#3
0
 public LevelSelect()
 {
     songid = MidiConsts.MIDI_FANTASIA;
     pcx    = new Pcx(Dat.Uif[ImageConsts.MENU_CHOOSEEPISODE]);
 }
示例#4
0
        public void GetDate(FileInfo f)
        {
            int imageWidth;
            int imageHeigth;
            int resolution;

            string imageDepth;
            string compressionType;
            Bitmap bitmap;

            Int16 bitConv = -1;

            if (f.Extension != ".pcx")
            {
                bitmap      = new Bitmap(f.FullName);
                imageWidth  = bitmap.Width;
                imageHeigth = bitmap.Height;
                resolution  = Convert.ToInt32(bitmap.HorizontalResolution);
                imageDepth  = bitmap.PixelFormat.ToString();

                int compressionTagIndex = Array.IndexOf(bitmap.PropertyIdList, 0x103);
                if (compressionTagIndex >= 0)
                {
                    PropertyItem compressionTag = bitmap.PropertyItems[compressionTagIndex];
                    bitConv = BitConverter.ToInt16(compressionTag.Value, 0);
                    if (bitConv < 0)
                    {
                        bitConv += Int16.MaxValue - 1;
                    }
                }
                bitmap.Dispose();

                if (bitConv == 2)
                {
                    compressionType = "Rle";
                }
                else if (bitConv == 3)
                {
                    compressionType = "Fax 3";
                }
                else if (bitConv == 4)
                {
                    compressionType = "Fax 4";
                }
                else if (bitConv == 5)
                {
                    compressionType = "Lzw";
                }
                else
                {
                    compressionType = "Undefined";
                }
            }
            else
            {
                var dataPcx = Pcx.FromFile(f.FullName);
                imageWidth      = dataPcx.Hdr.ImgXMax;
                imageHeigth     = dataPcx.Hdr.ImgYMax;
                resolution      = dataPcx.Hdr.Hdpi;
                imageDepth      = dataPcx.Hdr.BitsPerPixel.ToString();
                compressionType = dataPcx.Hdr.Encoding.ToString();
            }

            if (f.Extension == ".png")
            {
                compressionType = "Deflate";
            }

            if (f.Extension == ".gif")
            {
                compressionType = "Lzw";
            }

            if (f.Extension == ".jpg")
            {
                compressionType = "Jpeg";
            }

            ImageInfo imageInfo = new ImageInfo();

            imageInfo.name        = f.Name;
            imageInfo.width       = imageWidth;
            imageInfo.heigth      = imageHeigth;
            imageInfo.depth       = imageDepth;
            imageInfo.resolution  = resolution;
            imageInfo.compression = compressionType;

            images.Add(imageInfo);
        }