コード例 #1
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(LImage src, float x1, float y1, LImage 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).PackedValue != LSystem.TRANSPARENT)) &&
                            ((dest.GetPixel(nx1, ny1).PackedValue != LSystem.TRANSPARENT)))
                        {
                            return(true);
                        }
                    }
                    catch (Exception e)
                    {
                        Loon.Utils.Debugging.Log.Exception(e);
                    }
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: LProcess.cs プロジェクト: nobcdz/LGame
 public void OnDestroy()
 {
     EndTransition();
     if (GLEx.Self != null)
     {
         GLEx.Self.Dispose();
     }
     scene = null;
     screens.Clear();
     if (isInstance)
     {
         isInstance = false;
         loads.Clear();
         unloads.Clear();
         drawings.Clear();
         if (currentControl != null)
         {
             currentControl.Destroy();
             currentControl = null;
         }
         LSystem.isLogo       = false;
         LSystem.isPaused     = true;
         LSystem.AUTO_REPAINT = false;
         LImage.DisposeAll();
         LTextures.DisposeAll();
         XNACircle.Free();
         InitDestory();
     }
 }
コード例 #3
0
        public virtual LImage SetTileBackground(LImage image, bool isReturn)
        {
            if (image == null)
            {
                return(null);
            }
            int layerWidth  = GetWidth();
            int layerHeight = GetHeight();
            int tileWidth   = image.GetWidth();
            int tileHeight  = image.GetHeight();

            LImage    tempImage = LImage.CreateImage(layerWidth, layerHeight, false);
            LGraphics g         = tempImage.GetLGraphics();

            for (int x = 0; x < layerWidth; x += tileWidth)
            {
                for (int y = 0; y < layerHeight; y += tileHeight)
                {
                    g.DrawImage(image, x, y);
                }
            }
            g.Dispose();
            if (isReturn)
            {
                return(tempImage);
            }
            tempImage.SetFormat(Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
            SetBackground(tempImage.GetTexture());
            if (tempImage != null)
            {
                tempImage.Dispose();
                tempImage = null;
            }
            return(null);
        }
コード例 #4
0
        private void nextWavelet_Click(object sender, EventArgs e)
        {
            if (currentLayer < layers.Length - 1)
            {
                currentLayer++;
            }
            else
            {
                currentLayer = -1;
                ;
            }
            Image newImage = null;

            if (currentLayer >= 0)
            {
                newImage = layers[currentLayer].RenderBitmap(255);
            }
            else
            {
                int[] threshholds = new int[] { 150, 15, 3, 1 };
                using (var image = new LImage(layers, threshholds)) {
                    newImage = image.RenderBitmap((uint)MaxVNumericUpDown.Value);
                }
            }
            if (pictureBox.Image != null)
            {
                pictureBox.Image.Dispose();
            }
            pictureBox.Image = newImage;
        }
コード例 #5
0
        public static LTexture FilterColor(string res, LColor height, Loon.Core.Graphics.Opengl.LTexture.Format format)
        {
            uint      color = height.GetRGB();
            LImage    tmp   = LImage.CreateImage(res);
            LImage    image = LImage.CreateImage(tmp.GetWidth(), tmp.GetHeight(), true);
            LGraphics g     = image.GetLGraphics();

            g.DrawImage(tmp, 0, 0);
            g.Dispose();
            if (tmp != null)
            {
                tmp.Dispose();
                tmp = null;
            }
            Color[] pixels = image.GetPixels();
            int     size   = pixels.Length;

            for (int i = 0; i < size; i++)
            {
                if (pixels[i].PackedValue == color)
                {
                    pixels[i].PackedValue = LSystem.TRANSPARENT;
                }
            }
            image.SetFormat(format);
            image.SetPixels(pixels, image.GetWidth(), image.GetHeight());
            LTexture texture = image.GetTexture();

            if (image != null)
            {
                image.Dispose();
                image = null;
            }
            return(texture);
        }
コード例 #6
0
ファイル: GLLoader.cs プロジェクト: zhwk022/LGame
        public static void CopyArea(LImage image, LGraphics g, int x, int y, int width, int height, int dx, int dy)
        {
            LImage tmp = image.GetSubImage(x, y, width, height);

            g.DrawImage(tmp, x + dx, y + dy);
            tmp.Dispose();
            tmp = null;
        }
コード例 #7
0
ファイル: CollisionMask.cs プロジェクト: zx8326123/LGame
 public static Polygon MakePolygon(LImage image)
 {
     if (image == null)
     {
         throw new RuntimeException("Image is null !");
     }
     return(MakePolygon(image.GetIntPixels(), image.GetWidth(),
                        image.GetHeight()));
 }
コード例 #8
0
ファイル: CollisionMask.cs プロジェクト: zx8326123/LGame
 public static LTexture.Mask CreateMask(LImage image)
 {
     if (image == null)
     {
         throw new RuntimeException("Image is null !");
     }
     return(CreateMask(image.GetIntPixels(), image.GetWidth(),
                       image.GetHeight()));
 }
コード例 #9
0
ファイル: LSTRFont.cs プロジェクト: zx8326123/LGame
        public static LImage CreateFontImage(LFont font, LColor color, string text)
        {
            LImage    image = LImage.CreateImage(font.StringWidth(text), font.GetHeight());
            LGraphics g     = image.GetLGraphics();

            g.SetFont(font);
            g.DrawString(text, 0, 0, color);
            g.Dispose();
            return(image);
        }
コード例 #10
0
 public static LTexture OpenTexture(string fileName, string resName)
 {
     try {
         LImage image = OpenImage(fileName, resName);
         image.SetAutoDispose(true);
         return(image.GetTexture());
     } catch (Exception) {
         throw new Exception("File not found. ( " + resName + " )");
     }
 }
コード例 #11
0
 internal PackEntry(LImage image)
 {
     this.image = image;
     if (image != null)
     {
         this.fileName = image.GetPath();
         this.width    = image.GetWidth();
         this.height   = image.GetHeight();
     }
 }
コード例 #12
0
            public Menu()
                : base(128, 240)
            {
                // 设定menu层级高于MapLayer
                SetLayer(101);
                // 不锁定menu移动
                SetLocked(false);
                SetLimitMove(false);
                // 锁定Actor拖拽
                SetActorDrag(false);
                SetDelay(500);
                // 设定Menu背景
                LImage image = LImage.CreateImage(this.GetWidth(),
                                                  this.GetHeight(), true);
                LGraphics g = image.GetLGraphics();

                g.SetColor(0, 0, 0, 125);
                g.FillRect(0, 0, GetWidth(), GetHeight());
                g.SetColor(LColor.white);
                g.SetFont(15);
                g.DrawString("我是可拖拽菜单", 12, 25);
                g.Dispose();
                SetBackground(image.GetTexture());

                BulletTurret bulletTurret = new BulletTurret();

                bulletTurret.SetLocation(18, 64);


                BombTurret bombTurret = new BombTurret();

                bombTurret.SetLocation(78, 64);


                PoisonTurret poisonTurret = new PoisonTurret();

                poisonTurret.SetLocation(18, 134);


                LaserTurret laserTurret = new LaserTurret();

                laserTurret.SetLocation(78, 134);

                Button button = new Button();

                button.SetLocation(27, 196);

                // 复合LPaper到Layer
                Add(bulletTurret);
                Add(bombTurret);
                Add(poisonTurret);
                Add(laserTurret);
                Add(button);
            }
コード例 #13
0
        public static LImage OpenImage(string fileName, string resName)
        {
            byte[] buffer = null;
            try {
                buffer = LPKResource.OpenResource(fileName, resName);

                return(LImage.CreateImage(buffer));
            } catch (Exception) {
                throw new Exception("File not found. ( " + resName + " )");
            }
        }
コード例 #14
0
ファイル: GraphicsUtils.cs プロジェクト: nobcdz/LGame
        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);
        }
