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


C# Imaging.BitmapData类代码示例

本文整理汇总了C#中System.Drawing.Imaging.BitmapData的典型用法代码示例。如果您正苦于以下问题:C# BitmapData类的具体用法?C# BitmapData怎么用?C# BitmapData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BitmapData类属于System.Drawing.Imaging命名空间,在下文中一共展示了BitmapData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BltBitmap

 public static void BltBitmap(IntPtr dstPixels, Size dstSize,
     int dstX, int dstY, int width, int height,
     BitmapData srcBD, int srcX, int srcY)
 {
     Debug.Assert(srcBD.PixelFormat == PixelFormat.Format32bppArgb);
     Size srcSize = new Size(srcBD.Width, srcBD.Height);
     if (!ModifyRectangle(dstSize, ref dstX, ref dstY, ref width, ref height, srcSize, ref srcX, ref srcY))
     {
         return;
     }
     unsafe
     {
         int dstStride = (dstSize.Width * 4 + 3) / 4 * 4;
         Debug.Assert(srcBD.Stride % 4 == 0);
         int* dst = (int*)dstPixels + dstX + (dstY * dstStride / 4);
         int* src = (int*)srcBD.Scan0 + srcX + (srcY * srcBD.Stride / 4);
         int paddingDst = dstStride / 4 - width;
         int paddingSrc = srcBD.Stride / 4 - width;
         Debug.Assert(0 <= paddingDst);
         Debug.Assert(0 <= paddingSrc);
         for (int j = 0; j < height; j++, dst += paddingDst, src += paddingSrc)
         {
             for (int i = 0; i < width; i++, dst++, src++)
             {
                 *dst = *src;
             }
         }
     }
 }
开发者ID:hajimehoshi,项目名称:shrimp,代码行数:29,代码来源:Util.cs

示例2: drawClearWithBackground

 public static unsafe void drawClearWithBackground(Rectangle srcArea, BitmapData srcData, Rectangle dstArea, BitmapData dstData, BitmapData bgData)
 {
     if (srcData == null)
         return;
     int stride1 = srcData.Stride;
     int num1 = (int)srcData.Scan0 + srcArea.X * 4 + srcArea.Y * stride1;
     if (dstData == null)
         return;
     int stride2 = dstData.Stride;
     int num2 = (int)dstData.Scan0 + dstArea.X * 4 + dstArea.Y * stride2;
     if (bgData == null)
         return;
     int stride3 = bgData.Stride;
     int num3 = (int)bgData.Scan0 + dstArea.X * 4 + dstArea.Y * stride3;
     int width = srcArea.Width;
     int height = srcArea.Height;
     for (int index1 = 0; index1 < height; ++index1) {
         int num4 = num1 + index1 * stride1;
         int num5 = num2 + index1 * stride2;
         int num6 = num3 + index1 * stride3;
         for (int index2 = 0; index2 < width; ++index2) {
             *(PixelData*)num5 = PixelData.overlayPixelData(*(PixelData*)num4, *(PixelData*)num6);
             num4 += 4;
             num5 += 4;
             num6 += 4;
         }
     }
 }
开发者ID:Vliegwiel,项目名称:dfWeb,代码行数:28,代码来源:PixelData.cs

示例3: DrawExteriorAll

 public static void DrawExteriorAll(BitmapData data_bac)
 {
     for (int i = 0; i < STATIONS.Count; i++)
     {
         STATIONS[i].Draw_Exterior(data_bac);
     }
 }
开发者ID:fsps60312,项目名称:Digging-Game-2,代码行数:7,代码来源:Station.cs

