Ejemplo n.º 1
0
        public void showPaletteBox(BCLIM.CLIM bclim)
        {
            // Palette Box
            PaletteBox.Visible = BitConverter.ToUInt16(bclim.Data, 0) == 2 && bclim.FileFormat == 7;
            if (!PaletteBox.Visible)
            {
                return;
            }

            int colors = BitConverter.ToUInt16(bclim.Data, 2);

            Color[] ca = new Color[colors];
            for (int i = 0; i < colors; i++)
            {
                ca[i] = BCLIM.DecodeColor(BitConverter.ToUInt16(bclim.Data, 4 + 2 * i), 7);
            }
            Bitmap palette = new Bitmap(ca.Length * 8, 8, PixelFormat.Format32bppArgb);

            for (int x = 0; x < ca.Length * 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    palette.SetPixel(x, y, ca[x / 8]);
                }
            }
            PaletteBox.Image = palette; PaletteBox.Visible = true;
        }
Ejemplo n.º 2
0
        // File Generation
        public void makeBMP(string path)
        {
            BCLIM.CLIM bclim = BCLIM.analyze(path);
            GB_Details.Visible = true;
            L_Details.Text     = String.Format("{1}{0}{2}{0}{3}{0}{4}{0}{5}", Environment.NewLine,
                                               bclim.FileFormat, bclim.Width, bclim.Height, bclim.TileWidth, bclim.TileHeight);

            var img = BCLIM.makeBMP(path, CHK_AutoSavePNG.Checked, !CHK_NoCrop.Checked);

            if (img == null)
            {
                return;
            }
            showPaletteBox(bclim);
            PB_BCLIM.Image = img;
        }
Ejemplo n.º 3
0
        private void changeFile(object sender, EventArgs e)
        {
            // When the file is changed, we need to display the new file.
            string filename = CB_File.Text;
            int    entry    = -1;
            // Find entry in darc
            var darc = darcs[CB_DARC.SelectedIndex];

            for (int i = 0; i < darc.Entries.Length; i++)
            {
                if (darc.FileNameTable[i].FileName == filename)
                {
                    entry = i;
                    break;
                }
            }
            if (entry < 0)
            {
                throw new Exception("File not found!?");
            }

            // Load file
            byte[]     data  = darc.Data.Skip((int)(darc.Entries[entry].DataOffset - darc.Header.FileDataOffset)).Take((int)darc.Entries[entry].DataLength).ToArray();
            BCLIM.CLIM bclim = BCLIM.analyze(data, filename);
            Image      img   = BCLIM.getIMG(bclim);

            Rectangle cropRect = new Rectangle(0, 0, bclim.Width, bclim.Height);
            Bitmap    CropBMP  = new Bitmap(cropRect.Width, cropRect.Height);

            using (Graphics g = Graphics.FromImage(CropBMP))
            {
                g.DrawImage(img,
                            new Rectangle(0, 0, CropBMP.Width, CropBMP.Height),
                            cropRect,
                            GraphicsUnit.Pixel);
            }

            PB_Image.Image = CropBMP;
            // store image locally for saving if need be
            currentBytes = data;

            L_Dimensions.Text = $"Dimensions: {PB_Image.Width}w && {PB_Image.Height}h";
        }