コード例 #15
0
ファイル: GraphicsUtils.cs プロジェクト: nobcdz/LGame
        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);
        }
コード例 #16
0
ファイル: PShadowEffect.cs プロジェクト: zx8326123/LGame
 public void Dispose()
 {
     this.isClose = true;
     this.EndUsePixelThread();
     this.finalDrawPixels = null;
     this.nowDrawPixels   = null;
     if (image != null)
     {
         image.Dispose();
         image = null;
     }
 }
コード例 #17
0
        private void btnShow_Click(object sender, RoutedEventArgs e)
        {
            Window window = new Window();

            window.Width  = 1024;
            window.Height = 768;

            Grid  mainGrd = new Grid();
            Image img     = new Image();

            img.Source = LImage.LoadImageFromByteArray(lstDuLieuHinhAnh[_currentIndex].Data);
            mainGrd.Children.Add(img);

            window.Content = mainGrd;
            window.ShowDialog();
        }
コード例 #18
0
 public LTexture Pack(Loon.Core.Graphics.Opengl.LTexture.Format format)
 {
     if (texture != null && !packing)
     {
         return(texture);
     }
     if (fileName != null)
     {
         texture       = new LTexture(GLLoader.GetTextureData(fileName), format);
         texture.isExt = true;
     }
     else
     {
         LImage image = PackImage();
         if (image == null)
         {
             return(null);
         }
         if (texture != null)
         {
             texture.Destroy();
             texture = null;
         }
         if (colorMask != null)
         {
             Color[] pixels = image.GetPixels();
             int     size   = pixels.Length;
             uint    color  = colorMask.GetRGB();
             for (int i = 0; i < size; i++)
             {
                 if (pixels[i].PackedValue == color)
                 {
                     pixels[i].PackedValue = LSystem.TRANSPARENT;
                 }
             }
             image.SetPixels(pixels, image.GetWidth(), image.GetHeight());
         }
         texture       = new LTexture(GLLoader.GetTextureData(image), format);
         texture.isExt = true;
         if (image != null)
         {
             image.Dispose();
             image = null;
         }
     }
     return(texture);
 }
