示例#1
0
 public static LTexture CreateShadowTexture(LTexture texture, float alpha,
         float scale, float angle)
 {
     int width = texture.Width;
     int height = texture.Height;
     LPixmap image = new LPixmap(texture);
     int centerX = width / 2;
     int centerY = height / 2;
     int offsetX = (int)((width - image.Width) / 2);
     int offsetY = (int)((height - image.Height) / 2);
     Loon.Core.Geom.Matrix.Transform2i t = new Loon.Core.Geom.Matrix.Transform2i();
     t.Rotate(angle, centerX, centerY);
     t.Zoom(scale, centerX, centerY);
     LPixmap shadowProcess = new LPixmap(width, height,
             image.IsAlpha());
     shadowProcess.DrawPixmap(image, offsetX, offsetY);
     shadowProcess.Transparency();
     shadowProcess.Mul(255, 0, 0, 0);
     shadowProcess.Mul((int)(alpha * 255), 255, 255, 255);
     shadowProcess.Convolve(LPixmap.GaussianBlurKernel());
     shadowProcess.Transform(t);
     if (image != null)
     {
         image.Dispose();
         image = null;
     }
     return shadowProcess.Texture;
 }
 /// <summary>
 /// ����һ��RMVX��ʽ���α�
 /// </summary>
 ///
 /// <returns></returns>
 public static LTexture MakeCursor(int w, int h)
 {
     LPixmap cursor = new LPixmap(w, h, true);
     cursor.SetColor(0, 0, 0, 255);
     cursor.FillRect(0, 0, w, h);
     cursor.SetColor(255, 255, 255, 255);
     cursor.FillRect(1, 1, w - 2, h - 2);
     cursor.SetColor(0, 0, 0, 255);
     cursor.FillRect(4, 4, w - 8, h - 8);
     cursor.SetColor(0, 0, 0, 255);
     cursor.FillRect(w / 4, 0, w / 2, h);
     cursor.SetColor(0, 0, 0, 255);
     cursor.FillRect(0, h / 4, w, h / 2);
     Color[] basePixels = cursor.GetData();
     int length = basePixels.Length;
     Color c = Color.Black;
     for (int i = 0; i < length; i++)
     {
         if (c.Equals(basePixels[i]))
         {
             basePixels[i].PackedValue = LSystem.TRANSPARENT;
         }
     }
     cursor.SetData(basePixels);
     return cursor.Texture;
 }
示例#3
0
 public static LTexture.Mask CreateMask(LPixmap image)
 {
     if (image == null) {
         throw new RuntimeException("Image is null !");
     }
     return CreateMask(image.GetPixels(), image.GetWidth(),
             image.GetHeight());
 }
示例#4
0
 public static Polygon MakePolygon(LPixmap image)
 {
     if (image == null) {
         throw new RuntimeException("Image is null !");
     }
     return MakePolygon(image.GetPixels(), image.GetWidth(),
             image.GetHeight());
 }
示例#5
0
 public void Dispose()
 {
     this.isClose = true;
     if (buffer != null)
     {
         buffer.Dispose();
         buffer = null;
     }
 }
示例#6
0
 public static LTexture CreateGradientTexture(int width, int height,
     bool alpha, Color topLeftColor, Color topRightColor,
     Color bottomRightColor, Color bottomLeftColor)
 {
     LPixmap imgProcessor = new LPixmap(width, height,
             alpha);
     imgProcessor.FourCornersGradient(topLeftColor,
             topRightColor, bottomRightColor,
             bottomLeftColor);
     return imgProcessor.Texture;
 }
示例#7
0
        public static LTexture GetRMXPDialog(string fileName, int width,
                int height)
        {
            if (lazyImages == null)
            {
                lazyImages = new Dictionary<string, LTexture>(10);
            }
            LPixmap dialog = new LPixmap(fileName);
            int w = dialog.Width;
            Color[] pixels = dialog.GetData();
            int index = -1;
            int count = 0;
            uint pixel;
            for (int i = 0; i < 5; i++)
            {
                pixel = pixels[(141 + i) + w * 12].PackedValue;

                if (index == -1)
                {
                    index = (int)pixel;
                }
                if (index == pixel)
                {
                    count++;
                }
            }
            if (count == 5)
            {
                return GetRMXPDialog(dialog, width, height, 16, 5);
            }
            else if (count == 1)
            {
                return GetRMXPDialog(dialog, width, height, 27, 5);
            }
            else if (count == 2)
            {
                return GetRMXPDialog(dialog, width, height, 20, 5);
            }
            else
            {
                return GetRMXPDialog(dialog, width, height, 27, 5);
            }
        }
