Пример #1
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);
        }
Пример #2
0
        /// <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 void Submit()
 {
     if (!isDirty)
     {
         if (buffer == null)
         {
             return;
         }
         lock (buffer)
         {
             buffer.SetData(pixels);
         }
         isDirty = true;
     }
 }
Пример #4
0
 public LTexture Pack()
 {
     if (texture != null && !packing)
     {
         return(texture);
     }
     if (fileName != null)
     {
         texture = new LTexture(fileName);
     }
     else
     {
         LPixmap image = PackImage();
         if (image == null)
         {
             return(null);
         }
         if (texture != null)
         {
             texture.Destroy();
             texture = null;
         }
         if (colorMask != null)
         {
             Color[] pixels = image.GetData();
             int     size   = pixels.Length;
             uint    color  = colorMask.PackedValue;
             for (int i = 0; i < size; i++)
             {
                 if (pixels[i].PackedValue == color)
                 {
                     pixels[i].PackedValue = LSystem.TRANSPARENT;
                 }
             }
             image.SetData(pixels);
         }
         texture = image.Texture;
     }
     return(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
 /// <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;
 }