示例4: Apply

        public virtual Bitmap Apply(BitmapData imageData)
        {
            if (imageData.PixelFormat != PixelFormat.Format24bppRgb &&
                imageData.PixelFormat != PixelFormat.Format32bppArgb &&
                imageData.PixelFormat != PixelFormat.Format32bppRgb)
            {
                throw new ArgumentException();
            }

            int width = imageData.Width;
            int height = imageData.Height;

            Bitmap bitmap = new Bitmap(
                width, height, PixelFormat.Format24bppRgb);
            BitmapData bitmapdata = bitmap.LockBits(
                new Rectangle(0, 0, width, height),
                ImageLockMode.ReadWrite,
                PixelFormat.Format24bppRgb);

            NativeMethods.memcpy(
                bitmapdata.Scan0,
                imageData.Scan0,
                imageData.Stride * height);
            ProcessFilter(bitmapdata);
            bitmap.UnlockBits(bitmapdata);
            return bitmap;
        }
开发者ID:AndrewFanChina,项目名称:Cyclone2D-Editor,代码行数:27,代码来源:FilterColorToColor.cs

示例5: EmptyAlphaPixel

        /// <summary>
        /// Returns try if the given pixel is empty (i.e. alpha is zero)
        /// </summary>
        public static unsafe bool EmptyAlphaPixel(BitmapData bitmapData, int px, int py, byte alphaEmptyPixelTolerance)
        {

            byte* addr = (byte*)(bitmapData.Scan0) + bitmapData.Stride * py + px * 4;
            return (*(addr + 3) <= alphaEmptyPixelTolerance);

        }
开发者ID:Pireax,项目名称:neovim.cs,代码行数:10,代码来源:QBitmap.cs

示例6: EmptyPixel

        /// <summary>
        /// Returns try if the given pixel is empty (i.e. black)
        /// </summary>
        public static unsafe bool EmptyPixel(BitmapData bitmapData, int px, int py)
        {

            byte* addr = (byte*)(bitmapData.Scan0) + bitmapData.Stride * py + px * 3;
            return (*addr == 0 && *(addr + 1) == 0 && *(addr + 2) == 0);

        }
开发者ID:Pireax,项目名称:neovim.cs,代码行数:10,代码来源:QBitmap.cs

示例7: Apply

 public void Apply(BitmapData tileset, BitmapData background)
 {
     if (this.chunklist == null)
         return;
     foreach (TilesetPatchChunk tilesetPatchChunk in this.chunklist)
         tilesetPatchChunk.Apply(tileset, background);
 }
开发者ID:Vliegwiel,项目名称:dfWeb,代码行数:7,代码来源:TilesetPatch.cs

示例8: Circle

        public static void Circle(BitmapData bmpData, int Size, int X, int Y, Color Colour)
        {
            CacheCircles(Size);

            int tempX;
            int i = 0;
            for (int tempY = Y - Size; tempY < Y + Size; tempY++)
            {
                if (tempY >= 0)
                {
                    if (tempY >= bmpData.Height)
                    {
                        break;
                    }
                    tempX = X - CircleCache[Size][i];
                    while (tempX < CircleCache[Size][i] + X)
                    {
                        if (tempX >= 0)
                        {
                            if (tempX >= bmpData.Width)
                            {
                                break;
                            }
                            IntPtr temp = FindPtr(bmpData, tempX, tempY);
                            System.Runtime.InteropServices.Marshal.WriteInt32(temp, Colour.ToArgb());
                        }

                      tempX++;
                    }
                }
                i++;
            }
        }
开发者ID:RichTeaMan,项目名称:EcoSim,代码行数:33,代码来源:Draw.cs

示例9: ProcessFilter

        // Process the filter
        private unsafe void ProcessFilter( BitmapData data )
        {
            int width	= data.Width;
            int height	= data.Height;
            int offset	= data.Stride - width * 3;

            // do the job
            byte * ptr = (byte *) data.Scan0.ToPointer( );
            byte t;

            // for each line
            for ( int y = 0; y < height; y++ )
            {
                // for each pixel
                for ( int x = 0; x < width; x++, ptr += 3 )
                {
                    // rotate colors of each pixel
                    t = ptr[RGB.R];
                    ptr[RGB.R] = ptr[RGB.G];
                    ptr[RGB.G] = ptr[RGB.B];
                    ptr[RGB.B] = t;
                }
                ptr += offset;
            }
        }
