Beispiel #1
0
 public void UpdateCatzT2D()
 {
     for (int i = 0; i < this.ct.imageCount; i++)
     {
         this.textures[i] = Tex2Dbmp.GetTexture2DFromBitmap(this.ct.getBMP(i));
     }
 }
Beispiel #2
0
        public void GetDisplayTextures()
        {
            if (this.Bitmaps.Count == 0)
            {
                return;
            }
            if (this.DisplayTextures.Length == 0)
            {
                this.DisplayTextures = new Microsoft.Xna.Framework.Graphics.Texture2D[Bitmaps.Count - Patches.Count];
                this.EmptyPatches    = new Bitmap[Patches.Count];
            }

            for (int i = 0; i < this.EmptyPatches.Length; i++)
            {
                Bitmap img = this.Bitmaps[this.PatchTextureIndexes[i]].Clone(new Rectangle(0, 0, this.Bitmaps[this.PatchTextureIndexes[i]].Width, this.Bitmaps[this.PatchTextureIndexes[i]].Height), this.Bitmaps[this.PatchTextureIndexes[i]].PixelFormat);
                if (this.PatchIndexes[i] > -1)
                {
                    Bitmap   img2   = new Bitmap(img.Width, img.Height);
                    Graphics img2Gr = Graphics.FromImage(img2);

                    img2Gr.DrawImage(this.Patches[i], new Rectangle(this.PatchLocs[i].X, this.PatchLocs[i].Y, this.PatchSizes[i].Width, this.PatchSizes[i].Height),
                                     new Rectangle(0, this.PatchSizes[i].Height * this.PatchIndexes[i], this.PatchSizes[i].Width, this.PatchSizes[i].Height), GraphicsUnit.Pixel);

                    Rectangle rect;
                    if (this.PatchLocs[i].X > 0)
                    {
                        rect = new Rectangle(0, 0, this.PatchLocs[i].X, img.Height);
                        img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                    }
                    if (this.PatchLocs[i].Y > 0)
                    {
                        rect = new Rectangle(0, 0, img.Width, this.PatchLocs[i].Y);
                        img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                    }
                    if (this.PatchLocs[i].X + this.PatchSizes[i].Width < img.Width)
                    {
                        rect = new Rectangle(this.PatchLocs[i].X + this.PatchSizes[i].Width, 0, img.Width - this.PatchLocs[i].X - this.PatchSizes[i].Width, img.Height);
                        img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                    }
                    if (this.PatchLocs[i].Y + this.PatchSizes[i].Height < img.Height)
                    {
                        rect = new Rectangle(0, this.PatchLocs[i].Y + this.PatchSizes[i].Height, img.Width, img.Height - this.PatchLocs[i].Y - this.PatchSizes[i].Height);
                        img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                    }
                    img = img2;
                }

                Graphics grPatch = Graphics.FromImage(img);

                grPatch.FillRectangle(new SolidBrush(Color.FromArgb(150, 0, 0, 0)), new Rectangle(0, 0, img.Width, img.Height - 1));

                grPatch.FillRectangle(new SolidBrush(Color.FromArgb(100, 255, 100, 100)), new Rectangle(this.PatchLocs[i].X, this.PatchLocs[i].Y, this.PatchSizes[i].Width, this.PatchSizes[i].Height - 1));
                grPatch.DrawRectangle(new Pen(Color.Red, 1), new Rectangle(this.PatchLocs[i].X, this.PatchLocs[i].Y, this.PatchSizes[i].Width, this.PatchSizes[i].Height - 1));

                this.EmptyPatches[i] = img;
            }

            for (int i = 0; i < this.DisplayTextures.Length; i++)
            {
                Bitmap img = this.Bitmaps[i].Clone(new Rectangle(0, 0, this.Bitmaps[i].Width, this.Bitmaps[i].Height), this.Bitmaps[i].PixelFormat);
                for (int j = 0; j < this.PatchTextureIndexes.Count; j++)
                {
                    if (this.PatchTextureIndexes[j] == i)
                    {
                        if (this.PatchIndexes[j] < 0)
                        {
                            continue;
                        }

                        Bitmap   img2   = new Bitmap(img.Width, img.Height);
                        Graphics img2Gr = Graphics.FromImage(img2);

                        img2Gr.DrawImage(this.Patches[j], new Rectangle(this.PatchLocs[j].X, this.PatchLocs[j].Y, this.PatchSizes[j].Width, this.PatchSizes[j].Height),
                                         new Rectangle(0, this.PatchSizes[j].Height * this.PatchIndexes[j], this.PatchSizes[j].Width, this.PatchSizes[j].Height), GraphicsUnit.Pixel);
                        Rectangle rect;
                        if (this.PatchLocs[j].X > 0)
                        {
                            rect = new Rectangle(0, 0, this.PatchLocs[j].X, img.Height);
                            img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                        }
                        if (this.PatchLocs[j].Y > 0)
                        {
                            rect = new Rectangle(0, 0, img.Width, this.PatchLocs[j].Y);
                            img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                        }
                        if (this.PatchLocs[j].X + this.PatchSizes[j].Width < img.Width)
                        {
                            rect = new Rectangle(this.PatchLocs[j].X + this.PatchSizes[j].Width, 0, img.Width - this.PatchLocs[j].X - this.PatchSizes[j].Width, img.Height);
                            img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                        }
                        if (this.PatchLocs[j].Y + this.PatchSizes[j].Height < img.Height)
                        {
                            rect = new Rectangle(0, this.PatchLocs[j].Y + this.PatchSizes[j].Height, img.Width, img.Height - this.PatchLocs[j].Y - this.PatchSizes[j].Height);
                            img2Gr.DrawImage(img, rect, rect, GraphicsUnit.Pixel);
                        }
                        img = img2;
                    }
                }
                this.DisplayTextures[i] = Tex2Dbmp.GetTexture2DFromBitmap(img);
                Bitmap   imgHalfOp = new Bitmap(img.Width, img.Height);
                Graphics imgHalfGR = Graphics.FromImage(imgHalfOp);
                System.Drawing.Imaging.ColorMatrix cmxPic = new System.Drawing.Imaging.ColorMatrix();
                cmxPic.Matrix33 = 0.333f;
                System.Drawing.Imaging.ImageAttributes iaPic = new System.Drawing.Imaging.ImageAttributes();
                iaPic.SetColorMatrix(cmxPic, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);

                imgHalfGR.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, iaPic);
            }
        }