Example #1
0
 private void init(int width, int height, bool alpha)
 {
     this.width       = width;
     this.height      = height;
     this.hasAlpha    = alpha;
     this.buffer      = LImage.CreateImage(width, height, alpha);
     this.pixels      = buffer.GetPixels();
     this.finalPixels = (Color[])CollectionUtils.CopyOf(pixels);
 }
Example #2
0
        public static LImage DrawCropImage(LImage image, int x, int y,
                                           int objectWidth, int objectHeight)
        {
            LImage buffer = LImage.CreateImage(objectWidth,
                                               objectHeight, true);
            LGraphics g = buffer.GetLGraphics();

            g.DrawImage(image, 0, 0, objectWidth, objectHeight, x, y, objectWidth, objectHeight);
            g.Dispose();
            return(buffer);
        }
Example #3
0
        public static LImage DrawClipImage(LImage image,
                                           int objectWidth, int objectHeight, int x1, int y1, int x2, int y2)
        {
            LImage buffer = LImage.CreateImage(objectWidth,
                                               objectHeight, true);
            LGraphics g = buffer.GetLGraphics();

            g.DrawImage(image, 0, 0, objectWidth, objectHeight, x1, y1,
                        x2 - x1, y2 - y1);
            g.Dispose();
            return(buffer);
        }
Example #4
0
        public static LImage GetResize(LImage image, int w, int h)
        {
            if (image == null)
            {
                return(null);
            }
            if (image.width == w && image.height == h)
            {
                return(image);
            }
            LImage    result = LImage.CreateImage(w, h, image.HasAlpha());
            LGraphics g      = result.GetLGraphics();

            g.DrawImage(image, 0, 0, w, h, 0, 0, image.GetWidth(),
                        image.GetHeight());
            g.Dispose();
            return(result);
        }
Example #5
0
 public void DrawWidth(GLEx g, int x, int y)
 {
     try {
         if (drawTexWidth == null)
         {
             LImage    img = LImage.CreateImage(width, height, true);
             LGraphics gl  = img.GetLGraphics();
             for (int i = 0; i < width; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (width - i)) / width
                     + (end.GetRed() * i) / width,
                     (start.GetGreen() * (width - i)) / width
                     + (end.GetGreen() * i) / width,
                     (start.GetBlue() * (width - i)) / width
                     + (end.GetBlue() * i) / width, alpha);
                 gl.DrawLine(i, 0, i, height);
             }
             drawTexWidth = new LTexture(GLLoader.GetTextureData(img),
                                         Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
             gl.Dispose();
             gl = null;
         }
         g.DrawTexture(drawTexWidth, x, y);
     } catch (Exception) {
         for (int i = 0; i < width; i++)
         {
             g.SetColorValue(
                 (start.GetRed() * (width - i)) / width
                 + (end.GetRed() * i) / width,
                 (start.GetGreen() * (width - i)) / width
                 + (end.GetGreen() * i) / width,
                 (start.GetBlue() * (width - i)) / width
                 + (end.GetBlue() * i) / width, alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
Example #6
0
 public void DrawHeight(GLEx g, int x, int y)
 {
     try {
         if (drawTexHeight == null)
         {
             LImage    img = LImage.CreateImage(width, height, true);
             LGraphics gl  = img.GetLGraphics();
             for (int i = 0; i < height; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (height - i)) / height
                     + (end.GetRed() * i) / height,
                     (start.GetGreen() * (height - i)) / height
                     + (end.GetGreen() * i) / height,
                     (start.GetBlue() * (height - i)) / height
                     + (end.GetBlue() * i) / height, alpha);
                 gl.DrawLine(0, i, width, i);
             }
             drawTexHeight = new LTexture(GLLoader.GetTextureData(img),
                                          Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
             gl.Dispose();
             gl = null;
         }
         g.DrawTexture(drawTexHeight, x, y);
     } catch (Exception) {
         for (int i = 0; i < height; i++)
         {
             g.SetColorValue(
                 (start.GetRed() * (height - i)) / height
                 + (end.GetRed() * i) / height,
                 (start.GetGreen() * (height - i)) / height
                 + (end.GetGreen() * i) / height,
                 (start.GetBlue() * (height - i)) / height
                 + (end.GetBlue() * i) / height, alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
Example #7
0
 public void DrawHeight(LGraphics g, int x, int y)
 {
     try {
         if (drawImgHeight == null)
         {
             drawImgHeight = LImage.CreateImage(width, height, true);
             LGraphics gl = drawImgHeight.GetLGraphics();
             for (int i = 0; i < height; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (height - i)) / height
                     + (end.GetRed() * i) / height,
                     (start.GetGreen() * (height - i)) / height
                     + (end.GetGreen() * i) / height,
                     (start.GetBlue() * (height - i)) / height
                     + (end.GetBlue() * i) / height, alpha);
                 gl.DrawLine(0, i, width, i);
             }
             gl.Dispose();
             gl = null;
         }
         g.DrawImage(drawImgHeight, x, y);
     } catch (Exception) {
         for (int i = 0; i < height; i++)
         {
             g.SetColor(
                 (start.GetRed() * (height - i)) / height
                 + (end.GetRed() * i) / height,
                 (start.GetGreen() * (height - i)) / height
                 + (end.GetGreen() * i) / height,
                 (start.GetBlue() * (height - i)) / height
                 + (end.GetBlue() * i) / height, alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
Example #8
0
 public void DrawWidth(LGraphics g, int x, int y)
 {
     try {
         if (drawImgWidth == null)
         {
             drawImgWidth = LImage.CreateImage(width, height, true);
             LGraphics gl = drawImgWidth.GetLGraphics();
             for (int i = 0; i < width; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (width - i)) / width
                     + (end.GetRed() * i) / width,
                     (start.GetGreen() * (width - i)) / width
                     + (end.GetGreen() * i) / width,
                     (start.GetBlue() * (width - i)) / width
                     + (end.GetBlue() * i) / width, alpha);
                 gl.DrawLine(i, 0, i, height);
             }
             gl.Dispose();
             gl = null;
         }
         g.DrawImage(drawImgWidth, x, y);
     } catch (Exception) {
         for (int i = 0; i < width; i++)
         {
             g.SetColor(
                 (start.GetRed() * (width - i)) / width
                 + (end.GetRed() * i) / width,
                 (start.GetGreen() * (width - i)) / width
                 + (end.GetGreen() * i) / width,
                 (start.GetBlue() * (width - i)) / width
                 + (end.GetBlue() * i) / width, alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
Example #9
0
 public LPixmapData(string resName)
     : this(LImage.CreateImage(resName))
 {
 }