• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FastBitmap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ApplyFilter

        /// <summary>
        /// Applies the filter to the specified <paramref name="bitmap"/>. This method
        /// first calls <see cref="ImageReplacementFilter.GetDestinationDimensions(FastBitmap, out Int32, out Int32)" />
        /// to calculate the size of the destination image. Then it calls
        /// <see cref="ImageReplacementFilter.ApplyFilter(FastBitmap, FastBitmap, Graphics)" /> 
        /// which is where the overridden class implements its filter algorithm.
        /// </summary>
        /// <param name="bitmap">
        /// Image to apply the <see cref="ImageReplacementFilter" /> to.
        /// </param>
        public override sealed void ApplyFilter(FastBitmap bitmap)
        {
            OnBeginApplyFilter(bitmap);

            // get destination dimensions
            int width, height;
            bool shouldContinue = GetDestinationDimensions(bitmap, out width, out height);
            if (!shouldContinue)
                return;

            DrawingVisual dv = new DrawingVisual();
            ConfigureDrawingVisual(bitmap, dv);

            DrawingContext dc = dv.RenderOpen();

            ApplyFilter(bitmap, dc, width, height);
            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(width, height);
            rtb.Render(dv);
            FastBitmap destination = new FastBitmap(rtb);

            // copy metadata
            // TODO
            /*foreach (PropertyItem propertyItem in bitmap.InnerBitmap.PropertyItems)
                destination.InnerBitmap.SetPropertyItem(propertyItem);*/

            // set new image
            bitmap.InnerBitmap = destination.InnerBitmap;

            OnEndApplyFilter();
        }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:42,代码来源:ImageReplacementFilter.cs


示例2: PixelReader

 public PixelReader(FastBitmap fastBitmap, Rectangle region)
 {
     if (fastBitmap == null)
         throw new ArgumentOutOfRangeException("fastBitmap", "must not be null");
     _fastBitmap = fastBitmap;
     _region = region;
 }
开发者ID:gavinramm,项目名称:Afterglow,代码行数:7,代码来源:PixelReader.cs


示例3: DrawPoint

 /// <summary>
 /// Draw an one-pixel point of fixed color (defined by <see cref="PixelData"/>) in fixed position.
 /// </summary>
 public static void DrawPoint(FastBitmap bmp, int x, int y, PixelData color)
 {
     PixelData* addr = bmp[x, y];
     addr->R = color.R;
     addr->G = color.G;
     addr->B = color.B;
 }
开发者ID:mijay,项目名称:SwarmIntelligence,代码行数:10,代码来源:FastDrawHelper.cs


示例4: RenderFrame

 private Bitmap RenderFrame(LinePairCollection lines, FastBitmap startImage, FastBitmap endImage, double percent)
 {
     var forwardsAndBackwards = InterpolateLines(lines, percent);
     using (Bitmap forward = ComputePreimage( startImage,  forwardsAndBackwards.Item1))
     using (Bitmap backward = ComputePreimage( endImage, forwardsAndBackwards.Item2))
         return BlendImages(forward, backward, 1 - percent);
 }
开发者ID:Farouq,项目名称:semclone,代码行数:7,代码来源:ComputeMorph.cs


示例5: GetEffect

 protected override Effect GetEffect(FastBitmap source)
 {
     return new BrightnessAdjustmentEffect
     {
         Level = this.Level/100.0
     };
 }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:7,代码来源:BrightnessAdjustmentFilter.cs


示例6: CropArea

        public static unsafe Bitmap CropArea(Bitmap original, int posX, int posY, int width, int height)
        {
            Bitmap ret = new Bitmap(width, height);
            #if false
            FastBitmap retFast = new FastBitmap(ret);
            FastBitmap origFast = new FastBitmap(original);

            retFast.LockImage();
            origFast.LockImage();

            for (int x = posX; x < posX + width && x < original.Width; ++x)
            {
                for (int y = posY; y < posY + height && y < original.Height; ++y)
                {
                    retFast.CopyFrom(x - posX, y - posY, origFast.GetPixelData(x, y));
                }
            }

            retFast.UnlockImage();
            origFast.UnlockImage();
            #else
            using (Graphics g = Graphics.FromImage(ret))
            {
                RectangleF source = new RectangleF(posX, posY, width, height);
                RectangleF target = new RectangleF(0, 0, width, height);
                g.DrawImage(original, target, source, GraphicsUnit.Pixel);
            }
            #endif

            return ret;
        }
开发者ID:kalimaul,项目名称:specalg,代码行数:31,代码来源:Images.cs