コード例 #19
0
        public static SpriteFont Read(string resName)
        {
            try
            {
                List <RectBox> xGlyphs = new List <RectBox>(), xCropping = new List <RectBox>();
                List <Char>    xChars = new List <Char>();
                int            xSpacingV;
                float          xSpacingH;
                List <float[]> xKerning = new List <float[]>();

                ArrayByte arrays = new ArrayByte(Resources.OpenResource(resName),
                                                 ArrayByte.BIG_ENDIAN);

                int size = arrays.ReadInt();

                LImage image = LImage.CreateImage(arrays.ReadByteArray(size));

                int count = arrays.ReadInt();
                while (count-- > 0)
                {
                    xGlyphs.Add(new RectBox(arrays.ReadInt(), arrays.ReadInt(),
                                            arrays.ReadInt(), arrays.ReadInt()));
                    xCropping.Add(new RectBox(arrays.ReadInt(), arrays.ReadInt(),
                                              arrays.ReadInt(), arrays.ReadInt()));
                    xChars.Add((char)arrays.ReadInt());
                }

                xSpacingV = arrays.ReadInt();
                xSpacingH = arrays.ReadFloat();

                count = arrays.ReadInt();
                while (count-- > 0)
                {
                    xKerning.Add(new float[] { arrays.ReadFloat(),
                                               arrays.ReadFloat(), arrays.ReadFloat() });
                }
                arrays.Dispose();
                return(new SpriteFont(new LTexture(GLLoader.GetTextureData(image),
                                                   Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR), xGlyphs, xCropping, xChars, xSpacingV,
                                      xSpacingH, xKerning, 'A'));
            }
            catch (Exception e)
            {
                Loon.Utils.Debugging.Log.Exception(e);
            }
            return(null);
        }
コード例 #20
0
 public int PutImage(string name, LImage image)
 {
     CheckPacked();
     if (image == null)
     {
         throw new NullReferenceException();
     }
     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);
 }
コード例 #21
0
        public LImage GetImage(string name)
        {
            PackEntry entry = GetEntry(name);

            if (entry != null)
            {
                if (entry.image != null && !entry.image.IsClose())
                {
                    return(entry.image);
                }
                else if (entry.fileName != null)
                {
                    return(LImage.CreateImage(entry.fileName));
                }
            }
            return(null);
        }
コード例 #22
0
        public static LTexture CreateTexture(int width, int height, LColor c)
        {
            LImage    image = LImage.CreateImage(width, height, false);
            LGraphics g     = image.GetLGraphics();

            g.SetColor(c);
            g.FillRect(0, 0, width, height);
            g.Dispose();
            LTexture tex2d = image.GetTexture();

            if (image != null)
            {
                image.Dispose();
                image = null;
            }
            return(tex2d);
        }
