コード例 #1
0
ファイル: ImageDumper.cs プロジェクト: scemino/nscumm
        void DumpRoomObjectImages(Room room, ObjectData obj, Gdi gdi)
        {
            var text = new ScummText(obj.Name);
            var sb = new StringBuilder();
            sb.Append("Object #" + obj.Number).Append(" ");

            var decoder = new TextDecoder(sb);
            text.Decode(decoder);

            sb.AppendFormat(" size: {0}x{1}", obj.Width, obj.Height);
            Console.WriteLine(sb);

            var j = 0;
            foreach (var img in obj.Images)
            {
//                try
//                {
                var screen = new VirtScreen(0, obj.Width, obj.Height, PixelFormat.Indexed8, 2);
                if (img.IsBomp)
                {
                    var bdd = new BompDrawData();
                    bdd.Src = img.Data;
                    bdd.Dst = new PixelNavigator(screen.Surfaces[0]);
                    bdd.X = 0;
                    bdd.Y = 0;

                    bdd.Width = obj.Width;
                    bdd.Height = obj.Height;

                    bdd.ScaleX = 255;
                    bdd.ScaleY = 255;
                    bdd.DrawBomp();
                }
                else
                {
                    gdi.DrawBitmap(img, screen, new Point(0, 0), obj.Width, obj.Height & 0xFFF8, 0, obj.Width / 8, room.Header.Width, DrawBitmaps.None, true);
                }

                using (var bmp = ToBitmap(room, screen))
                {
                    bmp.Save("obj_" + obj.Number + "_" + (++j) + ".png");
                }
//                }
//                catch (Exception e)
//                {
//                    Console.ForegroundColor = ConsoleColor.Red;
//                    Console.WriteLine(e);
//                    Console.ResetColor();
//                    Console.ReadLine();
//                }
            }
        }
コード例 #2
0
ファイル: ImageDumper.cs プロジェクト: scemino/nscumm
 void DumpRoomObjects(Room room, Gdi gdi)
 {
     foreach (var obj in room.Objects)
     {
         DumpRoomObjectImages(room, obj, gdi);
     }
 }
コード例 #3
0
        public void DrawBitmap(ImageData img, VirtScreen vs, Point p, int width, int height, int stripnr, int numstrip, int roomWidth, DrawBitmaps flags, bool isLightOn)
        {
            var x = p.X;
            var y = p.Y;

            if ((_vm.TownsPaletteFlags & 2) != 0)
            {
                int cx = (x - _vm.ScreenStartStrip) << 3;
                Gdi.Fill(_vm.TextSurface,
                         new Rect(cx * _vm.TextSurfaceMultiplier, y * _vm.TextSurfaceMultiplier,
                                  (cx + width - 1) * _vm.TextSurfaceMultiplier, (y + height - 1) * _vm.TextSurfaceMultiplier), 0);
            }

            _objectMode = flags.HasFlag(DrawBitmaps.ObjectMode);
            PrepareDrawBitmap(img, vs, p, width, height, stripnr, numstrip);

            int sx = x - vs.XStart / 8;

            if (sx < 0)
            {
                numstrip -= -sx;
                x        += -sx;
                stripnr  += -sx;
                sx        = 0;
            }

            // Compute the number of strips we have to iterate over.
            // TODO/FIXME: The computation of its initial value looks very fishy.
            // It was added as a kind of hack to fix some corner cases, but it compares
            // the room width to the virtual screen width; but the former should always
            // be bigger than the latter (except for MM NES, maybe)... strange
            int limit = Math.Max(roomWidth, vs.Width) / 8 - x;

            if (limit > numstrip)
            {
                limit = numstrip;
            }
            if (limit > NumStrips - sx)
            {
                limit = NumStrips - sx;
            }

            for (int k = 0; k < limit; ++k, ++stripnr, ++sx, ++x)
            {
                if (y < vs.TDirty[sx])
                {
                    vs.TDirty[sx] = y;
                }

                if (y + height > vs.BDirty[sx])
                {
                    vs.BDirty[sx] = y + height;
                }

                // In the case of a double buffered virtual screen, we draw to
                // the backbuffer, otherwise to the primary surface memory.
                var surface = vs.HasTwoBuffers ? vs.Surfaces[1] : vs.Surfaces[0];
                var navDst  = new PixelNavigator(surface);
                navDst.GoTo(x * 8, y);

                bool transpStrip;
                using (var smapReader = new BinaryReader(new MemoryStream(img.Data)))
                {
                    transpStrip = DrawStrip(navDst, width, height, stripnr, smapReader);
                }

                // COMI and HE games only uses flag value
                if (game.Version == 8)
                {
                    transpStrip = true;
                }

                if (vs.HasTwoBuffers)
                {
                    var navFrontBuf = new PixelNavigator(vs.Surfaces[0]);
                    navFrontBuf.GoTo(x * 8, y);
                    if (isLightOn)
                    {
                        Copy8Col(navFrontBuf, navDst, height);
                    }
                    else
                    {
                        Clear8Col(navFrontBuf, height);
                    }
                }

                DecodeMask(x, y, width, height, stripnr, img.ZPlanes, transpStrip, flags);
            }
        }
コード例 #4
0
ファイル: ImageDumper.cs プロジェクト: scemino/nscumm
        void DumpRoomImage(Room room, Gdi gdi)
        {
            var name = room.Name ?? "room_" + room.Number;

            var screen = new VirtScreen(0, room.Header.Width, room.Header.Height, PixelFormat.Indexed8, 2);
            var numStrips = room.Header.Width / 8;
            gdi.NumStrips = numStrips;
            gdi.IsZBufferEnabled = false;
            if (room.Header.Height > 0)
            {
                gdi.RoomChanged(room);
                gdi.DrawBitmap(room.Image, screen, new Point(), room.Header.Width, room.Header.Height, 0, numStrips, room.Header.Width, 0, true);

                using (var bmpRoom = ToBitmap(room, screen))
                {
                    bmpRoom.Save(name + ".png");
                }
            }

            DumpZPlanes(room, name);
        }
コード例 #5
0
ファイル: Gdi.cs プロジェクト: scemino/nscumm
 public static Gdi Create(ScummEngine vm, GameInfo game)
 {
     Gdi gdi;
     switch (game.Version)
     {
         case 0:
         case 1:
             gdi = new Gdi1(vm, game);
             break;
         case 2:
             gdi = new Gdi2(vm, game);
             break;
         default:
             gdi = new Gdi(vm, game);
             break;
     }
     return gdi;
 }