当前位置: 首页>>代码示例>>C#>>正文


C# FastBitmap.Lock方法代码示例

本文整理汇总了C#中FastBitmap.Lock方法的典型用法代码示例。如果您正苦于以下问题:C# FastBitmap.Lock方法的具体用法?C# FastBitmap.Lock怎么用?C# FastBitmap.Lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FastBitmap的用法示例。


在下文中一共展示了FastBitmap.Lock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyTo

 public void CopyTo(FastBitmap bitmap, Int32 destx, Int32 desty, Int32 srcx, Int32 srcy,
     Int32 width, Int32 height)
 {
     try {
         Lock();
         bitmap.Lock();
         for (Int32 y = 0; y < height; y++) {
             for (Int32 x = 0; x < width; x++) {
                 Color c = GetPixel(srcx + x, srcy + y);
                 bitmap.SetPixel(destx + x, desty + y, c);
             }
         }
     }
     finally {
         Unlock();
         bitmap.Unlock();
     }
 }
开发者ID:BGCX261,项目名称:zrlabs-yael-svn-to-git,代码行数:18,代码来源:shadow.cs

示例2: BitmapSetPixelsArgb

 public override void BitmapSetPixelsArgb(BitmapCi bmp, int[] pixels)
 {
     BitmapCiCs bmp_ = (BitmapCiCs)bmp;
     int width = bmp_.bmp.Width;
     int height = bmp_.bmp.Height;
     if (IsMono)
     {
         for (int y = 0; y < height; y++)
         {
             for (int x = 0; x < width; x++)
             {
                 int color = pixels[x + y * width];
                 bmp_.bmp.SetPixel(x, y, Color.FromArgb(color));
             }
         }
     }
     else
     {
         FastBitmap fastbmp = new FastBitmap();
         fastbmp.bmp = bmp_.bmp;
         fastbmp.Lock();
         for (int x = 0; x < width; x++)
         {
             for (int y = 0; y < height; y++)
             {
                 fastbmp.SetPixel(x, y, pixels[x + y * width]);
             }
         }
         fastbmp.Unlock();
     }
 }
开发者ID:YoungGames,项目名称:manicdigger,代码行数:31,代码来源:PlatformNative.cs

示例3: Flatten

    internal FastBitmap Flatten()
    {
        // create a bitmap for result image

        FastBitmap final = new FastBitmap(_width, _height,
            PixelFormat.Format24bppRgb);

        // lock all bitmaps

        final.Lock();
        for (Int32 i = 0; i < _layers.Count; i++) {
            Layer l = _layers[i];
            l._bitmap.Lock();
            if (l.Mask != null)
                l.Mask.Lock();
        }

        // calculate colors of flattened image
        // 1. take offsetx, offsety into consideration
        // 2. calculate alpha of color (alpha, opacity, mask)
        // 3. mix colors of current layer and layer below

        for (Int32 y = 0; y < _height; y++) {
            for (Int32 x = 0; x < _width; x++) {
                Color c0 = _layers[0]._bitmap.GetPixel(x, y);
                for (Int32 i = 1; i < _layers.Count; i++) {
                    Layer layer = _layers[i];
                    Color c1 = Color.Transparent;
                    if (x >= layer.OffsetX &&
                        x <= layer.OffsetX + layer._bitmap.Width - 1 &&
                        y >= layer.OffsetY &&
                        y <= layer.OffsetY + layer._bitmap.Height - 1) {
                        c1 = layer._bitmap.GetPixel(x - layer.OffsetX,
                            y - layer.OffsetY);
                    }
                    if (c1.A == 255 && layer.Opacity == 1.0 &&
                        layer.Mask == null) {
                        c0 = c1;
                    } else {
                        Double tr, tg, tb, a;
                        a = c1.A / 255.0 * layer.Opacity;
                        if (layer.Mask != null) {
                            a *= layer.Mask.GetIntensity(x, y) / 255.0;
                        }
                        tr = c1.R * a + c0.R * (1.0 - a);
                        tg = c1.G * a + c0.G * (1.0 - a);
                        tb = c1.B * a + c0.B * (1.0 - a);
                        tr = Math.Round(tr);
                        tg = Math.Round(tg);
                        tb = Math.Round(tb);
                        tr = Math.Min(tr, 255);
                        tg = Math.Min(tg, 255);
                        tb = Math.Min(tb, 255);
                        c0 = Color.FromArgb((Byte)tr, (Byte)tg, (Byte)tb);
                    }
                }
                final.SetPixel(x, y, c0);
            }
        }

        // unlock all bitmaps

        for (Int32 i = 0; i < _layers.Count; i++) {
            Layer l = _layers[i];
            l._bitmap.Unlock();
            if (l.Mask != null)
                l.Mask.Unlock();
        }
        final.Unlock();

        return final;
    }
开发者ID:BGCX261,项目名称:zrlabs-yael-svn-to-git,代码行数:72,代码来源:shadow.cs

示例4: BitmapGetPixelsArgb

 public override void BitmapGetPixelsArgb(BitmapCi bitmap, int[] bmpPixels)
 {
     BitmapCiCs bmp = (BitmapCiCs)bitmap;
     int width = bmp.bmp.Width;
     int height = bmp.bmp.Height;
     if (IsMono)
     {
         for (int x = 0; x < width; x++)
         {
             for (int y = 0; y < height; y++)
             {
                 bmpPixels[x + y * width] = bmp.bmp.GetPixel(x, y).ToArgb();
             }
         }
     }
     else
     {
         FastBitmap fastbmp = new FastBitmap();
         fastbmp.bmp = bmp.bmp;
         fastbmp.Lock();
         for (int x = 0; x < width; x++)
         {
             for (int y = 0; y < height; y++)
             {
                 bmpPixels[x + y * width] = fastbmp.GetPixel(x, y);
             }
         }
         fastbmp.Unlock();
     }
 }
开发者ID:YoungGames,项目名称:manicdigger,代码行数:30,代码来源:PlatformNative.cs


注:本文中的FastBitmap.Lock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。