示例7: CopyScaledPixels

        static unsafe void CopyScaledPixels( FastBitmap src, FastBitmap dst, Size scale,
            Rectangle srcRect, Rectangle dstRect, byte rgbScale)
        {
            int srcWidth = srcRect.Width, dstWidth = dstRect.Width;
            int srcHeight = srcRect.Height, dstHeight = dstRect.Height;
            int srcX = srcRect.X, dstX = dstRect.X;
            int srcY = srcRect.Y, dstY = dstRect.Y;
            int scaleWidth = scale.Width, scaleHeight = scale.Height;

            for( int yy = 0; yy < dstHeight; yy++ ) {
                int scaledY = yy * srcHeight / scaleHeight;
                int* srcRow = src.GetRowPtr( srcY + scaledY );
                int* dstRow = dst.GetRowPtr( dstY + yy );

                for( int xx = 0; xx < dstWidth; xx++ ) {
                    int scaledX = xx * srcWidth / scaleWidth;
                    int pixel = srcRow[srcX + scaledX];

                    int col = pixel & ~0xFFFFFF; // keep a but clear rgb
                    col |= ((pixel & 0xFF) * rgbScale / 255);
                    col |= (((pixel >> 8) & 0xFF) * rgbScale / 255) << 8;
                    col |= (((pixel >> 16) & 0xFF) * rgbScale / 255) << 16;
                    dstRow[dstX + xx] = col;
                }
            }
        }
开发者ID:Daribon,项目名称:ClassicalSharp,代码行数:26,代码来源:LauncherWindow.Background.cs


示例8: FindPupil

        public Rectangle FindPupil(FastBitmap bitmap, Rectangle eye, double[,] angulars)
        {
            cube = new double[eye.Width, eye.Height, maxRad - minRad];
            double maxCubeval = 0;
            int maxi = 0, maxj = 0, maxr = 0;
            Parallel.For(0, eye.Width - (int)(0.5 * eye.Width), i =>
            //for (int i = 0; i < eye.Width; i++)
            {
                  for (int j = 0; j < eye.Height - 0.5 * eye.Height; j++)
                  {
                      for (int r = 0; r < maxRad - minRad; r++)
                      {
                          cube[i, j, r] = CountCubeValue(i, j, bitmap, eye, angulars);
                          if (maxCubeval <= cube[i, j, r])
                          {
                              maxi = i;
                              maxj = j;
                              maxr = r;
                              maxCubeval = cube[i, j, r];
                          }
                      }
                  }
              });

            Rectangle result = new Rectangle(eye.X + maxi, eye.Y + maxj, minRad + maxr, minRad + maxr);
            return result;
        }
开发者ID:Lena-P,项目名称:face-recognizer,代码行数:27,代码来源:PupilSearcher.cs


