Пример #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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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;
 }
Пример #5
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);
        }
Пример #6
0
        public static LPixmap DrawCropImage(LPixmap image, int x, int y,
                                            int objectWidth, int objectHeight)
        {
            LPixmap buffer = new LPixmap(objectWidth,
                                         objectHeight, true);

            buffer.DrawPixmap(image, 0, 0, objectWidth, objectHeight, x, y, objectWidth, objectHeight);
            return(buffer);
        }
Пример #7
0
        public static LPixmap DrawClipImage(LPixmap image,
                                            int objectWidth, int objectHeight, int x1, int y1, int x2, int y2)
        {
            LPixmap buffer = new LPixmap(objectWidth,
                                         objectHeight, true);

            buffer.DrawPixmap(image, 0, 0, objectWidth, objectHeight, x1, y1,
                              x2 - x1, y2 - y1);
            return(buffer);
        }
Пример #8
0
        public static LPixmap GetResize(LPixmap image, int w, int h)
        {
            if (image == null)
            {
                return(null);
            }
            if (image.Width == w && image.Height == h)
            {
                return(image);
            }
            LPixmap result = new LPixmap(w, h, image.IsAlpha());

            result.DrawPixmap(image, 0, 0, w, h, 0, 0, image.GetWidth(),
                              image.GetHeight());
            return(result);
        }
Пример #9
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);
         }
     }
 }
Пример #10
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);
         }
     }
 }
Пример #11
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);
        }
Пример #12
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);
         }
     }
 }
Пример #13
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;
 }
Пример #14
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;
 }
Пример #15
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);
 }
Пример #16
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);
         }
     }
 }
Пример #17
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;
 }
Пример #18
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;
 }
Пример #19
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);
        }
Пример #20
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;
        }
Пример #21
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;
        }