コード例 #1
0
        private void exportTexture(GraphicsViewer gv)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "PNG Image|*.png|JPEG Image|*.jpg|Bitmap Image|*.bmp";
            sfd.Title    = "Save as Image File";
            sfd.FileName = String.Format("{0}.{1:X05}.{2}.png", basename, offset, N64Graphics.CodecString(gv.Codec));
            DialogResult dResult = sfd.ShowDialog();

            if (dResult == DialogResult.OK)
            {
                int      width  = gv.GetPixelWidth();
                int      height = gv.GetPixelHeight();
                Bitmap   bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                Graphics g      = Graphics.FromImage(bitmap);
                N64Graphics.RenderTexture(g, romData, curPalette, offset, width, height, 1, gv.Codec, gv.Mode);
                switch (sfd.FilterIndex)
                {
                case 1: bitmap.Save(sfd.FileName, ImageFormat.Png); break;

                case 2: bitmap.Save(sfd.FileName, ImageFormat.Jpeg); break;

                case 3: bitmap.Save(sfd.FileName, ImageFormat.Bmp); break;
                }
            }
        }
コード例 #2
0
        private void gviewPalette_MouseUp(object sender, MouseEventArgs e)
        {
            GraphicsViewer gv = (GraphicsViewer)sender;

            if (gv == clickedGV)
            {
                switch (e.Button)
                {
                case System.Windows.Forms.MouseButtons.Left:
                    int direction   = 1;
                    int pixelAmount = 0;
                    if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                    {
                        direction = -1;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        pixelAmount = 1;
                    }
                    advancePaletteOffset(gv, direction, pixelAmount);
                    break;

                case System.Windows.Forms.MouseButtons.Right:
                    rightClickGV = gv;
                    break;
                }
            }
            clickedGV = null;
        }
コード例 #3
0
        private void advancePaletteOffset(GraphicsViewer gv, int direction, int advancePixels)
        {
            int offsetSize;

            if (advancePixels == 0)
            {
                offsetSize = N64Graphics.PixelsToBytes(gv.Codec, gv.PixSize.Width * gv.PixSize.Height);
            }
            else
            {
                offsetSize = N64Graphics.PixelsToBytes(gv.Codec, advancePixels);
            }
            int palOffset = (int)numericPalette.Value;
            int change    = direction * offsetSize;

            setPaletteOffset(palOffset + change);
        }
コード例 #4
0
 private void advanceOffset(GraphicsViewer gv, int direction, int advancePixels)
 {
     if (romData != null)
     {
         int offsetSize;
         if (advancePixels == 0)
         {
             offsetSize = N64Graphics.PixelsToBytes(gv.Codec, gv.GetPixelWidth() * gv.GetPixelHeight());
         }
         else
         {
             offsetSize = N64Graphics.PixelsToBytes(gv.Codec, advancePixels);
         }
         int change    = direction * offsetSize;
         int newOffset = Math.Max(0, Math.Min(romData.Length - 1, offset + change));
         numericOffset.Value = newOffset;
     }
 }
コード例 #5
0
        private void graphicsViewer_MouseUp(object sender, MouseEventArgs e)
        {
            GraphicsViewer gv = (GraphicsViewer)sender;

            if (gv == clickedGV)
            {
                switch (e.Button)
                {
                case System.Windows.Forms.MouseButtons.Left:
                    int pixelAmount = (e.X + e.Y * gv.GetPixelWidth()) / gv.PixScale;
                    advanceOffset(gv, 1, pixelAmount);
                    break;

                case System.Windows.Forms.MouseButtons.Right:
                    rightClickGV = gv;
                    break;
                }
            }
            clickedGV = null;
        }
コード例 #6
0
        private void graphicsViewer_MouseMove(object sender, MouseEventArgs e)
        {
            if (romData != null)
            {
                GraphicsViewer gv            = (GraphicsViewer)sender;
                int            pixOffset     = (e.Y / gv.PixScale) * gv.GetPixelWidth() + e.X / gv.PixScale;
                int            byteOffset    = N64Graphics.PixelsToBytes(gv.Codec, pixOffset);
                int            nibblesPerPix = 1;
                int            select        = 0;
                int            selectBits    = 0;
                switch (gv.Codec)
                {
                case N64Codec.RGBA32:
                    nibblesPerPix = 8;
                    pixOffset    *= nibblesPerPix / 2;
                    break;

                case N64Codec.RGBA16:
                case N64Codec.IA16:
                    nibblesPerPix = 4;
                    pixOffset    *= nibblesPerPix / 2;
                    break;

                case N64Codec.IA8:
                case N64Codec.I8:
                case N64Codec.CI8:
                    nibblesPerPix = 2;
                    break;

                case N64Codec.IA4:
                case N64Codec.I4:
                case N64Codec.CI4:
                    selectBits = 4;
                    select     = pixOffset & 0x1;
                    pixOffset /= 2;
                    break;

                case N64Codec.ONEBPP:
                    selectBits = 1;
                    select     = pixOffset & 0x7;
                    pixOffset /= 8;
                    break;
                }

                byte[] colorData;
                if (gv == gviewPalette)
                {
                    colorData = curPalette;
                }
                else
                {
                    byteOffset += offset;
                    colorData   = romData;
                }
                if (byteOffset >= 0 && (byteOffset + nibblesPerPix / 2) <= colorData.Length)
                {
                    Color c     = N64Graphics.MakeColor(colorData, curPalette, byteOffset, select, gv.Codec, gv.Mode);
                    int   value = 0;
                    for (int i = 0; i < (nibblesPerPix + 1) / 2; i++)
                    {
                        value = (value << 8) | colorData[byteOffset + i];
                    }
                    switch (selectBits)
                    {
                    case 4: value = (value >> ((1 - select) * 4)) & 0xf; break;

                    case 1: value = (value >> select) & 0x1; break;
                    }
                    string hexFormat = String.Format("Hex: {{0:X0{0}}}", nibblesPerPix);
                    pictureBoxColor.BackColor = c;
                    labelColorHex.Text        = String.Format(hexFormat, value);
                    labelColorR.Text          = String.Format("R: {0}", c.R);
                    labelColorG.Text          = String.Format("G: {0}", c.G);
                    labelColorB.Text          = String.Format("B: {0}", c.B);
                    labelColorA.Text          = String.Format("A: {0}", c.A);
                }
                else
                {
                    pictureBoxColor.BackColor = Color.Empty;
                    labelColorHex.Text        = "Hex:";
                    labelColorR.Text          = "R:";
                    labelColorG.Text          = "G:";
                    labelColorB.Text          = "B:";
                    labelColorA.Text          = "A:";
                }
            }
        }
コード例 #7
0
 private void graphicsViewer_MouseLeave(object sender, EventArgs e)
 {
     hoverGV = null;
 }
コード例 #8
0
 private void graphicsViewer_MouseEnter(object sender, EventArgs e)
 {
     hoverGV = (GraphicsViewer)sender;
 }
コード例 #9
0
 private void graphicsViewer_MouseDown(object sender, MouseEventArgs e)
 {
     clickedGV = (GraphicsViewer)sender;
 }