示例9: DrawGraph

        public FastBitmap DrawGraph(string StatName, double MaxVal)
        {
            Bitmap bitmap = new Bitmap(200, 200, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            FastBitmap bmp = new FastBitmap(bitmap);
            bmp.LockBitmap();

            ProfilerValueManager statManager = GetStat(StatName);

            double ScaleFactor = 1 / (MaxVal / 200); //We multiply by this so that the graph uses the full space

            double[] Stats = statManager.GetInfos();

            for (int x = 200; x > 0; x--)
            {
                for (int y = 200; y > 0; y--)
                {
                    //Note: we do 200-y to flip the graph on the Y axis
                    if (IsInGraphBar(x, y, Stats, ScaleFactor))
                        bmp.SetPixel(x, 200 - y, BarColor);
                    else
                    {
                        //Check whether the line needs drawn
                        if (DrawLine(y, ScaleFactor))
                            bmp.SetPixel(x, 200 - y, LineColor);
                        else
                            bmp.SetPixel(x, 200 - y, BackgroundColor);
                    }
                }
            }
            bmp.UnlockBitmap();

            return bmp;
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:33,代码来源:Profiler.cs


示例10: ImagePreview

        public ImagePreview(String path)
        {
            InitializeComponent();

            this.path = path;

            StreamReader reader = new StreamReader(path);
            Bitmap bmpTemp = (Bitmap)Bitmap.FromStream(reader.BaseStream);
            Bitmap bmpTemp2 = new Bitmap(bmpTemp.Size.Width, bmpTemp.Size.Height);
            bmpTemp2.SetResolution(bmpTemp.HorizontalResolution, bmpTemp.VerticalResolution);
            Graphics gr = Graphics.FromImage(bmpTemp2);
            gr.DrawImage(bmpTemp, new Point());
            bmpTemp.Dispose();
            reader.Close();

            bmp = new FastBitmap(bmpTemp2);
            bmp.Bitmap.SetResolution(96, 96);

            Text = path;
            ClientSize = bmp.Size;
            graphicsPanel.Left = 0;
            graphicsPanel.Top = 0;
            graphicsPanel.Size = bmp.Size;
            graphics = this.graphicsPanel.CreateGraphics();
        }
开发者ID:kemot90,项目名称:APO,代码行数:25,代码来源:ImagePreview.cs


示例11: ApplyArea

		public IBitmap ApplyArea(IArea area)
		{
			//todo: performance can be improved by only creating a bitmap the size of the area, and not the entire background.
			//This will require to change the rendering as well to offset the location
			byte zero = (byte)0;
			Bitmap output = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
			using (FastBitmap inBmp = new FastBitmap (_bitmap, ImageLockMode.ReadOnly))
			{
				using (FastBitmap outBmp = new FastBitmap (output, ImageLockMode.WriteOnly, true))
				{
					for (int y = 0; y < Height; y++)
					{
						int bitmapY = Height - y - 1;
						for (int x = 0; x < Width; x++)
						{
							System.Drawing.Color color = inBmp.GetPixel(x, bitmapY);
							byte alpha = area.IsInArea(new AGS.API.PointF(x, y)) ? color.A : zero;
							outBmp.SetPixel(x, bitmapY, System.Drawing.Color.FromArgb(alpha, color));
						}
					}
				}
			}

            return new DesktopBitmap(output, _graphics);
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:25,代码来源:DesktopBitmap.cs


示例12: FastBitmap

        public FastBitmap(FastBitmap bmp, Rectangle src)
        {
            if (bmp == null)
                throw new ArgumentNullException("bitmap");

            bitmap = new Bitmap(src.Width, src.Height, PixelFormat.Format8bppIndexed);
            bitmap.SetResolution(bitmap.HorizontalResolution, bitmap.VerticalResolution);
            levels = bmp.Levels;
            bitmap.Palette = bmp.Palette;

            Lock();

            unsafe
            {
                if (bmp != null)
                {
                    Byte* pPixel = (Byte*)bitmapData.Scan0;
                    for (int y = 0; y < bitmap.Height; y++)
                    {
                        for (int x = 0; x < bitmap.Width; x++)
                        {
                            pPixel[x] = bmp[x + src.X, y + src.Y];
                        }
                        pPixel += bitmapData.Stride;
                    }
                }
            }
        }
开发者ID:mariuszfoltak,项目名称:APO,代码行数:28,代码来源:FastBitmap.cs


示例13: ApplyFilter

        public void ApplyFilter(FastBitmap image)
        {
            const int blurRadius = 5;
            var map = new List<Color>[image.Width, image.Height];
            for (var i = 0; i < image.Width; ++i)
            {
                for (var j = 0; j < image.Height; ++j)
                {
                    for (var iInner = -blurRadius; iInner < blurRadius; ++iInner)
                    {
                        var x = i + iInner;
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= image.Width)
                        {
                            break;
                        }

                        for (var jInner = -blurRadius; jInner < blurRadius; ++jInner)
                        {
                            var y = j + jInner;
                            if (y < 0)
                            {
                                continue;
                            }
                            if (y >= image.Height)
                            {
                                break;
                            }

                            var distance = Math.Sqrt((iInner*iInner) + (jInner*jInner));
                            if (distance > blurRadius)
                            {
                                continue;
                            }

                            if (map[i, j] == null)
                            {
                                map[i, j] = new List<Color>();
                            }
                            map[i, j].Add(image.GetPixel(x, y));
                        }
                    }
                }
            }

            for (var i = 0; i < image.Width; ++i)
            {
                for (var j = 0; j < image.Height; ++j)
                {
                    var r = (int)map[i, j].Average(a => a.R);
                    var g = (int)map[i, j].Average(a => a.G);
                    var b = (int)map[i, j].Average(a => a.B);

                    image.SetPixel(i, j, r, g, b);
                }
            }
        }
开发者ID:eouw0o83hf,项目名称:pixel-place,代码行数:60,代码来源:BlurFilter.cs


示例14: GetImageWithDisplacement

        public ReturnImage GetImageWithDisplacement(FastBitmap currFrame, FastBitmap nextFrame, List<Point> edgePoints)
        {
            _nBytesPerPixel = currFrame.CCount;
            currFrame.LockBits();
            nextFrame.LockBits();
            byte[] currRgbValues = currFrame.Pixels;
            byte[] nextRgbValues = nextFrame.Pixels;
            ConcurrentDictionary<Point, Point> displacements = new ConcurrentDictionary<Point, Point>();

            Parallel.ForEach(edgePoints, (edgePoint) =>
            {
                int edgePointPos;
                List<Color> pointVicinity = GetPointVicinity(edgePoint, currRgbValues, currFrame.Width, currFrame.Height, currFrame.Stride, out edgePointPos);
                _brief = new BRIEF((POINT_WINDOW_SIDE + 1) * (POINT_WINDOW_SIDE + 1), edgePointPos);
                string vicinityDescriptor = _brief.GetImageDescriptor(pointVicinity);
                if (pointVicinity[edgePointPos] != Color.Black)
                {
                    Point nextFramePoint = FindPointDiscplacement(edgePoint, nextRgbValues, nextFrame.Width, nextFrame.Height, vicinityDescriptor, nextFrame.Stride, pointVicinity[edgePointPos]);
                    displacements.TryAdd(edgePoint, nextFramePoint);
                }
                else
                    displacements.TryAdd(edgePoint, edgePoint);
            });

            currFrame.UnlockBits();
            nextFrame.UnlockBits();

            Frame frame = GetFrameByChanell(currFrame, displacements);
            //frames.Add();
            ReturnImage image = new ReturnImage(frame, currFrame);
            return image;
        }
开发者ID:HelShurova,项目名称:MiSOI,代码行数:32,代码来源:LucasKanadeMethod.cs


示例15: Draw

        public override void Draw( IWindowInfo info, Bitmap framebuffer )
        {
            using( FastBitmap bmp = new FastBitmap( framebuffer, true ) ) {
                IntPtr scan0 = bmp.Scan0;
                int size = bmp.Width * bmp.Height * 4;

                IntPtr colorSpace = OSX.API.CGColorSpaceCreateDeviceRGB();
                IntPtr provider = OSX.API.CGDataProviderCreateWithData( IntPtr.Zero, scan0, size, IntPtr.Zero );
                const uint flags = 4 | (2 << 12);
                IntPtr image = OSX.API.CGImageCreate( bmp.Width, bmp.Height, 8, 8 * 4, bmp.Stride,
                                                     colorSpace, flags, provider, IntPtr.Zero, 0, 0 );
                IntPtr context = IntPtr.Zero;
                OSStatus err = OSX.API.QDBeginCGContext( windowPort, ref context );
                OSX.API.CheckReturn( err );

                OSX.HIRect rect = new OSX.HIRect();
                rect.Origin.X = 0; rect.Origin.Y = 0;
                rect.Size.X = bmp.Width; rect.Size.Y = bmp.Height;

                OSX.API.CGContextDrawImage( context, rect, image );
                OSX.API.CGContextSynchronize( context );
                err = OSX.API.QDEndCGContext( windowPort, ref context );
                OSX.API.CheckReturn( err );

                OSX.API.CGImageRelease( image );
                OSX.API.CGDataProviderRelease( provider );
                OSX.API.CGColorSpaceRelease( colorSpace );
            }
        }
开发者ID:andrewphorn,项目名称:ClassicalSharp,代码行数:29,代码来源:PlatformDrawer.cs


示例16: GrayLevelDiff

        public static int[] GrayLevelDiff(FastBitmap bmp, int dx, int dy, Point begin, Point end)
        {
            int xbegin, ybegin, xend, yend, difference;
            int[] lh = new int[bmp.Levels];
            int[] hv = new int[bmp.Levels];

            if (dx < 0) xbegin = begin.X - dx;
            else xbegin = begin.X;
            if (dx > 0) xend = end.X - dx;
            else xend = end.X;
            if (dy < 0) ybegin = begin.Y - dy;
            else ybegin = begin.Y;
            if (dy > 0) yend = end.Y - dy;
            else yend = end.Y;

            for (int y = ybegin; y < yend; y++)
            {
                for (int x = xbegin; x < xend; x++)
                {
                    int color1 = bmp[x, y];
                    int color2 = bmp[x + dx, y + dy];
                    difference = Math.Abs(color1 - color2);
                    lh[difference]++;
                }
            }

            for (int i = 0; i < bmp.Levels; i++)
                hv[i] = (int)(lh[i] / ((float)(end.X - begin.X - Math.Abs(dx)) * (float)(end.Y - begin.Y - Math.Abs(dy))) * 1000000);

            return hv;
        }
开发者ID:mariuszfoltak,项目名称:APO,代码行数:31,代码来源:HistDiffForm.cs


示例17: AverageColor

        public static unsafe Color AverageColor(Bitmap img)
        {
            #if true
            if (img.Width > avgColorPxSize && img.Height > avgColorPxSize)
            {
                img = Resize(img, avgColorPxSize, avgColorPxSize);
            }
            #endif

            double r = 0, g = 0, b = 0;

            FastBitmap fast = new FastBitmap(img);
            fast.LockImage();
            FastBitmap.PixelData* px = fast.GetPixelData(0, 0);

            for (int i = 0; i < img.Width * img.Height; ++i)
            {
                r += px->red;
                g += px->green;
                b += px->blue;
                ++px;
            }

            fast.UnlockImage();

            r /= (img.Width * img.Height);
            g /= (img.Width * img.Height);
            b /= (img.Width * img.Height);

            return Color.FromArgb((int)r, (int)g, (int)b);
        }
开发者ID:kalimaul,项目名称:specalg,代码行数:31,代码来源:Images.cs


示例18: UpdateState

        public void UpdateState( TerrainAtlas2D atlas2D )
        {
            int maxVerSize = Math.Min( 4096, graphics.MaxTextureDimensions );
            int verElements = maxVerSize / atlas2D.elementSize;
            int totalElements = TerrainAtlas2D.RowsCount * TerrainAtlas2D.ElementsPerRow;
            int elemSize = atlas2D.elementSize;

            int atlasesCount = Utils.CeilDiv( totalElements, verElements );
            usedElementsPerAtlas1D = Math.Min( verElements, totalElements );
            int atlas1DHeight = Utils.NextPowerOf2( usedElementsPerAtlas1D * atlas2D.elementSize );

            int index = 0;
            TexIds = new int[atlasesCount];
            Utils.LogDebug( "Loaded new atlas: {0} bmps, {1} per bmp", atlasesCount, usedElementsPerAtlas1D );

            using( FastBitmap atlas = new FastBitmap( atlas2D.AtlasBitmap, true ) ) {
                for( int i = 0; i < TexIds.Length; i++ ) {
                    Bitmap atlas1d = new Bitmap( atlas2D.elementSize, atlas1DHeight );
                    using( FastBitmap dst = new FastBitmap( atlas1d, true ) ) {
                        for( int y_1D = 0; y_1D < usedElementsPerAtlas1D; y_1D++ ) {
                            int x = index & 0x0F;
                            int y = index >> 4;
                            FastBitmap.MovePortion( x * elemSize, y * elemSize, 0, y_1D * elemSize, atlas, dst, elemSize );
                            index++;
                        }
                        TexIds[i] = graphics.CreateTexture( dst );
                    }
                    atlas1d.Dispose();
                }
            }
            elementsPerBitmap = atlas1DHeight / atlas2D.elementSize;
            invElementSize = 1f / elementsPerBitmap;
        }
开发者ID:Hetal728,项目名称:ClassicalSharp,代码行数:33,代码来源:TerrainAtlas1D.cs


示例19: Integrator

 public Integrator(FastBitmap bitmap)
 {
     IntegralView = new int[bitmap.Width, bitmap.Height];
     SquareIntegralView = new int[bitmap.Width, bitmap.Height];
     for (int x = 0; x < bitmap.Width; ++x)
     {
         for (int y = 0; y < bitmap.Height; ++y)
         {
             IntegralView[x, y] = bitmap[x, y];
             SquareIntegralView[x, y] = bitmap[x, y]*bitmap[x, y];
             if (x-1 >=0)
             {
                 IntegralView[x, y] += IntegralView[x - 1, y];
                 SquareIntegralView[x, y] += SquareIntegralView[x - 1, y];
             }
             if (y-1 >= 0)
             {
                 IntegralView[x, y] += IntegralView[x, y -1];
                 SquareIntegralView[x, y] += SquareIntegralView[x, y - 1];
             }
             if (x - 1 >= 0 && y - 1 >=0)
             {
                 IntegralView[x, y] -= IntegralView[x - 1, y - 1];
                 SquareIntegralView[x, y] -= SquareIntegralView[x - 1, y - 1];
             }
         }
     }
 }
开发者ID:Lena-P,项目名称:face-recognizer,代码行数:28,代码来源:Integrator.cs


示例20: SetFontBitmap

 public override void SetFontBitmap( Bitmap bmp )
 {
     fontBmp = bmp;
     boxSize = fontBmp.Width / 16;
     fontPixels = new FastBitmap( fontBmp, true );
     CalculateTextWidths();
 }
开发者ID:Daribon,项目名称:ClassicalSharp,代码行数:7,代码来源:GdiPlusDrawer2D.TextMC.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FastColoredTextBox类代码示例发布时间:2022-05-24
下一篇:
C# FarseerPhysics类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap