Esempio n. 1
0
        private void ToolModeDraw(MouseEventArgs e)
        {
            int incY  = BitmapCpc.modeVirtuel >= 8 ? 8 : 2;
            int yReel = e != null ? (offsetY + (e.Y / zoom)) & -incY : 0;
            int tx    = BitmapCpc.CalcTx(yReel);

            drawColor.BackColor   = Color.FromArgb(bitmapCpc.GetColorPal(drawCol % (BitmapCpc.modeVirtuel == 6 ? 16 : 1 << tx)).GetColorArgb);
            undrawColor.BackColor = Color.FromArgb(bitmapCpc.GetColorPal(undrawCol % (BitmapCpc.modeVirtuel == 6 ? 16 : 1 << tx)).GetColorArgb);
            drawColor.Width       = undrawColor.Width = 35 * Math.Min(tx, 4);
            drawColor.Refresh();
            undrawColor.Refresh();
            if (e == null || e.Button == MouseButtons.None)
            {
                if (doDraw)
                {
                    doDraw = false;
                    undo.EndUndoRedo();
                }
            }
            else
            {
                int pen = e.Button == MouseButtons.Left ? drawCol : undrawCol;
                for (int y = 0; y < penWidth * incY; y += 2)
                {
                    tx = BitmapCpc.CalcTx(yReel);
                    int nbCol     = BitmapCpc.modeVirtuel == 6 ? 16 : 1 << tx;
                    int realColor = GetPalCPC(BitmapCpc.Palette[pen % nbCol]);
                    int yStart    = zoom * (yReel - offsetY);
                    for (int x = 0; x < penWidth * tx; x += tx)
                    {
                        int xReel = (x + offsetX + (e.X / zoom)) & -tx;
                        if (xReel >= 0 && yReel >= 0 && xReel < BitmapCpc.TailleX && yReel < BitmapCpc.TailleY)
                        {
                            undo.MemoUndoRedo(xReel, yReel, BmpLock.GetPixel(xReel, yReel), realColor, doDraw);
                            doDraw = true;
                            BmpLock.SetHorLineDouble(xReel, yReel, tx, realColor);
                            if (zoom != 1)
                            {
                                for (int yz = yStart; yz < Math.Min(tmpLock.Height, yStart + (zoom << 1)); yz += 2)
                                {
                                    if (yz >= 0)
                                    {
                                        tmpLock.SetHorLineDouble(zoom * (xReel - offsetX), yz, zoom * tx, realColor);
                                    }
                                }
                            }
                        }
                    }
                    yReel += 2;
                }
                Render();
            }
        }
Esempio n. 2
0
        public void Render(bool forceDrawZoom = false)
        {
            UpdatePalette();
            modeCaptureSprites.Visible = BitmapCpc.modeVirtuel == 11;
            modeEdition.Visible        = BitmapCpc.modeVirtuel != 11;
            if (chkDoRedo.Checked && modeEdition.Checked)
            {
                Enabled = false;
                List <MemoPoint> lst = undo.lstUndoRedo;
                foreach (MemoPoint p in lst)
                {
                    int Tx = BitmapCpc.CalcTx(p.posy);
                    BmpLock.SetHorLineDouble(p.posx, p.posy, Tx, p.newColor);
                }
                forceDrawZoom  = true;
                bpUndo.Enabled = undo.CanUndo;
                bpRedo.Enabled = undo.CanRedo;
                Enabled        = true;
            }
            if (zoom != 1)
            {
                if (tmpLock == null)
                {
                    tmpLock = new DirectBitmap(imgOrigine.Width, imgOrigine.Height);
                }

                if (forceDrawZoom)
                {
                    for (int y = 0; y < imgOrigine.Height; y += 2)
                    {
                        int ySrc = Math.Min(offsetY + (y / zoom), BitmapCpc.TailleY - 1);
                        for (int x = 0; x < imgOrigine.Width; x += zoom)
                        {
                            tmpLock.SetHorLineDouble(x, y, Math.Min(zoom, imgOrigine.Width - x - 1), BmpLock.GetPixel(offsetX + (x / zoom), ySrc));
                        }
                    }
                }
                pictureBox.Image = tmpLock.Bitmap;
            }
            else
            {
                pictureBox.Image = imgCopy != null ? imgCopy.Bitmap : BmpLock.Bitmap;
                tmpLock          = null;
            }
            pictureBox.Refresh();
            if (fenetreRendu != null)
            {
                fenetreRendu.Picture.Refresh();
            }
        }
Esempio n. 3
0
        private void bpRedo_Click(object sender, System.EventArgs e)
        {
            Enabled = false;
            List <MemoPoint> lst = undo.Redo();

            foreach (MemoPoint p in lst)
            {
                int tx = BitmapCpc.CalcTx(p.posy);
                BmpLock.SetHorLineDouble(p.posx, p.posy, tx, p.newColor);
            }
            if (imgCopy != null)
            {
                imgCopy.CopyBits(BmpLock);
            }

            Render(true);
            bpUndo.Enabled = undo.CanUndo;
            bpRedo.Enabled = undo.CanRedo;
            Enabled        = true;
        }
Esempio n. 4
0
 public void SetPixelCpc(int xPos, int yPos, int col, int tx)
 {
     BmpLock.SetHorLineDouble(xPos, yPos, tx, GetPalCPC(BitmapCpc.modeVirtuel == 5 || BitmapCpc.modeVirtuel == 6 ? colMode5[yPos >> 1, col] : BitmapCpc.Palette[col]));
 }
Esempio n. 5
0
        private void ToolModeCopy(MouseEventArgs e)
        {
            int yReel = ((e.Y / zoom) & 0xFFE) * zoom;
            int tx    = BitmapCpc.CalcTx(yReel);
            int xReel = ((e.X / zoom) & -tx) * zoom;

            if (e.Button == MouseButtons.Left && xReel >= 0 && yReel >= 0)
            {
                if (imgMotif != null)
                {
                    for (int y = 0; y < imgMotif.Height; y += 2)
                    {
                        tx = BitmapCpc.CalcTx(y + yReel);
                        for (int x = 0; x < imgMotif.Width; x += tx)
                        {
                            if (x + xReel < BitmapCpc.NbCol << 3 && y + yReel < BitmapCpc.NbLig << 1)
                            {
                                int c = imgMotif.GetPixel(x, y);
                                undo.MemoUndoRedo(x + xReel, y + yReel, BmpLock.GetPixel(x + xReel, y + yReel), c, doDraw);
                                BmpLock.SetHorLineDouble(x + xReel, y + yReel, tx, c);
                                doDraw = true;
                            }
                        }
                    }
                    imgCopy.CopyBits(BmpLock);
                    Render();
                }
                else
                {
                    if (!setCopyRect)
                    {
                        setCopyRect = true;
                        copyRectx   = xReel;
                        copyRecty   = yReel;
                        copyRecth   = copyRectw = 0;
                    }
                    else
                    {
                        Graphics g = Graphics.FromImage(pictureBox.Image);
                        if (copyRecth != 0 || copyRectw != 0)
                        {
                            XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, copyRectx, copyRecty, copyRectx + copyRectw, copyRecty + copyRecth);
                        }
                        copyRectw = xReel - copyRectx;
                        copyRecth = yReel - copyRecty;
                        XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, copyRectx, copyRecty, copyRectx + copyRectw, copyRecty + copyRecth);
                        pictureBox.Refresh();
                    }
                }
            }
            else
            {
                if (setCopyRect)
                {
                    setCopyRect = false;
                    if (copyRectw != 0 && copyRecth != 0)
                    {
                        Graphics g = Graphics.FromImage(pictureBox.Image);
                        XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, copyRectx, copyRecty, copyRectx + copyRectw, copyRecty + copyRecth);
                        imgMotif = new DirectBitmap(Math.Abs(copyRectw / zoom), Math.Abs(copyRecth / zoom));
                        for (int x = 0; x < imgMotif.Width; x++)
                        {
                            for (int y = 0; y < imgMotif.Height; y++)
                            {
                                imgMotif.SetPixel(x, y, BmpLock.GetPixel(offsetX + x + copyRectx / zoom, offsetY + y + copyRecty / zoom));
                            }
                        }

                        if (zoom != 1)
                        {
                            zoom = 1;
                            DoZoom();
                        }
                        imgCopy          = new DirectBitmap(BmpLock.Width, BmpLock.Height);
                        pictureBox.Image = imgCopy.Bitmap;
                    }
                }
                if (doDraw)
                {
                    doDraw = false;
                    undo.EndUndoRedo();
                }
                DrawCopy(e);
                pictureBox.Refresh();
            }
        }