Пример #1
0
        public void ShowAutocomplete(IEnumerable <AutocompleteSymbol> symbols)
        {
            var ed = App.Editor();

            if (ed != null)
            {
                symbols = symbols.Distinct(Comparer.Instance).OrderBy(s => s.Name);
                var sci = ed.Control as ScintillaControl;

                if (sci != null)
                {
                    if (!scis.ContainsKey(sci))
                    {
                        sci.RegisterAutocompleteImage(1, Pixmap.FromBitmap((Bitmap)Bitmaps.Load <NS>("PixmapVariable")));
                        sci.RegisterAutocompleteImage(2, Pixmap.FromBitmap((Bitmap)Bitmaps.Load <NS>("PixmapModule")));
                        sci.RegisterAutocompleteImage(3, Pixmap.FromBitmap((Bitmap)Bitmaps.Load <NS>("PixmapMember")));
                        sci.RegisterAutocompleteImage(4, Pixmap.FromBitmap((Bitmap)Bitmaps.Load <NS>("PixmapType")));
                        sci.RegisterAutocompleteImage(5, Pixmap.FromBitmap((Bitmap)Bitmaps.Load <NS>("PixmapKeyword")));
                        scis.Add(sci, null);
                    }

                    var words = String.Join(" ", symbols.Select(SymbolToString).ToArray());
                    sci.ShowAutocompleteList(0, words);
                }
            }
        }
Пример #2
0
        private int Mode;      //替换模式 0为替换贴图 1为替换gif 2为替换文件夹

        public void Do(params object[] args)
        {
            Type     = (ColorBits)args[0];
            isAdjust = (bool)args[1];
            Mode     = (int)args[2];
            Path     = args[3] as string;
            Album    = args[4] as Album;
            Indices  = args[5] as int[];
            switch (Mode)
            {
            case 0:
                if (Album.List.Count > 0)
                {
                    var image = Album[Indices[0]];
                    oldImages = new Bitmap[] { image.Picture };
                    types     = new ColorBits[] { image.Type };
                    image.ReplaceImage(Type, isAdjust, Image.FromFile(Path) as Bitmap);
                }
                break;

            case 1:
                var gifentry = Bitmaps.ReadGif(Path);
                oldImages = new Bitmap[Indices.Length];
                types     = new ColorBits[Indices.Length];
                for (int i = 0; i < Indices.Length && i < gifentry.Length; i++)
                {
                    if (Indices[i] > Album.List.Count - 1 && Indices[i] < 0)
                    {
                        continue;
                    }
                    var image = Album[Indices[i]];
                    oldImages[i] = image.Picture;
                    types[i]     = image.Type;
                    image.ReplaceImage(Type, isAdjust, gifentry[i]);
                }
                break;

            case 2:
                var images = GetImages(Album, Indices.Length);
                oldImages = new Bitmap[Indices.Length];
                types     = new ColorBits[Indices.Length];
                for (var i = 0; i < Indices.Length && i < images.Length; i++)
                {
                    if (Indices[i] > Album.List.Count - 1 || Indices[i] < 0)
                    {
                        continue;
                    }
                    var image = Album[Indices[i]];
                    oldImages[i] = image.Picture;
                    types[i]     = image.Type;
                    image.ReplaceImage(Type, isAdjust, images[i]);
                }
                break;

            default:
                break;
            }
            Album.Adjust();
            Album.Refresh();
        }
Пример #3
0
        public TaskManager(IApp app, TaskListService service)
        {
            this.app     = app;
            this.service = service;

            this.sciMap                   = new Dictionary <ScintillaControl, Object>();
            this.nodeMap                  = new Dictionary <CodeDocument, TreeNode>();
            this.treeView                 = new BufferedTreeView();
            this.treeView.Font            = Fonts.Text;
            this.treeView.BorderStyle     = BorderStyle.None;
            this.treeView.ShowLines       = false;
            this.treeView.BeforeExpand   += TreeViewBeforeExpand;
            this.treeView.NodeMouseClick += NodeMouseClick;

            var img = new ImageList();

            img.ColorDepth       = ColorDepth.Depth32Bit;
            img.TransparentColor = Color.Magenta;
            img.ImageSize        = new Size(16, 16);
            img.Images.Add("Folder", Bitmaps.Load <NS>("Folder"));
            img.Images.Add("Task", Bitmaps.Load <NS>("Task"));
            treeView.ImageList = img;

            var srv = app.GetService <IDocumentService>();

            srv.EnumerateDocuments().ForEach(d => AddDocument(d as CodeDocument));
            srv.DocumentAdded   += DocumentAdded;
            srv.DocumentRemoved += DocumentRemoved;
        }
Пример #4
0
        public void SetStatusString(StatusType type, string text, params object[] args)
        {
            var t = WB.Form.ActiveToolbar;

            t.Invoke(() =>
            {
                t.HighlightStatusString = true;
                t.StatusString          = args != null && args.Length > 0 ? String.Format(text, args) : text;
                t.StatusImage           = type == StatusType.Error ? Bitmaps.Load("Error") :
                                          type == StatusType.Warning ? Bitmaps.Load("Warning") :
                                          Bitmaps.Load("Message");

                if (type == StatusType.Error)
                {
                    SystemSounds.Exclamation.Play();
                }

                if (type == StatusType.Warning)
                {
                    SystemSounds.Beep.Play();
                }

                t.Refresh();
            });
        }
Пример #5
0
        public bitmap(CacheBase Cache, int Address)
        {
            EndianReader Reader = Cache.Reader;

            Reader.SeekTo(Address);

            #region Sequence Chunk
            Reader.SeekTo(Address + 60);
            int iCount  = Reader.ReadInt32();
            int iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Sequences.Add(new Sequence(Cache, iOffset + 60 * i));
            }
            #endregion

            #region BitmapData Chunk
            Reader.SeekTo(Address + 68);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Bitmaps.Add(new BitmapData(Cache, iOffset + 116 * i));
            }
            #endregion
        }
Пример #6
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                _compressedColorPlateData.ReadBinary(reader);
                _processedPixelData.ReadBinary(reader);
                for (x = 0; (x < _sequences.Count); x = (x + 1))
                {
                    Sequences.Add(new BitmapGroupSequenceBlock());
                    Sequences[x].Read(reader);
                }
                for (x = 0; (x < _sequences.Count); x = (x + 1))
                {
                    Sequences[x].ReadChildData(reader);
                }
                for (x = 0; (x < _bitmaps.Count); x = (x + 1))
                {
                    Bitmaps.Add(new BitmapDataBlock());
                    Bitmaps[x].Read(reader);
                }
                for (x = 0; (x < _bitmaps.Count); x = (x + 1))
                {
                    Bitmaps[x].ReadChildData(reader);
                }
            }
Пример #7
0
        internal void Initialize(IApp app)
        {
            this.app    = app;
            contextMenu = new ContextMenuStrip();
            contextMenu.Items.Add("Remove Bookmark", null, (o, e) => RemoveBookmark(lastNodeClick));
            MenuRenderer.ApplySkin(contextMenu);

            this.sciMap                   = new Dictionary <ScintillaControl, Object>();
            this.nodeMap                  = new Dictionary <Document, TreeNode>();
            this.treeView                 = new BufferedTreeView();
            this.treeView.Font            = Fonts.Text;
            this.treeView.BorderStyle     = BorderStyle.None;
            this.treeView.ShowLines       = false;
            this.treeView.BeforeExpand   += TreeViewBeforeExpand;
            this.treeView.NodeMouseClick += NodeMouseClick;
            this.treeView.ItemHeight      = Dpi.ScaleY(18);

            var img = new ImageList();

            img.ColorDepth       = ColorDepth.Depth32Bit;
            img.TransparentColor = Color.Magenta;
            img.ImageSize        = new Size(16, 16);
            img.Images.Add("Folder", Bitmaps.Load <NS>("Folder"));
            img.Images.Add("Bookmark", Bitmaps.Load <NS>("Bookmark"));
            treeView.ImageList = img;

            var srv = app.GetService <IDocumentService>();

            srv.EnumerateDocuments().ForEach(d => AddDocument(d as TextDocument));
            srv.DocumentAdded   += DocumentAdded;
            srv.DocumentRemoved += DocumentRemoved;
        }
Пример #8
0
 public OpenFilesControl()
 {
     InitializeComponent();
     treeView.ImageList = imageList;
     treeView.ImageList.Images.Add("Folder", Bitmaps.Load <NS>("Folder"));
     treeView.ImageList.Images.Add("Flag", Bitmaps.Load <NS>("Flag"));
     FlaggedDocuments = new List <String>();
 }
Пример #9
0
        private bool isCombatPicture = false; // images used in combat mode have a slightly different EGA palette (colors 0 and 8 are swapped)
        public EgaBlock(FileBlockParameters parameters)
        {
            setBlockId(parameters.Id);
            var       data          = parameters.Data;
            uint      height        = ArrayToUshort(data, 0);
            uint      width         = ArrayToUshort(data, 2);
            uint      xPos          = ArrayToUshort(data, 4);
            uint      yPos          = ArrayToUshort(data, 6);
            uint      itemCount     = data[8];
            var       widthPx       = width * 8;
            var       heightPx      = height;
            var       xPosPx        = xPos * 8;
            var       yPosPx        = yPos * 8;
            const int egaDataOffset = 17;
            var       egaDataSize   = height * width * 4;

            EgaColors = EgaVgaPalette.EgaColors;

            var filename = Path.GetFileName(parameters.Name).ToUpper();

            if (filename.Contains("CPIC") || filename.Contains("CHEAD") || filename.Contains("CBODY") ||
                filename.Contains("DUNGCOM") || filename.Contains("WILDCOM") || filename.Contains("RANDCOM") ||
                filename.Contains("COMSPR"))
            {
                isCombatPicture = true;
                EgaColors       = EgaVgaPalette.EgaCombatColors;
            }

            if (data.Length == (egaDataSize * (itemCount + 1)) + egaDataOffset)
            {
                // Death Knights of Krynn
                itemCount += 1;
            }

            if (data.Length == (egaDataSize * itemCount) + egaDataOffset)
            {
                var offset = 0;
                for (var i = 0; i < itemCount; i++, offset += (int)egaDataSize)
                {
                    var bitmap = new Bitmap((int)(widthPx + xPosPx), (int)(heightPx + yPosPx),
                                            PixelFormat.Format16bppArgb1555);
                    for (var y = 0; y < heightPx; y++)
                    {
                        for (var x = 0; x < widthPx; x += 2)
                        {
                            var   b     = data[egaDataOffset + (y * width * 4) + (x / 2) + offset];
                            var   pxX   = (int)(x + 0 + xPosPx);
                            var   pxY   = (int)(y + yPosPx);
                            Color ctest = Color.FromArgb((int)EgaColors[b >> 4]);
                            bitmap.SetPixel(pxX, pxY, Color.FromArgb((int)EgaColors[b >> 4]));
                            bitmap.SetPixel(pxX + 1, pxY, Color.FromArgb((int)EgaColors[b & 0xF]));
                        }
                    }

                    Bitmaps.Add(bitmap);
                }
            }
        }
Пример #10
0
        public VgaSpriteBlock(DaxFileBlock block)
        {
            setBlockId(block.Id);
            var data     = block.Data;
            var origData = data;

            int height       = data[0];
            int width        = data[2];
            var widthPx      = width * 8;
            var heightPx     = height;
            int frames       = data[8];
            int clrBase      = data[9];
            int clrCount     = data[10];
            var picSize      = widthPx * heightPx;
            var isSpriteFile = false;

            var clrs      = EgaVgaPalette.ExtractPalette(origData, clrCount, clrBase, 11);
            var dataStart = (clrCount * 3) + 132 + (3 * frames);

            if (block.FileNameUpperCase.StartsWith("SPRIT"))
            {
                clrs[0]      = Color.FromArgb(0);
                clrs[13]     = Color.FromArgb(0, 0, 0);
                isSpriteFile = true;
                if (clrBase == 176 && clrCount == 80)
                {
                    dataStart = 306;
                }
            }

            data = UnpackSpriteData(data, dataStart);
            var frameCount = data.Length / picSize;

            int mframe = origData[(clrCount * 3) + 132 - 5];

            if (isSpriteFile)
            {
                mframe = frameCount - 1;
            }

            for (var frame = 0; frame < frameCount; frame++)
            {
                var bitmap = new Bitmap(widthPx, heightPx, System.Drawing.Imaging.PixelFormat.Format16bppArgb1555);

                for (var y = 0; y < heightPx; y++)
                {
                    for (var x = 0; x < widthPx; x += 1)
                    {
                        var b1 = data[(y * widthPx) + x + (picSize * frame)];
                        var b3 = data[(y * widthPx) + x + (picSize * mframe)];
                        bitmap.SetPixel(x, y, frame != mframe ? clrs[b1 ^ b3] : clrs[b1]);
                    }
                }

                Bitmaps.Add(bitmap);
            }
        }
Пример #11
0
 public IoTHubController(DroneClient client, AnalyzerOutput output, Bitmaps bitmaps)
 {
     this.bitmaps        = bitmaps;
     droneClient         = client;
     this.analyzerOutput = output;
     droneClient.NavigationDataAcquired += DroneClient_NavigationDataAcquired;
     cancelTokenSource = new CancellationTokenSource();
     init(cancelTokenSource.Token);
 }
Пример #12
0
        /// <summary>
        /// Set image for tab
        /// </summary>
        /// <param name="tabPage"></param>
        /// <param name="idx"></param>

        internal void SetTabImage(
            XtraTabPage tabPage,
            string viewTypeImageName)
        {
            Image image = Bitmaps.GetImageFromName(Bitmaps.I.ViewTypeImages, viewTypeImageName, true);

            SetTabImage(tabPage, image);
            return;
        }
Пример #13
0
 internal CodeSampleTreeBuilder(IApp app, SamplesControl control)
 {
     this.app      = app;
     this.control  = control;
     this.treeView = control.TreeView;
     this.treeView.ImageList.Images.Add("Folder", Bitmaps.Load <NS>("Folder"));
     this.treeView.BeforeExpand         += BeforeExpand;
     this.treeView.NodeMouseClick       += NodeMouseClick;
     this.treeView.NodeMouseDoubleClick += NodeMouseDoubleClick;
 }
Пример #14
0
 public SaveLoad()
 {
     if (!File.Exists(_saveToFile))
     {
         _current = new Bitmaps();
         return;
     }
     using (FileStream fs = new FileStream(_saveToFile, FileMode.Open, FileAccess.Read, FileShare.Read))
         _current = (Bitmaps)_xml.Deserialize(fs) ?? new Bitmaps();
 }
Пример #15
0
 internal DocTreeBuilder(IApp app, DocControl control)
 {
     this.app = app;
     this.control = control;
     this.treeView = control.TreeView;
     this.treeView.ImageList.Images.Add("Book", Bitmaps.Load<NS>("Book"));
     this.treeView.ImageList.Images.Add("Article", Bitmaps.Load<NS>("Article"));
     this.treeView.BeforeExpand += BeforeExpand;
     this.treeView.NodeMouseDoubleClick += NodeMouseDoubleClick;
 }
Пример #16
0
        public override Bitmap ConvertToBitmap(Sprite entity)
        {
            var data = entity.Data;
            var type = entity.Type;
            var size = entity.Width * entity.Height * (type == ColorBits.ARGB_8888 ? 4 : 2);

            if (entity.Compress == Compress.ZLIB)
            {
                data = Zlib.Decompress(data, size);
            }
            return(Bitmaps.FromArray(data, entity.Size, type));
        }
Пример #17
0
 internal void Redraw()
 {
     _forceLayout = true;
     if (CellBitmap != null)
     {
         var bit = CellBitmap;
         Bitmaps.Remove(this);
         bit.Dispose();
         mem -= Width * Height * 4;
     }
     Invalidate();
 }
Пример #18
0
 private void WelcomePageView_Load(object sender, EventArgs e)
 {
     BackColor             = Color.White;
     BackgroundImage       = Bitmaps.Load <NS>("WelcomePage");
     BackgroundImageLayout = ImageLayout.None;
     version.Text          = String.Format(version.Text, ElideInfo.Version, ElideInfo.VersionType);
     dontShow.Checked      = !App.Config <WorkbenchConfig>().ShowWelcomePage;
     App.GetService <IConfigService>().ConfigUpdated += (o, ev) =>
     {
         dontShow.Checked = !App.Config <WorkbenchConfig>().ShowWelcomePage;
     };
 }
Пример #19
0
        /// <summary>
        /// Show the AddView context menu
        /// </summary>

        void ShowAddViewContextMenu()
        {
            List <ResultsViewModel> modelViews = ViewManager.GetResultsViewModels();

            ContextMenuStrip menu = AddViewContextMenu;

            menu.Items.Clear();

            foreach (ResultsViewModel view in modelViews)
            {
                if (!view.ShowInViewsMenu)
                {
                    continue;
                }

                if (Lex.StartsWith(view.Name, "Separator"))
                {
                    menu.Items.Add(new ToolStripSeparator());
                    continue;
                }

                ToolStripMenuItem item = new ToolStripMenuItem();

                ResultsViewModel rvm = view.Clone();                 // get a clone that we can modify
                item.Tag = rvm;

                item.Text = view.Title;

                string imageName = view.CustomViewTypeImageName;
                if (!Lex.IsDefined(imageName))
                {
                    imageName = "Spotfire";
                }

                item.Image = Bitmaps.GetImageFromName(Bitmaps.I.ViewTypeImages, imageName);

                rvm.Query = this.BaseQuery;
                rvm.QueryResultsControl = this;

                item.Click += AddViewMenuItem_Click;

                menu.Items.Add(item);
            }

            int   x = Cursor.Position.X;
            int   y = Tabs.PointToScreen(Tabs.Location).Y + 22;           // +Tabs.DisplayRectangle.Top;
            Point p = new Point(x, y);

            AddViewContextMenu.Show(p);

            return;
        }