コード例 #23
0
ファイル: AVGDialog.cs プロジェクト: zx8326123/LGame
        public static LTexture GetRMXPDialog(string fileName, int width,
                                             int height)
        {
            if (lazyImages == null)
            {
                lazyImages = new Dictionary <string, LTexture>(10);
            }
            LImage dialog = LImage.CreateImage(fileName);
            int    w      = dialog.GetWidth();

            Color[] pixels = dialog.GetPixels();
            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));
            }
        }
コード例 #24
0
        private void rbtnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Lấy dữ liệu ảnh 1
                string img1Path = txtLogo1.Tag.ToString();
                byte[] img1     = LImage.GetByteArrayFromImage(img1Path);

                // Lấy dữ liệu ảnh 2
                string img2Path = txtLogo2.Tag.ToString();
                byte[] img2     = LImage.GetByteArrayFromImage(img2Path);

                ZATestAppProcess process = new ZATestAppProcess();
                process.processDataTransfer(img1, img2);
            }
            catch (Exception ex)
            {
                //this.Close();
                //Application.Current.Shutdown();
                this.Cursor = Cursors.Arrow;
                if (ex.GetType() == typeof(CustomException))
                {
                    new frmThongBaoLoi(ex.Message, ex.InnerException).ShowDialog();
                }
                else
                {
                    if (ex.InnerException != null)
                    {
                        if (ex.InnerException.GetType() == typeof(CustomException))
                        {
                            new frmThongBaoLoi(ex.InnerException.Message, ex.InnerException).ShowDialog();
                        }
                        else
                        {
                            new frmThongBaoLoi("M.ResponseMessage.Common.KhongThanhCong", ex).ShowDialog();
                        }
                    }
                    else
                    {
                        new frmThongBaoLoi("M.ResponseMessage.Common.KhongThanhCong", ex).ShowDialog();
                    }
                }
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
        }
コード例 #25
0
 public int PutTile(int id, LImage img, Attribute attribute)
 {
     if (active)
     {
         TileMap.Tile tile = new TileMap.Tile();
         tile.id        = id;
         tile.imgId     = imgPack.PutImage(img);
         tile.attribute = attribute;
         CollectionUtils.Add(arrays, tile);
         dirty = true;
         return(tile.imgId);
     }
     else
     {
         throw new Exception(
                   "Map is no longer active, you can not add new tiles !");
     }
 }
コード例 #26
0
ファイル: GraphicsUtils.cs プロジェクト: nobcdz/LGame
        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);
        }
コード例 #27
0
 public void SetImage()
 {
     try
     {
         if (lstDuLieuHinhAnh != null && lstDuLieuHinhAnh.Count > 0 && _currentIndex <= lstDuLieuHinhAnh.Count - 1)
         {
             if (_currentIndex < 0)
             {
                 _currentIndex = 0;
             }
             imgKhachHang.Source = LImage.LoadImageFromByteArray(lstDuLieuHinhAnh[_currentIndex].Data);
             SetEnableControl();
         }
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
     }
 }
コード例 #28
0
        static void LImage2LImageForTP(MenuCommand menuCommand)
        {
            LImage     image         = menuCommand.context as LImage;
            GameObject go            = image.gameObject;
            var        color         = image.color;
            var        sprite        = image.sprite;
            var        raycastTarget = image.raycastTarget;

            var type = image.type;

            GameObject.DestroyImmediate(image);

            LImageForTP image2 = go.AddComponent <LImageForTP>();

            image2.color         = color;
            image2.sprite        = sprite;
            image2.raycastTarget = raycastTarget;
            image2.type          = type;
        }