开发者ID:vebin,项目名称:PhotoBrushProject,代码行数:26,代码来源:RotateChannels.cs

示例10: Apply

 internal static Bitmap Apply(BitmapData bitmapData1)
 {
     Bitmap returnMap = new Bitmap(bitmapData1.Width, bitmapData1.Height, PixelFormat.Format32bppArgb);
     BitmapData bitmapData2 = returnMap.LockBits(new Rectangle(0, 0,
                              returnMap.Width, returnMap.Height),
                              ImageLockMode.ReadOnly,
                              PixelFormat.Format32bppArgb);
     unsafe
     {
         byte* imagePointer1 = (byte*)bitmapData1.Scan0;
         byte* imagePointer2 = (byte*)bitmapData2.Scan0;
         for (int i = 0; i < bitmapData1.Height; i++)
         {
             for (int j = 0; j < bitmapData1.Width; j++)
             {
                 // Standard Invert algorithm
                 imagePointer2[0] = (byte)(255 - imagePointer1[0]);
                 imagePointer2[1] = (byte)(255 - imagePointer1[1]);
                 imagePointer2[2] = (byte)(255 - imagePointer1[2]);
                 imagePointer2[3] = imagePointer1[3];
                 //4 bytes per pixel
                 imagePointer1 += 4;
                 imagePointer2 += 4;
             }
             //4 bytes per pixel
             imagePointer1 += bitmapData1.Stride - (bitmapData1.Width * 4);
             imagePointer2 += bitmapData1.Stride - (bitmapData1.Width * 4);
         }
     }
     returnMap.UnlockBits(bitmapData2);
     return returnMap;
 }
开发者ID:dspankov,项目名称:FilterIT,代码行数:32,代码来源:InvertFilter.cs

示例11: Smoother

 /// <summary>
 /// Creates a new instance of Smoother
 /// </summary>
 public Smoother(BitmapData inBmpData, byte[] inRgbData, IProgressHandler progHandler)
 {
     _bmpData = inBmpData;
     _rgbData = inRgbData;
     _result = new byte[inRgbData.Length];
     pm = new ProgressMeter(progHandler, "Smoothing Image", inBmpData.Height);
 }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:10,代码来源:Smoother.cs

示例12: DrawImg

 public void DrawImg()
 {
     imgData = img.LockBits(
         new Rectangle(0, 0, Width, Height),
         ImageLockMode.ReadWrite,
         PixelFormat.Format32bppArgb);
 }
开发者ID:gamma057,项目名称:MathEngine,代码行数:7,代码来源:Graph.cs

示例13: BeginAccess

 /// <summary>
 /// Bitmap処理の高速化開始
 /// </summary>
 public void BeginAccess()
 {
     // Bitmapに直接アクセスするためのオブジェクト取得(LockBits)
     _img = _bmp.LockBits(new Rectangle(0, 0, _bmp.Width, _bmp.Height),
         System.Drawing.Imaging.ImageLockMode.ReadWrite,
         System.Drawing.Imaging.PixelFormat.Format24bppRgb);
 }
开发者ID:Nucleareal,项目名称:RandomPiecesGenerator,代码行数:10,代码来源:BitmapFast.cs

示例14: Unlock

 /// <summary>
 /// Required to use the image after editing.
 /// </summary>
 public void Unlock()
 {
     System.Runtime.InteropServices.Marshal.Copy(PixelData, 0, BmpData.Scan0, PixelData.Length);
     BitmapImage.UnlockBits(BmpData);
     BmpData = null;
     PixelData = null;
 }
开发者ID:ninjabyte,项目名称:AncientClaw.NET,代码行数:10,代码来源:MemoryBitmap.cs

示例15: InitializeBuffer

        private void InitializeBuffer()
        {
            bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);

            imageBuffer = new byte[bitmapData.Stride * bitmap.Height];
        }
开发者ID:freelancejounin,项目名称:intelligent-scissors,代码行数:7,代码来源:DirectBitmapWriter.cs


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