Пример #20
0
        public List <Album> Decode(string filename)
        {
            var fs    = File.Open(filename, FileMode.Open);
            var array = Bitmaps.ReadGif(fs);

            fs.Close();
            var album = new Album(array);

            album.Path = filename.GetSuffix();
            return(new List <Album> {
                album
            });
        }
 public AnimatedCellBitmapSet(FramerateDelay delay, params CellBitmap[] bitmaps)
 {
     Id                = Interlocked.Increment(ref _idCounter);
     Delay             = delay.Delay;
     Bitmaps           = bitmaps;
     _rotatedCloneLazy = new Lazy <AnimatedCellBitmapSet>(() => new AnimatedCellBitmapSet(
                                                              delay,
                                                              Bitmaps
                                                              .Select(x => BitmapExtensions.Get90DegreesRotatedClone(x.Bitmap))
                                                              .Select(x => new CellBitmap(x)).ToArray()
                                                              ));
     _bitmapEnumerator = Bitmaps.GetInifiniteEnumerator();
     _bitmapEnumerator.MoveNext();
 }
Пример #22
0
        /// <summary>
        /// Clear the palette... remove all removable thumbnails
        /// </summary>
        public void Clear()
        {
            // Just build a new list and swap it out
            Bitmaps.Clear();

            if (myThumbnails.Count > 0)
            {
                SelectItem(myThumbnails[0]);
            }
            else
            {
                mySelectedThumbnail = null;
            }
        }
Пример #23
0
        void SetPixels(int[] pixels)
        {
            var len  = image.Width * image.Height;
            var data = new byte[len * 4];

            for (var i = 0; i < len; i++)
            {
                var pixel = pixels[i];
                data[i * 4 + 0] = (byte)(pixel & 0xff);
                data[i * 4 + 1] = (byte)((pixel >> 8) & 0xff);
                data[i * 4 + 2] = (byte)((pixel >> 16) & 0xff);
                data[i * 4 + 3] = (byte)(pixel >> 24);
            }
            bitmap = Bitmaps.FromArray(data, image.Size);
        }
Пример #24
0
        /// <summary>
        ///     读取一个贴图
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Bitmap ReadImage(Stream stream, Sprite entity)
        {
            var data = new byte[entity.Width * entity.Height * 4];

            for (var i = 0; i < data.Length; i += 4)
            {
                var bits = entity.Type;
                if (entity.Version == ImgVersion.Ver4 && bits == ColorBits.ARGB_1555)
                {
                    bits = ColorBits.ARGB_8888;
                }
                Colors.ReadColor(stream, bits, data, i);
            }
            return(Bitmaps.FromArray(data, entity.Size));
        }
Пример #25
0
        private void InitData(string id)
        {
            Bitmaps.Clear();
            BitmapsIndex = 0;
            string dir   = PathHelper.GetScreenShotDir(id);
            var    files = Directory.GetFiles(dir, "*.jpg");

            if (files.Length > 0)
            {
                for (int i = 0; i < files.Length; i++)
                {
                    Bitmaps.Add(i, new Bitmap(files[i]));
                }
                PicPreview.Image = Bitmaps[0];
            }
        }
Пример #26
0
        public bitmap(CacheBase Cache, int Address)
        {
            EndianReader Reader = Cache.Reader;

            Reader.SeekTo(Address);

            #region Sequence Chunk
            Reader.SeekTo(Address + 84);
            int iCount  = Reader.ReadInt32();
            int iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Sequences.Add(new Sequence(Cache, iOffset + 64 * i));
            }
            #endregion

            #region BitmapData Chunk
            Reader.SeekTo(Address + 96);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Bitmaps.Add(new BitmapData(Cache, iOffset + 48 * i));
            }
            #endregion

            #region Raw Chunk A
            Reader.SeekTo(Address + 140);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                RawChunkAs.Add(new RawChunkA(Cache, iOffset + 8 * i));
            }
            #endregion

            #region Raw Chunk B
            Reader.SeekTo(Address + 152);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                RawChunkBs.Add(new RawChunkB(Cache, iOffset + 8 * i));
            }
            Reader.SeekTo(Address + 164);
            #endregion
        }