コード例 #29
0
ファイル: StatusBar.cs プロジェクト: zx8326123/LGame
        public LTexture LoadBarColor(LColor c1, LColor c2, LColor c3)
        {
            if (colors.Count > 10)
            {
                lock (colors)
                {
                    foreach (LTexture tex2d in colors.Values)
                    {
                        if (tex2d != null)
                        {
                            tex2d.Destroy();
                        }
                    }
                    colors.Clear();
                }
            }
            int hash = 1;

            hash = LSystem.Unite(hash, c1.GetRGB());
            hash = LSystem.Unite(hash, c2.GetRGB());
            hash = LSystem.Unite(hash, c3.GetRGB());
            LTexture texture = null;

            lock (colors)
            {
                texture = (LTexture)CollectionUtils.Get(colors, hash);
            }
            if (texture == null)
            {
                LImage    image = LImage.CreateImage(8, 8, false);
                LGraphics g     = image.GetLGraphics();
                g.SetColor(c1);
                g.FillRect(0, 0, 4, 4);
                g.SetColor(c2);
                g.FillRect(4, 0, 4, 4);
                g.SetColor(c3);
                g.FillRect(0, 4, 4, 4);
                g.Dispose();
                texture = image.GetTexture();
                CollectionUtils.Put(colors, hash, texture);
            }
            return(this.texture = texture);
        }
コード例 #30
0
        public static LTexture FilterLimitColor(string res, LColor start,
                                                LColor end, Loon.Core.Graphics.Opengl.LTexture.Format format)
        {
            int       sred   = start.R;
            int       sgreen = start.G;
            int       sblue  = start.B;
            int       ered   = end.R;
            int       egreen = end.G;
            int       eblue  = end.B;
            LImage    tmp    = LImage.CreateImage(res);
            LImage    image  = LImage.CreateImage(tmp.GetWidth(), tmp.GetHeight(), true);
            LGraphics g      = image.GetLGraphics();

            g.DrawImage(tmp, 0, 0);
            g.Dispose();
            if (tmp != null)
            {
                tmp.Dispose();
                tmp = null;
            }
            Color[] pixels = image.GetPixels();
            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 = LSystem.TRANSPARENT;
                }
            }
            image.SetFormat(format);
            image.SetPixels(pixels, image.GetWidth(), image.GetHeight());
            LTexture texture = image.GetTexture();

            if (image != null)
            {
                image.Dispose();
                image = null;
            }
            return(texture);
        }
コード例 #31
0
ファイル: LGraphics.cs プロジェクト: keppelcao/LGame
        public void DrawImage(LImage img, int dstX, int dstY, int dstWidth, int dstHeight,
                int srcX, int srcY, int srcWidth, int srcHeight)
        {
            if (isClose || img == null || img.IsClose())
            {
                return;
            }

            LGraphics pixel = img.GetLGraphics();

            pixel.UpdatePixels();

            dstX += translateX;
            dstY += translateY;
            srcX += translateX;
            srcY += translateY;

            if (pixel == null || dstWidth <= 0 || dstHeight <= 0 || srcWidth <= 0 || srcHeight <= 0)
            {
                return;
            }
            if (dstWidth == srcWidth && dstHeight == srcHeight)
            {
                DrawImage(pixel, dstX, dstY, dstWidth, dstHeight, srcX, srcY);
                return;
            }

            Color[] currentPixels = pixel.pixels;

            int spitch = pixel.width;
            int dpitch = this.width;

            float x_ratio = ((float)srcWidth - 1) / dstWidth;
            float y_ratio = ((float)srcHeight - 1) / dstHeight;
            float x_diff = 0F;
            float y_diff = 0F;

            int dx = dstX;
            int dy = dstY;
            int sx = srcX;
            int sy = srcY;
            int i = 0;
            int j = 0;

            for (; i < dstHeight; i++)
            {
                sy = (int)(i * y_ratio) + srcY;
                dy = i + dstY;
                y_diff = (y_ratio * i + srcY) - sy;
                if (sy < 0 || dy < 0)
                {
                    continue;
                }
                if (sy >= pixel.height || dy >= this.height)
                {
                    break;
                }

                for (j = 0; j < dstWidth; j++)
                {
                    sx = (int)(j * x_ratio) + srcX;
                    dx = j + dstX;
                    x_diff = (x_ratio * j + srcX) - sx;
                    if (sx < 0 || dx < 0)
                    {
                        continue;
                    }
                    if (sx >= pixel.width || dx >= this.width)
                    {
                        break;
                    }

                    int src_ptr = sx + sy * spitch;
                    int dst_ptr = dx + dy * dpitch;
                    Color src_color = currentPixels[src_ptr];
                    uint src_pixel = src_color.PackedValue;

                    if (src_pixel != LSystem.TRANSPARENT)
                    {
                        float ta = (1 - x_diff) * (1 - y_diff);
                        float tb = (x_diff) * (1 - y_diff);
                        float tc = (1 - x_diff) * (y_diff);
                        float td = (x_diff) * (y_diff);

                        uint a = (uint)(((src_pixel & 0xff000000) >> 24) * ta +
                                                ((src_pixel & 0xff000000) >> 24) * tb +
                                                ((src_pixel & 0xff000000) >> 24) * tc +
                                                ((src_pixel & 0xff000000) >> 24) * td) & 0xff;
                        uint b = (uint)(((src_pixel & 0xff0000) >> 16) * ta +
                                                ((src_pixel & 0xff0000) >> 16) * tb +
                                                ((src_pixel & 0xff0000) >> 16) * tc +
                                                ((src_pixel & 0xff0000) >> 16) * td) & 0xff;
                        uint g = (uint)(((src_pixel & 0xff00) >> 8) * ta +
                                                ((src_pixel & 0xff00) >> 8) * tb +
                                                ((src_pixel & 0xff00) >> 8) * tc +
                                                ((src_pixel & 0xff00) >> 8) * td) & 0xff;
                        uint r = (uint)((src_pixel & 0xff) * ta +
                                                (src_pixel & 0xff) * tb +
                                                (src_pixel & 0xff) * tc +
                                                (src_pixel & 0xff) * td) & 0xff;

                        Color dst_color = pixels[dst_ptr];
                        DrawPoint(pixels, dst_ptr, Blend(r, g, b, a, dst_color));
                    }
                    else
                    {
                        DrawPoint(pixels, dst_ptr, LSystem.TRANSPARENT);
                    }
                }
            }

        }
