Esempio n. 1
0
        public void SauvePng(string fileName, Param param)
        {
            if (BitmapCpc.modeVirtuel == 6)
            {
                string       singleName = Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName);
                DirectBitmap bmpRaster  = new DirectBitmap(BmpLock.Bitmap.Width >> 1, BmpLock.Bitmap.Height >> 1);
                //DirectBitmap bmp4Cols = new DirectBitmap(BmpLock.Bitmap.Width >> 1, BmpLock.Bitmap.Height >> 1);
                RvbColor c2   = new RvbColor(0);
                int      posx = 0;
                for (int y = 0; y < bmpRaster.Height; y++)
                {
                    bool memoC = false;
                    for (int x = 0; x < bmpRaster.Width; x++)
                    {
                        RvbColor c = BmpLock.GetPixelColor(x << 1, y << 1);
                        for (int i = 0; i < 16; i++)
                        {
                            RvbColor p = BitmapCpc.RgbCPC[colMode5[y, i]];
                            if (p.r == c.r && p.v == c.v && p.b == c.b)
                            {
                                if (i > 2)
                                {
                                    //c = BitmapCpc.RgbCPC[colMode5[y, 3]];
                                    c2 = p;
                                    int start = memoC ? x & 0xFF8 : 0;
                                    memoC = true;
                                    for (int r = start; r < x; r++)
                                    {
                                        bmpRaster.SetPixel(r, y, c2);
                                    }

                                    //									posx = 0;
                                }
                                break;
                            }
                        }
                        //bmp4Cols.SetPixel(x, y, c);
                        bmpRaster.SetPixel(x, y, c2);
                        posx++;
                    }
                }
                bmpRaster.Bitmap.Save(singleName + "_Rasters" + ".png", System.Drawing.Imaging.ImageFormat.Png);
                bitmapCpc.CreeBmpCpcForceMode1(BmpLock);
                SauveImage.SauveScr(singleName + ".scr", bitmapCpc, this, param, false);
            }
            else
            {
                BmpLock.Bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
            }

            main.SetInfo("Sauvegarde image PNG ok.");
        }
Esempio n. 2
0
        private byte[] MakeSprite()
        {
            byte[] ret = new byte[(BitmapCpc.TailleX * BitmapCpc.TailleY) >> 4];
            Array.Clear(ret, 0, ret.Length);
            for (int y = 0; y < BitmapCpc.TailleY; y += 2)
            {
                int tx = BitmapCpc.CalcTx(y);
                for (int x = 0; x < BitmapCpc.TailleX; x += 8)
                {
                    byte pen = 0, octet = 0;
                    for (int p = 0; p < 8; p++)
                    {
                        if ((p % tx) == 0)
                        {
                            RvbColor col = BmpLock.GetPixelColor(x + p, y);
                            if (BitmapCpc.cpcPlus)
                            {
                                for (pen = 0; pen < 16; pen++)
                                {
                                    if ((col.v >> 4) == (BitmapCpc.Palette[pen] >> 8) && (col.r >> 4) == ((BitmapCpc.Palette[pen] >> 4) & 0x0F) && (col.b >> 4) == (BitmapCpc.Palette[pen] & 0x0F))
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                for (pen = 0; pen < 16; pen++)
                                {
                                    RvbColor fixedCol = BitmapCpc.RgbCPC[BitmapCpc.Palette[pen]];
                                    if (fixedCol.r == col.r && fixedCol.b == col.b && fixedCol.v == col.v)
                                    {
                                        break;
                                    }
                                }
                            }
                            if (pen > 15)
                            {
                                pen = 0;                                 // Pb peut survenir si la palette n'est pas la même pour chaque image d'une animation...
                            }

                            octet |= (byte)(tabOctetMode[pen % 16] >> (p / tx));
                        }
                    }
                    ret[(x >> 3) + (y >> 1) * (BitmapCpc.TailleX >> 3)] = octet;
                }
            }
            return(ret);
        }
Esempio n. 3
0
        public byte[] GetCpcScr(Param param, bool spriteMode = false)
        {
            int maxSize = (BitmapCpc.TailleX >> 3) + ((BitmapCpc.TailleY - 2) >> 4) * (BitmapCpc.TailleX >> 3) + ((BitmapCpc.TailleY - 2) & 14) * 0x400;

            if (spriteMode)
            {
                maxSize = (BitmapCpc.TailleX * BitmapCpc.TailleY) >> 4;
            }
            else
            if (maxSize >= 0x4000)
            {
                maxSize += 0x3800;
            }

            byte[] ret = new byte[maxSize];
            Array.Clear(ret, 0, ret.Length);
            int posRet = 0;

            for (int y = 0; y < BitmapCpc.TailleY; y += 2)
            {
                int adrCPC = BitmapCpc.GetAdrCpc(y);
                int tx     = BitmapCpc.CalcTx(y);
                for (int x = 0; x < BitmapCpc.TailleX; x += 8)
                {
                    byte pen = 0, octet = 0;
                    for (int p = 0; p < 8; p++)
                    {
                        if ((p % tx) == 0)
                        {
                            RvbColor col = BmpLock.GetPixelColor(x + p, y);
                            if (BitmapCpc.cpcPlus)
                            {
                                for (pen = 0; pen < 16; pen++)
                                {
                                    if ((col.v >> 4) == (BitmapCpc.Palette[pen] >> 8) && (col.r >> 4) == ((BitmapCpc.Palette[pen] >> 4) & 0x0F) && (col.b >> 4) == (BitmapCpc.Palette[pen] & 0x0F))
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                for (pen = 0; pen < 16; pen++)
                                {
                                    RvbColor fixedCol = BitmapCpc.RgbCPC[BitmapCpc.Palette[pen]];
                                    if (fixedCol.r == col.r && fixedCol.b == col.b && fixedCol.v == col.v)
                                    {
                                        break;
                                    }
                                }
                            }
                            octet |= (byte)(tabOctetMode[pen] >> (p / tx));
                        }
                    }
                    if (!spriteMode)
                    {
                        posRet = BitmapCpc.GetAdrCpc(y) + (x >> 3);
                    }

                    ret[posRet++] = octet;
                }
            }
            return(ret);
        }