示例#8
0
 public void DrawHeight(GLEx g, int x, int y)
 {
     try
     {
         if (drawTexHeight == null)
         {
             LPixmap img = new LPixmap(width, height, true);
             for (int i = 0; i < height; i++)
             {
                 img.SetColor((byte)(
                         (start.R * (height - i)) / height
                                 + (end.R * i) / height),
                         (byte)((start.G * (height - i)) / height
                                 + (end.G * i) / height),
                         (byte)((start.B * (height - i)) / height
                                 + (end.B * i) / height), (byte)(alpha));
                 img.DrawLine(0, i, width, i);
             }
             drawTexHeight = img.Texture;
         }
         g.DrawTexture(drawTexHeight, x, y);
     }
     catch
     {
         for (int i = 0; i < height; i++)
         {
             g.SetColor(
                     (byte)((start.R * (height - i)) / height
                             + (end.R * i) / height),
                     (byte)((start.G * (height - i)) / height
                             + (end.G * i) / height),
                     (byte)((start.B * (height - i)) / height
                             + (end.B * i) / height), (byte)alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
示例#9
0
 public PShadowEffect(LPixmap img, LPixmap back, int x, int y)
     : this(img, back, x, y, img.Width, img.Height)
 {
 }
示例#10
0
 public PShadowEffect(LPixmap img)
     : this(img, 0, 0)
 {
 }
示例#11
0
        public static LTexture GetRMXPloadBuoyage(LPixmap rmxpImage,
                int width, int height)
        {
            if (lazyImages == null)
            {
                lazyImages = new Dictionary<string, LTexture>(10);
            }
            string keyName = ("buoyage" + width + "|" + height);
            LTexture lazy = (LTexture)CollectionUtils.Get(lazyImages, keyName);
            if (lazy == null)
            {
                LPixmap lazyImage;
                LPixmap image, left, right, center, up, down = null;
                int objWidth = 32;
                int objHeight = 32;
                int x1 = 128;
                int x2 = 160;
                int y1 = 64;
                int y2 = 96;
                int k = 1;

                try
                {
                    image = GraphicsUtils.DrawClipImage(rmxpImage, objWidth,
                            objHeight, x1, y1, x2, y2);
                    lazyImage = new LPixmap(width, height, true);
                    left = GraphicsUtils.DrawClipImage(image, k, height, 0, 0, k,
                            objHeight);
                    right = GraphicsUtils.DrawClipImage(image, k, height, objWidth
                            - k, 0, objWidth, objHeight);
                    center = GraphicsUtils.DrawClipImage(image, width, height, k,
                            k, objWidth - k, objHeight - k);
                    up = GraphicsUtils.DrawClipImage(image, width, k, 0, 0,
                            objWidth, k);
                    down = GraphicsUtils.DrawClipImage(image, width, k, 0,
                            objHeight - k, objWidth, objHeight);
                    lazyImage.DrawPixmap(center, 0, 0);
                    lazyImage.DrawPixmap(left, 0, 0);
                    lazyImage.DrawPixmap(right, width - k, 0);
                    lazyImage.DrawPixmap(up, 0, 0);
                    lazyImage.DrawPixmap(down, 0, height - k);

                    lazy = lazyImage.Texture;

                    if (lazyImage != null)
                    {
                        lazyImage.Dispose();
                        lazyImage = null;
                    }

                    lazyImages.Add(keyName, lazy);
                }
                catch
                {
                    return null;
                }
                finally
                {
                    left = null;
                    right = null;
                    center = null;
                    up = null;
                    down = null;
                    image = null;
                }
            }
            return lazy;
        }
示例#12
0
 private void init(int width, int height, bool alpha)
 {
     this.width = width;
     this.height = height;
     this.hasAlpha = alpha;
     this.buffer = new LPixmap(width, height, alpha);
     this.pixels = buffer.GetData();
     this.finalPixels = (Color[])CollectionUtils.CopyOf(pixels);
 }
示例#13
0
 private LPixmap PackImage()
 {
     CheckPacked();
     if (packing)
     {
         if (temps.IsEmpty())
         {
             throw new Exception("Nothing to Pack !");
         }
         int maxWidth  = 0;
         int maxHeight = 0;
         int totalArea = 0;
         for (int i = 0; i < temps.Size(); i++)
         {
             PackEntry entry  = (PackEntry)temps.Get(i);
             int       width  = entry.image.GetWidth();
             int       height = entry.image.GetHeight();
             if (width > maxWidth)
             {
                 maxWidth = width;
             }
             if (height > maxHeight)
             {
                 maxHeight = height;
             }
             totalArea += width * height;
         }
         Loon.Core.Geom.Point.Point2i size = new Loon.Core.Geom.Point.Point2i(CloseTwoPower(maxWidth),
                                                                              CloseTwoPower(maxHeight));
         bool fitAll = false;
         while (!fitAll)
         {
             int area = size.x * size.y;
             if (area < totalArea)
             {
                 NextSize(size);
                 continue;
             }
             Node root = new Node(size.x, size.y);
             for (int i = 0; i < temps.Size(); i++)
             {
                 PackEntry entry    = (PackEntry)temps.Get(i);
                 Node      inserted = root.Insert(entry);
                 if (inserted == null)
                 {
                     NextSize(size);
                     continue;
                 }
             }
             fitAll = true;
         }
         LPixmap image = new LPixmap(size.x, size.y, useAlpha);
         for (int i = 0; i < temps.Size(); i++)
         {
             PackEntry entry = (PackEntry)temps.Get(i);
             image.DrawPixmap(entry.image, entry.bounds.left, entry.bounds.top);
         }
         packing = false;
         return(image);
     }
     return(null);
 }
示例#14
0
 private LPixmap PackImage()
 {
     CheckPacked();
     if (packing)
     {
         if (temps.IsEmpty())
         {
             throw new Exception("Nothing to Pack !");
         }
         int maxWidth = 0;
         int maxHeight = 0;
         int totalArea = 0;
         for (int i = 0; i < temps.Size(); i++)
         {
             PackEntry entry = (PackEntry)temps.Get(i);
             int width = entry.image.GetWidth();
             int height = entry.image.GetHeight();
             if (width > maxWidth)
             {
                 maxWidth = width;
             }
             if (height > maxHeight)
             {
                 maxHeight = height;
             }
             totalArea += width * height;
         }
         Loon.Core.Geom.Point.Point2i size = new Loon.Core.Geom.Point.Point2i(CloseTwoPower(maxWidth),
                 CloseTwoPower(maxHeight));
         bool fitAll = false;
         while (!fitAll)
         {
             int area = size.x * size.y;
             if (area < totalArea)
             {
                 NextSize(size);
                 continue;
             }
             Node root = new Node(size.x, size.y);
             for (int i = 0; i < temps.Size(); i++)
             {
                 PackEntry entry = (PackEntry)temps.Get(i);
                 Node inserted = root.Insert(entry);
                 if (inserted == null)
                 {
                     NextSize(size);
                     continue;
                 }
             }
             fitAll = true;
         }
         LPixmap image = new LPixmap(size.x, size.y, useAlpha);
         for (int i = 0; i < temps.Size(); i++)
         {
             PackEntry entry = (PackEntry)temps.Get(i);
             image.DrawPixmap(entry.image, entry.bounds.left, entry.bounds.top);
         }
         packing = false;
         return image;
     }
     return null;
 }
示例#15
0
        private static LTexture GetRMXPDialog(LPixmap rmxpImage, int width,
                int height, int size, int offset)
        {
            if (lazyImages == null)
            {
                lazyImages = new Dictionary<string, LTexture>(10);
            }
            string keyName = "dialog" + width + "|" + height;
            LTexture lazy = (LTexture)CollectionUtils.Get(lazyImages, keyName);
            if (lazy == null)
            {
                try
                {
                    int objWidth = 64;
                    int objHeight = 64;
                    int x1 = 128;
                    int x2 = 192;
                    int y1 = 0;
                    int y2 = 64;

                    int center_size = objHeight - size * 2;

                    LPixmap lazyImage = null;

                    LPixmap image = null;

                    LPixmap messageImage = null;

                    image = GraphicsUtils.DrawClipImage(rmxpImage, objWidth,
                            objHeight, x1, y1, x2, y2);

                    LPixmap centerTop = GraphicsUtils.DrawClipImage(image,
                            center_size, size, size, 0);

                    LPixmap centerDown = GraphicsUtils.DrawClipImage(image,
                            center_size, size, size, objHeight - size);

                    LPixmap leftTop = GraphicsUtils.DrawClipImage(image, size, size,
                            0, 0);

                    LPixmap leftCenter = GraphicsUtils.DrawClipImage(image, size,
                            center_size, 0, size);

                    LPixmap leftDown = GraphicsUtils.DrawClipImage(image, size,
                            size, 0, objHeight - size);

                    LPixmap rightTop = GraphicsUtils.DrawClipImage(image, size,
                            size, objWidth - size, 0);

                    LPixmap rightCenter = GraphicsUtils.DrawClipImage(image, size,
                            center_size, objWidth - size, size);

                    LPixmap rightDown = GraphicsUtils.DrawClipImage(image, size,
                            size, objWidth - size, objHeight - size);
                    lazyImage = centerTop;

                    lazyImage = new LPixmap(width, height, true);

                    messageImage = GraphicsUtils.DrawClipImage(rmxpImage, 128, 128,
                            0, 0, 128, 128);

                    messageImage = GraphicsUtils.GetResize(messageImage, width
                            - offset + 1, height - offset + 1);
                    messageImage.UpdateAlpha(125);

                    lazyImage.DrawPixmap(messageImage, (lazyImage.Width - messageImage.Width) / 2, (lazyImage.Height - messageImage
                            .Height) / 2);

                    LPixmap tmp = GraphicsUtils.GetResize(centerTop, width
                            - (size * 2), size);

                    lazyImage.DrawPixmap(tmp, size, 0);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }

                    tmp = GraphicsUtils.GetResize(centerDown, width - (size * 2),
                            size);

                    lazyImage.DrawPixmap(tmp, size, height - size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }

                    lazyImage.DrawPixmap(leftTop, 0, 0);

                    tmp = GraphicsUtils.GetResize(leftCenter,
                            leftCenter.GetWidth(), width - (size * 2));

                    lazyImage.DrawPixmap(tmp, 0, size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }
                    lazyImage.DrawPixmap(leftDown, 0, height - size);

                    int right = width - size;

                    lazyImage.DrawPixmap(rightTop, right, 0);

                    tmp = GraphicsUtils.GetResize(rightCenter, leftCenter
                            .Width, width - (size * 2));

                    lazyImage.DrawPixmap(tmp, right, size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }
                    lazyImage.DrawPixmap(rightDown, right, height - size);

                    lazy = lazyImage.Texture;
                    lazy.isExt = true;

                    lazyImages.Add(keyName, lazy);

                    image.Dispose();
                    messageImage.Dispose();
                    centerTop.Dispose();
                    centerDown.Dispose();
                    leftTop.Dispose();
                    leftCenter.Dispose();
                    leftDown.Dispose();
                    rightTop.Dispose();
                    rightCenter.Dispose();
                    rightDown.Dispose();

                    image = null;
                    messageImage = null;
                    centerTop = null;
                    centerDown = null;
                    leftTop = null;
                    leftCenter = null;
                    leftDown = null;
                    rightTop = null;
                    rightCenter = null;
                    rightDown = null;
                }
                catch
                {

                }
            }
            return lazy;
        }
示例#16
0
文件: TileMap.cs 项目: vb0067/LGame
 public void PutTile(int id, LPixmap img)
 {
     PutTile(id, img, null);
 }
示例#17
0
 private void InitDesktop()
 {
     if (desktop != null && sprites != null)
     {
         return;
     }
     this.desktop = new Desktop(this, GetWidth(), GetHeight());
     this.sprites = new Sprites(GetWidth(), GetHeight());
     if (dialog == null)
     {
         LPixmap g = new LPixmap(GetWidth() - 20,
                 GetHeight() / 2 - 20, true);
         g.SetAlphaValue(0, 0, 0, 125);
         g.FillRect(0, 0, g.GetWidth(), g.GetHeight());
         g.Dispose();
         dialog = g.Texture;
         g = null;
     }
     this.message = new LMessage(dialog, 0, 0);
     this.message.SetFontColor(LColor.white);
     int size = message.GetWidth() / (message.GetMessageFont().GetSize());
     if (LSystem.scaleWidth != 1 || LSystem.scaleHeight != 1)
     {
         if (size % 2 != 0)
         {
             size = size + 2;
         }
         else
         {
             size = size + 3;
         }
     }
     else
     {
         if (size % 2 != 0)
         {
             size = size - 3;
         }
         else
         {
             size = size - 4;
         }
     }
     this.message.SetMessageLength(size);
     this.message.SetLocation((GetWidth() - message.GetWidth()) / 2,
             GetHeight() - message.GetHeight() - 10);
     this.message.SetVisible(false);
     this.select = new LSelect(dialog, 0, 0);
     this.select.SetLocation(message.X(), message.Y());
     this.scrCG = new AVGCG();
     this.desktop.Add(message);
     this.desktop.Add(select);
     this.select.SetVisible(false);
 }
示例#18
0
 /// <summary>
 /// �ж�ָ��������ͼƬ֮���Ƿ��������ײ
 /// </summary>
 ///
 /// <param name="src"></param>
 /// <param name="x1"></param>
 /// <param name="y1"></param>
 /// <param name="dest"></param>
 /// <param name="x2"></param>
 /// <param name="y2"></param>
 /// <returns></returns>
 public bool isPixelCollide(LPixmap src, float x1, float y1, LPixmap dest,
         float x2, float y2)
 {
     float width1 = x1 + src.GetWidth() - 1, height1 = y1 + src.GetHeight()
             - 1, width2 = x2 + dest.GetWidth() - 1, height2 = y2
             + dest.GetHeight() - 1;
     int xstart = (int)Loon.Utils.MathUtils.Max(x1, x2), ystart = (int)Loon.Utils.MathUtils.Max(y1, y2), xend = (int)Loon.Utils.MathUtils.Min(width1, width2), yend = (int)Loon.Utils.MathUtils.Min(height1, height2);
     int toty = Loon.Utils.MathUtils.Abs(yend - ystart);
     int totx = Loon.Utils.MathUtils.Abs(xend - xstart);
     for (int y = 1; y < toty - 1; y++)
     {
         int ny = Loon.Utils.MathUtils.Abs(ystart - (int)y1) + y;
         int ny1 = Loon.Utils.MathUtils.Abs(ystart - (int)y2) + y;
         for (int x = 1; x < totx - 1; x++)
         {
             int nx = Loon.Utils.MathUtils.Abs(xstart - (int)x1) + x;
             int nx1 = Loon.Utils.MathUtils.Abs(xstart - (int)x2) + x;
             try
             {
                 if (((src.GetPixel(nx, ny) != LSystem.TRANSPARENT))
                         && ((dest.GetPixel(nx1, ny1) != LSystem.TRANSPARENT)))
                 {
                     return true;
                 }
             }
             catch (Exception e)
             {
                 Log.Exception(e);
             }
         }
     }
     return false;
 }
示例#19
0
 public void PutTile(int id, LPixmap img)
 {
     PutTile(id, img, null);
 }
示例#20
0
 public void PutTile(int id, LPixmap img, Attribute attribute)
 {
     if (active)
     {
         TileMap.Tile tile = new TileMap.Tile();
         tile.id = id;
         tile.imgId = imgPack.PutImage(img);
         tile.attribute = attribute;
         arrays.Add(tile);
         dirty = true;
     }
     else
     {
         throw new Exception(
                 "Map is no longer active, you can not Add new tiles !");
     }
 }
示例#21
0
        private void Init(LTexture tex2d, float limit, bool remove, float scale)
        {
            this.isVisible    = true;
            this.expandLimit  = limit;
            this.width        = tex2d.GetWidth();
            this.height       = tex2d.GetHeight();
            this.scaleWidth   = (int)(width * scale);
            this.scaleHeight  = (int)(height * scale);
            this.loopMaxCount = (MathUtils.Max(scaleWidth, scaleHeight) / 2) + 1;
            this.fractions    = new float[(scaleWidth * scaleHeight) * maxElements];
            this.exWidth      = (int)(scaleWidth * expandLimit);
            this.exHeigth     = (int)(scaleHeight * expandLimit);
            LPixmap image = tex2d.GetImage().ScaledInstance(scaleWidth, scaleHeight);

            Color[] pixels = image.GetData();
            if (image != null)
            {
                image.Dispose();
                image = null;
            }
            this.size   = pixels.Length;
            this.pixmap = new LPixmapData(exWidth, exHeigth, true);
            int   no = 0, idx = 0;
            int   length = fractions.Length;
            float angle  = 0;
            float speed  = 0;

            System.Random random = LSystem.random;
            for (int y = 0; y < scaleHeight; y++)
            {
                for (int x = 0; x < scaleWidth; x++)
                {
                    if (idx + maxElements < length)
                    {
                        no    = y * scaleWidth + x;
                        angle = random.Next(360);
                        speed = 10f / random.Next(30);
                        fractions[idx + 0] = x;
                        fractions[idx + 1] = y;
                        fractions[idx + 2] = (MathUtils.Cos(angle * MathUtils.PI
                                                            / 180) * speed);
                        fractions[idx + 3] = (MathUtils.Sin(angle * MathUtils.PI
                                                            / 180) * speed);
                        fractions[idx + 4] = (pixels[no].PackedValue == 0xff00 ? 0xffffff
                                                        : pixels[no].PackedValue);
                        fractions[idx + 5] = x / 6 + random.Next(10);
                        idx += maxElements;
                    }
                }
            }
            if (remove)
            {
                if (tex2d != null)
                {
                    tex2d.Destroy();
                    tex2d = null;
                }
            }
            this.tmp = tex2d;
            this.StartUsePixelThread();
        }
示例#22
0
 public int PutImage(LPixmap image)
 {
     return PutImage(
             JavaRuntime.CurrentTimeMillis() + "|" + (count + 1),
             image);
 }
示例#23
0
 public int PutImage(string name, LPixmap image)
 {
     CheckPacked();
     if (image == null)
     {
         throw new Exception();
     }
     if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
     {
         throw new ArgumentException(
                 "width and height must be positive");
     }
     this.temps.Put(name, new PackEntry(image));
     this.packing = true;
     this.count++;
     return temps.Size() - 1;
 }
示例#24
0
 public void DrawWidth(LPixmap g, int x, int y)
 {
     try
     {
         if (drawImgWidth == null)
         {
             drawImgWidth = new LPixmap(width, height, true);
             for (int i = 0; i < width; i++)
             {
                 drawImgWidth.SetColor(
                         (byte)((start.R * (width - i)) / width
                                 + (end.R * i) / width),
                         (byte)((start.G * (width - i)) / width
                                 + (end.G * i) / width),
                         (byte)((start.B * (width - i)) / width
                                 + (end.B * i) / width), (byte)alpha);
                 drawImgWidth.DrawLine(i, 0, i, height);
             }
         }
         g.DrawPixmap(drawImgWidth, x, y);
     }
     catch
     {
         for (int i = 0; i < width; i++)
         {
             g.SetColor(
                     (byte)((start.R * (width - i)) / width
                             + (end.R * i) / width),
                     (byte)((start.G * (width - i)) / width
                             + (end.G * i) / width),
                     (byte)((start.B * (width - i)) / width
                             + (end.B * i) / width), (byte)alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
示例#25
0
 public int PutImage(LPixmap image)
 {
     return(PutImage(
                JavaRuntime.CurrentTimeMillis() + "|" + (count + 1),
                image));
 }
示例#26
0
 public void SetTileBackground(LPixmap image)
 {
     SetTileBackground(image, false);
 }
示例#27
0
 public void DrawHeight(LPixmap g, int x, int y)
 {
     try
     {
         if (drawImgHeight == null)
         {
             drawImgHeight = new LPixmap(width, height, true);
             for (int i = 0; i < height; i++)
             {
                 drawImgHeight.SetColor(
                         (byte)((start.R * (height - i)) / height
                                 + (end.R * i) / height),
                         (byte)((start.G * (height - i)) / height
                                 + (end.G * i) / height),
                         (byte)((start.B * (height - i)) / height
                                 + (end.B * i) / height), (byte)alpha);
                 drawImgHeight.DrawLine(0, i, width, i);
             }
         }
         g.DrawPixmap(drawImgHeight, x, y);
     }
     catch
     {
         for (int i = 0; i < height; i++)
         {
             g.SetColor((byte)(
                     (start.R * (height - i)) / height
                             + (end.R * i) / height),
                    (byte)((start.G * (height - i)) / height
                             + (end.G * i) / height),
                     (byte)((start.B * (height - i)) / height
                             + (end.B * i) / height), (byte)alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
示例#28
0
 public static LTexture FilterLimitColor(string res, LColor start,
         LColor end)
 {
     int sred = start.R;
     int sgreen = start.G;
     int sblue = start.B;
     int ered = end.R;
     int egreen = end.G;
     int eblue = end.B;
     LPixmap tmp = new LPixmap(res);
     LPixmap image = new LPixmap(tmp.Width, tmp.Height, true);
     image.DrawPixmap(tmp, 0, 0);
     if (tmp != null)
     {
         tmp.Dispose();
         tmp = null;
     }
     Color[] pixels = image.GetData();
     int size = pixels.Length;
     for (int i = 0; i < size; i++)
     {
         Color pixel = pixels[i];
         if ((pixel.R >= sred && pixel.G >= sgreen && pixel.B >= sblue)
                 && (pixel.R <= ered && pixel.G <= egreen && pixel.B <= eblue))
         {
             pixels[i].PackedValue = transparent;
         }
     }
     return image.Texture;
 }
示例#29
0
 public LPixmapData(LPixmap pix)
     : this(pix.GetData(), pix.GetWidth(), pix.GetHeight())
 {
 }
示例#30
0
 public void DrawWidth(GLEx g, int x, int y)
 {
     try
     {
         if (drawTexWidth == null)
         {
             LPixmap img = new LPixmap(width, height, true);
             for (int i = 0; i < width; i++)
             {
                 img.SetColor(
                         (byte)((start.R * (width - i)) / width
                                 + (end.R * i) / width),
                         (byte)((start.G * (width - i)) / width
                                 + (end.G * i) / width),
                         (byte)((start.B * (width - i)) / width
                                 + (end.B * i) / width), (byte)alpha);
                 img.DrawLine(i, 0, i, height);
             }
             drawTexWidth = img.Texture;
         }
         g.DrawTexture(drawTexWidth, x, y);
     }
     catch
     {
         for (int i = 0; i < width; i++)
         {
             g.SetColor(
                         (byte)((start.R * (width - i)) / width
                                 + (end.R * i) / width),
                         (byte)((start.G * (width - i)) / width
                                 + (end.G * i) / width),
                         (byte)((start.B * (width - i)) / width
                                 + (end.B * i) / width), (byte)alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
示例#31
0
 public LPixmapData(LPixmap pix)
     : this(pix.GetData(), pix.GetWidth(), pix.GetHeight())
 {
 }
示例#32
0
        private static LTexture GetRMXPDialog(LPixmap rmxpImage, int width,
                                              int height, int size, int offset)
        {
            if (lazyImages == null)
            {
                lazyImages = new Dictionary <string, LTexture>(10);
            }
            string   keyName = "dialog" + width + "|" + height;
            LTexture lazy    = (LTexture)CollectionUtils.Get(lazyImages, keyName);

            if (lazy == null)
            {
                try
                {
                    int objWidth  = 64;
                    int objHeight = 64;
                    int x1        = 128;
                    int x2        = 192;
                    int y1        = 0;
                    int y2        = 64;

                    int center_size = objHeight - size * 2;

                    LPixmap lazyImage = null;

                    LPixmap image = null;

                    LPixmap messageImage = null;

                    image = GraphicsUtils.DrawClipImage(rmxpImage, objWidth,
                                                        objHeight, x1, y1, x2, y2);

                    LPixmap centerTop = GraphicsUtils.DrawClipImage(image,
                                                                    center_size, size, size, 0);

                    LPixmap centerDown = GraphicsUtils.DrawClipImage(image,
                                                                     center_size, size, size, objHeight - size);

                    LPixmap leftTop = GraphicsUtils.DrawClipImage(image, size, size,
                                                                  0, 0);

                    LPixmap leftCenter = GraphicsUtils.DrawClipImage(image, size,
                                                                     center_size, 0, size);

                    LPixmap leftDown = GraphicsUtils.DrawClipImage(image, size,
                                                                   size, 0, objHeight - size);

                    LPixmap rightTop = GraphicsUtils.DrawClipImage(image, size,
                                                                   size, objWidth - size, 0);

                    LPixmap rightCenter = GraphicsUtils.DrawClipImage(image, size,
                                                                      center_size, objWidth - size, size);

                    LPixmap rightDown = GraphicsUtils.DrawClipImage(image, size,
                                                                    size, objWidth - size, objHeight - size);
                    lazyImage = centerTop;

                    lazyImage = new LPixmap(width, height, true);

                    messageImage = GraphicsUtils.DrawClipImage(rmxpImage, 128, 128,
                                                               0, 0, 128, 128);

                    messageImage = GraphicsUtils.GetResize(messageImage, width
                                                           - offset + 1, height - offset + 1);
                    messageImage.UpdateAlpha(125);

                    lazyImage.DrawPixmap(messageImage, (lazyImage.Width - messageImage.Width) / 2, (lazyImage.Height - messageImage
                                                                                                    .Height) / 2);

                    LPixmap tmp = GraphicsUtils.GetResize(centerTop, width
                                                          - (size * 2), size);

                    lazyImage.DrawPixmap(tmp, size, 0);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }

                    tmp = GraphicsUtils.GetResize(centerDown, width - (size * 2),
                                                  size);

                    lazyImage.DrawPixmap(tmp, size, height - size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }

                    lazyImage.DrawPixmap(leftTop, 0, 0);

                    tmp = GraphicsUtils.GetResize(leftCenter,
                                                  leftCenter.GetWidth(), width - (size * 2));

                    lazyImage.DrawPixmap(tmp, 0, size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }
                    lazyImage.DrawPixmap(leftDown, 0, height - size);

                    int right = width - size;

                    lazyImage.DrawPixmap(rightTop, right, 0);

                    tmp = GraphicsUtils.GetResize(rightCenter, leftCenter
                                                  .Width, width - (size * 2));

                    lazyImage.DrawPixmap(tmp, right, size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }
                    lazyImage.DrawPixmap(rightDown, right, height - size);

                    lazy       = lazyImage.Texture;
                    lazy.isExt = true;

                    lazyImages.Add(keyName, lazy);

                    image.Dispose();
                    messageImage.Dispose();
                    centerTop.Dispose();
                    centerDown.Dispose();
                    leftTop.Dispose();
                    leftCenter.Dispose();
                    leftDown.Dispose();
                    rightTop.Dispose();
                    rightCenter.Dispose();
                    rightDown.Dispose();

                    image        = null;
                    messageImage = null;
                    centerTop    = null;
                    centerDown   = null;
                    leftTop      = null;
                    leftCenter   = null;
                    leftDown     = null;
                    rightTop     = null;
                    rightCenter  = null;
                    rightDown    = null;
                }
                catch
                {
                }
            }
            return(lazy);
        }
示例#33
0
 public static LTexture FilterColor(string res, uint[] colors)
 {
     LPixmap tmp = new LPixmap(res);
     LPixmap image = new LPixmap(tmp.Width, tmp.Height, true);
     image.DrawPixmap(tmp, 0, 0);
     if (tmp != null)
     {
         tmp.Dispose();
         tmp = null;
     }
     Color[] pixels = image.GetData();
     int size = pixels.Length;
     for (int i = 0; i < size; i++)
     {
         for (int j = 0; j < colors.Length; j++)
         {
             if (pixels[i].PackedValue == colors[j])
             {
                 pixels[i].PackedValue = transparent;
             }
         }
     }
     image.SetData(pixels);
     return image.Texture;
 }
示例#34
0
        public static LTexture GetRMXPloadBuoyage(LPixmap rmxpImage,
                                                  int width, int height)
        {
            if (lazyImages == null)
            {
                lazyImages = new Dictionary <string, LTexture>(10);
            }
            string   keyName = ("buoyage" + width + "|" + height);
            LTexture lazy    = (LTexture)CollectionUtils.Get(lazyImages, keyName);

            if (lazy == null)
            {
                LPixmap lazyImage;
                LPixmap image, left, right, center, up, down = null;
                int     objWidth  = 32;
                int     objHeight = 32;
                int     x1        = 128;
                int     x2        = 160;
                int     y1        = 64;
                int     y2        = 96;
                int     k         = 1;

                try
                {
                    image = GraphicsUtils.DrawClipImage(rmxpImage, objWidth,
                                                        objHeight, x1, y1, x2, y2);
                    lazyImage = new LPixmap(width, height, true);
                    left      = GraphicsUtils.DrawClipImage(image, k, height, 0, 0, k,
                                                            objHeight);
                    right = GraphicsUtils.DrawClipImage(image, k, height, objWidth
                                                        - k, 0, objWidth, objHeight);
                    center = GraphicsUtils.DrawClipImage(image, width, height, k,
                                                         k, objWidth - k, objHeight - k);
                    up = GraphicsUtils.DrawClipImage(image, width, k, 0, 0,
                                                     objWidth, k);
                    down = GraphicsUtils.DrawClipImage(image, width, k, 0,
                                                       objHeight - k, objWidth, objHeight);
                    lazyImage.DrawPixmap(center, 0, 0);
                    lazyImage.DrawPixmap(left, 0, 0);
                    lazyImage.DrawPixmap(right, width - k, 0);
                    lazyImage.DrawPixmap(up, 0, 0);
                    lazyImage.DrawPixmap(down, 0, height - k);


                    lazy = lazyImage.Texture;

                    if (lazyImage != null)
                    {
                        lazyImage.Dispose();
                        lazyImage = null;
                    }

                    lazyImages.Add(keyName, lazy);
                }
                catch
                {
                    return(null);
                }
                finally
                {
                    left   = null;
                    right  = null;
                    center = null;
                    up     = null;
                    down   = null;
                    image  = null;
                }
            }
            return(lazy);
        }
示例#35
0
        public void SetField2DBackground(Field2D field, Dictionary<object, object> pathMap,
                String fileName)
        {
            SetField2D(field);
            LPixmap background = null;

            if (fileName != null)
            {
                LPixmap tmp = new LPixmap(fileName);
                background = SetTileBackground(tmp, true);
                if (tmp != null)
                {
                    tmp.Dispose();
                    tmp = null;
                }
            }
            else
            {
                background = new LPixmap(GetWidth(), GetHeight(), false);
            }

            for (int i = 0; i < field.GetWidth(); i++)
            {
                for (int j = 0; j < field.GetHeight(); j++)
                {
                    int index = field.GetType(j, i);
                    Object o = CollectionUtils.Get(pathMap, index);
                    if (o != null)
                    {
                        if (o is LPixmap)
                        {
                            background.DrawPixmap(((LPixmap)o), field.TilesToWidthPixels(i),
                                    field.TilesToHeightPixels(j));
                        }
                        else if (o is Actor)
                        {
                            AddObject(((Actor)o), field.TilesToWidthPixels(i),
                                    field.TilesToHeightPixels(j));
                        }
                    }
                }
            }
            SetBackground(background.Texture);
            if (background != null)
            {
                background.Dispose();
                background = null;
            }
        }
示例#36
0
 public void SetTileBackground(LPixmap image)
 {
     SetTileBackground(image, false);
 }
示例#37
0
 public static LTexture CreateTexture(int width, int height, LColor c)
 {
     LPixmap image = new LPixmap(width, height, false);
     image.SetColor(c);
     image.FillRect(0, 0, width, height);
     return image.Texture;
 }
示例#38
0
 public LPixmap SetTileBackground(LPixmap image, bool isReturn)
 {
     if (image == null)
     {
         return null;
     }
     int layerWidth = GetWidth();
     int layerHeight = GetHeight();
     int tileWidth = image.GetWidth();
     int tileHeight = image.GetHeight();
     LPixmap tempImage = new LPixmap(layerWidth, layerHeight, false);
     for (int x = 0; x < layerWidth; x += tileWidth)
     {
         for (int y = 0; y < layerHeight; y += tileHeight)
         {
             tempImage.DrawPixmap(image, x, y);
         }
     }
     if (isReturn)
     {
         return tempImage;
     }
     SetBackground(tempImage.Texture);
     return null;
 }
示例#39
0
 public PShadowEffect(LPixmap img, int x, int y)
     : this(img, null, x, y, img.Width, img.Height)
 {
 }
示例#40
0
 public PackEntry(LPixmap image)
 {
     this.image = image;
     if (image != null)
     {
         this.fileName = image.GetPath();
         this.width = image.GetWidth();
         this.height = image.GetHeight();
     }
 }
示例#41
0
 public PShadowEffect(String fileName, LPixmap back, int x, int y, int w,
                      int h)
     : this(new LPixmap(fileName), back, x, y, w,
            h)
 {
 }
示例#42
0
 public void DrawPixmap(LPixmap pix, float x, float y, Color c)
 {
     if (pix == null)
     {
         return;
     }
     UPos(x, y);
     InBegin(c);
     innterBatch.Draw(pix.Get(), postion, pix.Color);
     InEnd();
 }