コード例 #32
0
ファイル: LGraphics.cs プロジェクト: keppelcao/LGame
 public void DrawImage(LImage image, int x, int y, int w, int h)
 {
     if (image == null)
     {
         return;
     }
     else
     {
         DrawImage(image, x, y, w, h, 0, 0, image.width, image.height);
         return;
     }
 }
コード例 #33
0
ファイル: LGraphics.cs プロジェクト: keppelcao/LGame
 public void DrawImage(LImage pixel)
 {
     if (isClose)
     {
         return;
     }
     LGraphics g = pixel.GetLGraphics();
     int w = pixel.width;
     int h = pixel.height;
     Color[] currentPixels = g.pixels;
     for (int size = 0; size < h; size++)
     {
         Array.Copy(currentPixels, size * pixel.width
                 , pixels, size * width, w);
     }
 }
コード例 #34
0
ファイル: LGraphics.cs プロジェクト: keppelcao/LGame
        public LImage[] Split(int row, int col)
        {
            if (isClose)
            {
                return null;
            }
            int count = row * col;
            int w = width / row;
            int h = height / col;

            LImage[] pixels = new LImage[count];
            for (int i = 0; i < count; i++)
            {
                int x = (i % row) * w;
                int y = (i / row) * h;
                pixels[i] = Copy(x, y, w, h);
            }

            return pixels;
        }
コード例 #35
0
ファイル: LGraphics.cs プロジェクト: keppelcao/LGame
 public LGraphics(LImage buffer)
 {
     this.alpha = true;
     this.width = buffer.width;
     this.height = buffer.height;
     this.size = width * height;
     this.colorValue = new Color(255, 255, 255, 255);
     this.clip = new RectBox(0, 0, width, height);
     this.defClip = new RectBox(0, 0, width, height);
     this.pixels = new Color[size];
     this.store = buffer.m_data;
     store.GetData(pixels);
     this.isDitry = false;
 }