Пример #27
0
        public CognitiveController(Bitmaps input, CognitiveData output)
        {
            this.input  = input;
            this.output = output;

            try
            {
                var cogKey = ConfigurationManager.AppSettings["CognitiveKey"];
                Logger.LogInfo($"Cognitive Key: {cogKey}");
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            input.PropertyChanged += Input_PropertyChanged;
        }
Пример #28
0
        /// <summary>
        /// Loads the image at %AppData%\TranscodedWallpaper, stores it in this.TranscodedWallpaper,
        /// and returns the same Image.
        /// Called automatically by constructor.
        /// Do not call if you don't need to update the Image stored in this.TranscodedWallpaper.
        /// </summary>
        public bool Reload()
        {
            this.FreeImages();

            try
            {
                this.TranscodedWallpaper = Bitmaps.FromFile(this.DesktopBackgroundPath);
            }
            catch (IOException e)
            {
                Console.WriteLine(Extender.Exceptions.ExceptionTools.CreateExceptionText(e, true));
                return(false);
            }

            this.ScaledWallpaper = ScaledWallpaper; // forces a re-scale with new TranscodedWallpaper
            return(true);
        }
Пример #29
0
        public bitmap(CacheBase Cache, int Address)
        {
            int          magic = Cache.Magic;
            EndianReader Reader;

            if (Address < 0) //external bitmap
            {
                var fs = new FileStream(Cache.FilePath + "\\bitmaps.map", FileMode.Open, FileAccess.Read);
                Reader = new EndianReader(fs, EndianFormat.LittleEndian);

                Reader.SeekTo(8);
                var indexOffset = Reader.ReadInt32();
                var index       = Address + Cache.Magic;

                Reader.SeekTo(indexOffset + 12 * index + 8);
                Address = Reader.ReadInt32();
                magic   = -Address;
            }
            else
            {
                Reader = Cache.Reader;
            }

            #region BitmapData Chunk
            Reader.SeekTo(Address + 96);
            int iCount  = Reader.ReadInt32();
            int iOffset = Reader.ReadInt32() - magic;
            for (int i = 0; i < iCount; i++)
            {
                Bitmaps.Add(new BitmapData(Reader, iOffset + 48 * i));
            }
            #endregion

            if (Reader != Cache.Reader)
            {
                Reader.Close();
                Reader.Dispose();

                //add flag so the GetRawFromID function
                //can tell that it's an external bitmap
                foreach (var bData in Bitmaps)
                {
                    bData.PixelsOffset |= int.MinValue; //0x80000000
                }
            }
        }
Пример #30
0
        public VgaBlock(DaxFileBlock block)
        {
            setBlockId(block.Id);

            var data = block.Data;

            int       height     = data[0];
            int       width      = data[1];
            const int xPos       = 0;
            const int yPos       = 0;
            var       widthPx    = width * 8;
            var       heightPx   = height;
            const int xPosPx     = xPos * 8;
            const int yPosPx     = yPos * 8;
            int       clrBase    = data[8];
            int       clrCount   = data[9] + 1;
            var       paletteEnd = 10 + (clrCount * 3);
            var       chunkSize  = (widthPx * heightPx);
            var       chunkCount = ArrayToUshort(data, 6);
            var       dataStart  = data.Length - (chunkCount * chunkSize);

            for (var chunk = 0; chunk < chunkCount; chunk++, dataStart += chunkSize)
            {
                var clrs = EgaVgaPalette.ExtractPalette(data, clrCount, clrBase, 10);

                if (clrs == null)
                {
                    return;
                }

                var bitmap = new Bitmap((widthPx + xPosPx), (heightPx + yPosPx), PixelFormat.Format16bppArgb1555);
                for (var y = 0; y < heightPx; y++)
                {
                    for (var x = 0; x < widthPx; x += 1)
                    {
                        var b   = data[dataStart + (y * widthPx) + x];
                        var pxX = (x + 0 + xPosPx);
                        var pxY = (y + yPosPx);
                        bitmap.SetPixel(pxX, pxY, clrs[b]);
                    }
                }

                Bitmaps.Add(bitmap);
            }
        }
Пример #31
0
 public Resources(Assembly target)
 {
     _bitmaps = new Bitmaps(target);
      _icons   = new Icons(target);
      _sounds  = new Sounds(target);
 }