コード例 #36
0
ファイル: GLLoader.cs プロジェクト: keppelcao/LGame
        private void Create(LImage image)
        {

            if (image == null)
            {
                return;
            }
            if (buffer != null)
            {
                return;
            }

            fileName = image.GetPath();


            this.isExt = image.isExt;
            this.hasAlpha = image.hasAlpha;
            int srcWidth = image.Width;
            int srcHeight = image.Height;

            if (GLEx.IsPowerOfTwo(srcWidth) && GLEx.IsPowerOfTwo(srcHeight))
            {
                this.width = srcWidth;
                this.height = srcHeight;
                this.texHeight = srcHeight;
                this.texWidth = srcWidth;
                this.buffer = image.GetBitmap();
                if (image.IsAutoDispose())
                {
                    image.Dispose();
                    image = null;
                }
                return;
            }

            int texWidth = GLEx.ToPowerOfTwo(srcWidth);
            int texHeight = GLEx.ToPowerOfTwo(srcHeight);

            this.width = srcWidth;
            this.height = srcHeight;
            this.texHeight = texHeight;
            this.texWidth = texWidth;
            Color[] src = image.GetPixels();
            Color[] dst = new Color[texWidth * texHeight];
            for (int size = 0; size < height; size++)
            {
                Array.Copy(src, size * width
                        , dst, size * texWidth, width);
            }
            if (buffer == null)
            {
                buffer = new Texture2D(GL.device, texWidth, texHeight);
            }
            buffer.SetData<Color>(dst);
            src = null;
            dst = null;
            if (image != null && image.IsAutoDispose())
            {
                image.Dispose();
                image = null;
            }
        }
コード例 #37
0
ファイル: LTexture.cs プロジェクト: darragh-murphy/LGame
        public LTexture(LImage pix)
            : this(pix, Format.DEFAULT)
        {

        }
コード例 #38
0
ファイル: GLLoader.cs プロジェクト: keppelcao/LGame
 public static LTextureData GetTextureData(LImage img)
 {
     return new GLLoader(img);
 }
コード例 #39
0
ファイル: LLayer.cs プロジェクト: keppelcao/LGame
        public virtual LImage SetTileBackground(LImage image, bool isReturn)
        {
            if (image == null)
            {
                return null;
            }
            int layerWidth = GetWidth();
            int layerHeight = GetHeight();
            int tileWidth = image.GetWidth();
            int tileHeight = image.GetHeight();

            LImage tempImage = LImage.CreateImage(layerWidth, layerHeight, false);
            LGraphics g = tempImage.GetLGraphics();
            for (int x = 0; x < layerWidth; x += tileWidth)
            {
                for (int y = 0; y < layerHeight; y += tileHeight)
                {
                    g.DrawImage(image, x, y);
                }
            }
            g.Dispose();
            if (isReturn)
            {
                return tempImage;
            }
            tempImage.SetFormat(Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
            SetBackground(tempImage.GetTexture());
            if (tempImage != null)
            {
                tempImage.Dispose();
                tempImage = null;
            }
            return null;
        }
コード例 #40
0
ファイル: LTexturePack.cs プロジェクト: 207h2Flogintvg/LGame
		public int PutImage(string name, LImage image) {
			CheckPacked();
			if (image == null) {
				throw new NullReferenceException();
			}
			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;
		}
コード例 #41
0
ファイル: LTexture.cs プロジェクト: darragh-murphy/LGame
        public LTexture(LImage pix, Format format)
            : this(GLLoader.GetTextureData(pix), format)
        {

        }
コード例 #42
0
ファイル: GLLoader.cs プロジェクト: keppelcao/LGame
 private GLLoader(LImage img)
 {
     Create(img);
 }
コード例 #43
0
ファイル: LTexturePack.cs プロジェクト: 207h2Flogintvg/LGame
		public int PutImage(LImage image) {
			return PutImage(
					JavaRuntime.CurrentTimeMillis() + "|" + Convert.ToString((count + 1)),
					image);
		}
コード例 #44
0
ファイル: LLayer.cs プロジェクト: keppelcao/LGame
 public virtual void SetTileBackground(LImage image)
 {
     SetTileBackground(image, false);
 }
コード例 #45
0
ファイル: LTexturePack.cs プロジェクト: 207h2Flogintvg/LGame
            internal PackEntry(LImage image)
            {
				this.image = image;
				if (image != null) {
					this.fileName = image.GetPath();
					this.width = image.GetWidth();
					this.height = image.GetHeight();
				}
			}
コード例 #46
0
ファイル: GLLoader.cs プロジェクト: keppelcao/LGame
 public static void CopyArea(LImage image, LGraphics g, int x, int y, int width, int height, int dx, int dy)
 {
     LImage tmp = image.GetSubImage(x, y, width, height);
     g.DrawImage(tmp, x + dx, y + dy);
     tmp.Dispose();
     tmp = null;
 }