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


C# PixelFormat类代码示例

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


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

示例1: GetHistogramEXT

		public static void GetHistogramEXT(HistogramTargetEXT target, bool reset, PixelFormat format, PixelType type, IntPtr values)
		{
			Debug.Assert(Delegates.pglGetHistogramEXT != null, "pglGetHistogramEXT not implemented");
			Delegates.pglGetHistogramEXT((Int32)target, reset, (Int32)format, (Int32)type, values);
			CallLog("glGetHistogramEXT({0}, {1}, {2}, {3}, 0x{4})", target, reset, format, type, values.ToString("X8"));
			DebugCheckErrors();
		}
开发者ID:MagmaiKH,项目名称:OpenGL.Net,代码行数:7,代码来源:Gl.EXT_histogram.cs

示例2: Quantize

        /// <summary>The quantize.</summary>
        /// <param name="image">The image.</param>
        /// <param name="pixelFormat">The pixel format.</param>
        /// <param name="useDither">The use dither.</param>
        /// <returns>The quantized image with the recalculated color palette.</returns>
        public static Bitmap Quantize(Image image, PixelFormat pixelFormat, bool useDither)
        {
            Bitmap tryBitmap = image as Bitmap;

            if (tryBitmap != null && tryBitmap.PixelFormat == PixelFormat.Format32bppArgb)
            {
                // The image passed to us is ALREADY a bitmap in the right format. No need to create
                // a copy and work from there.
                return DoQuantize(tryBitmap, pixelFormat, useDither);
            }

            // We use these values a lot
            int width = image.Width;
            int height = image.Height;
            Rectangle sourceRect = Rectangle.FromLTRB(0, 0, width, height);

            // Create a 24-bit rgb version of the source image
            using (Bitmap bitmapSource = new Bitmap(width, height, PixelFormat.Format32bppArgb))
            {
                using (Graphics grfx = Graphics.FromImage(bitmapSource))
                {
                    grfx.DrawImage(image, sourceRect, 0, 0, width, height, GraphicsUnit.Pixel);
                }

                return DoQuantize(bitmapSource, pixelFormat, useDither);
            }
        }
开发者ID:jesperordrup,项目名称:ImageProcessor,代码行数:32,代码来源:ColorQuantizer.cs

示例3: BytesPerPixel

        public static int BytesPerPixel(PixelFormat pixelFormat)
        {
            int bytesPerPixel;

            // calculate bytes per pixel
            switch ( pixelFormat )
            {
                case PixelFormat.Format8bppIndexed:
                    bytesPerPixel = 1;
                    break;
                case PixelFormat.Format16bppGrayScale:
                    bytesPerPixel = 2;
                    break;
                case PixelFormat.Format24bppRgb:
                    bytesPerPixel = 3;
                    break;
                case PixelFormat.Format32bppRgb:
                case PixelFormat.Format32bppArgb:
                case PixelFormat.Format32bppPArgb:
                    bytesPerPixel = 4;
                    break;
                case PixelFormat.Format48bppRgb:
                    bytesPerPixel = 6;
                    break;
                case PixelFormat.Format64bppArgb:
                case PixelFormat.Format64bppPArgb:
                    bytesPerPixel = 8;
                    break;
                default:
                    throw new UnsupportedImageFormatException( "Can not create image with specified pixel format." );
            }
            return bytesPerPixel;
        }
开发者ID:tdhieu,项目名称:iSpy,代码行数:33,代码来源:Tools.cs

示例4: ToBitmap

        /// <summary>
        /// Converts a depth frame to the corresponding System.Drawing.Bitmap.
        /// </summary>
        /// <param name="frame">The specified depth frame.</param>
        /// <param name="format">Pixel format of the depth frame.</param>
        /// <param name="mode">Depth frame mode.</param>
        /// <returns>The corresponding System.Drawing.Bitmap representation of the depth frame.</returns>
        public static Bitmap ToBitmap(this DepthImageFrame frame, PixelFormat format, DepthImageMode mode)
        {
            short[] pixelData = new short[frame.PixelDataLength];
            frame.CopyPixelDataTo(pixelData);

            byte[] pixels;

            switch (mode)
            {
                case DepthImageMode.Raw:
                    pixels = GenerateRawFrame(frame, pixelData);
                    break;
                case DepthImageMode.Dark:
                    pixels = GenerateDarkFrame(frame, pixelData);
                    break;
                case DepthImageMode.Colors:
                    pixels = GenerateColoredFrame(frame, pixelData);
                    break;
                default:
                    pixels = GenerateRawFrame(frame, pixelData);
                    break;
            }

            return pixels.ToBitmap(frame.Width, frame.Height, format);
        }
开发者ID:Naiit,项目名称:Vitruvius,代码行数:32,代码来源:DepthExtensions.cs

示例5: VideoPacketDecoderWorker

 public VideoPacketDecoderWorker(PixelFormat pixelFormat, bool skipFrames, Action<VideoFrame> onFrameDecoded)
 {
   _pixelFormat = pixelFormat;
   _skipFrames = skipFrames;
   _onFrameDecoded = onFrameDecoded;
   _packetQueue = new ConcurrentQueue<VideoPacket>();
 }
开发者ID:guozanhua,项目名称:OculusArDroneKinect,代码行数:7,代码来源:VideoPacketDecoderWorker.cs

示例6: Build1DMipmap

 Int32 Build1DMipmap(TextureTarget target, Int32 internalFormat, Int32 width, PixelFormat format, PixelType type, IntPtr data)
 {
     unsafe
     {
         return Delegates.gluBuild1DMipmaps((TextureTarget)target, (Int32)internalFormat, (Int32)width, (PixelFormat)format, (PixelType)type, (IntPtr)data);
     }
 }
开发者ID:dakahler,项目名称:alloclave,代码行数:7,代码来源:Glu.cs

示例7: Snip

 /// <summary>
 /// Takes screenshot of the window (supports multiple monitors) and then lets user to select the wanted area and returns that area.
 /// Also returns the rectangle of the selected part inside of the window.
 /// </summary>
 public static Image Snip(IntPtr hWnd, out Rectangle rect, PixelFormat format = PixelFormat.Format24bppRgb) {
     NativeWin32.SetForegroundWindow(hWnd);
     
     Rect r;
     if (!NativeWin32.GetWindowRect(hWnd, out r)) {
         rect = Rectangle.Empty;
         return null;
     } 
     rect = new Rectangle(Convert.ToInt32(r.X), Convert.ToInt32(r.Y), Convert.ToInt32(r.Width), Convert.ToInt32(r.Height));
     
     var bmp = ScreenShot.Create(hWnd);
     Graph = Graphics.FromImage(bmp);
     Graph.SmoothingMode = SmoothingMode.None;
     
     using (var snipper = new SnippingTool(bmp) {SpecificWindowMode = true}) {
         snipper.Location = new Point(rect.Left, rect.Top);
         NativeWin32.SetForegroundWindow(snipper.Handle);
          
         if (snipper.ShowDialog() == DialogResult.OK) {
             rect = snipper.rcSelect;
             return snipper.Image;
         }
     }
     rect = Rectangle.Empty;
     return null;
 }
开发者ID:Nucs,项目名称:nlib,代码行数:30,代码来源:SnippingTool.cs

示例8: IsPixelFormatSupportedByGraphicsObject

        /// <summary>
        /// Determines whether [is pixel format supported by graphics object] [the specified format].
        /// </summary>
        /// <param name="format">The format.</param>
        /// <returns><c>true</c> if [is pixel format supported by graphics object] [the specified format]; otherwise, <c>false</c>.</returns>
        public static bool IsPixelFormatSupportedByGraphicsObject(PixelFormat format)
        {
            // http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx

            if ((format & PixelFormat.Indexed) == PixelFormat.Indexed)
            {
                return false;
            }
            if ((format & PixelFormat.Undefined) == PixelFormat.Undefined)
            {
                return false;
            }
            if ((format & PixelFormat.DontCare) == PixelFormat.DontCare)
            {
                return false;
            }
            if ((format & PixelFormat.Format16bppArgb1555) == PixelFormat.Format16bppArgb1555)
            {
                return false;
            }
            if ((format & PixelFormat.Format16bppGrayScale) == PixelFormat.Format16bppGrayScale)
            {
                return false;
            }

            return true;
        }
开发者ID:Kampari,项目名称:MediaBrowser,代码行数:32,代码来源:ImageExtensions.cs

示例9: Build1DMipmapLevel

 Int32 Build1DMipmapLevel(TextureTarget target, Int32 internalFormat, Int32 width, PixelFormat format, PixelType type, Int32 level, Int32 @base, Int32 max, IntPtr data)
 {
     unsafe
     {
         return Delegates.gluBuild1DMipmapLevels((TextureTarget)target, (Int32)internalFormat, (Int32)width, (PixelFormat)format, (PixelType)type, (Int32)level, (Int32)@base, (Int32)max, (IntPtr)data);
     }
 }
开发者ID:dakahler,项目名称:alloclave,代码行数:7,代码来源:Glu.cs

示例10: PixelFormats

 static PixelFormats()
 {
     Bgr101010 = new PixelFormat("Bgr101010", 32);
     Bgr24 = new PixelFormat("Bgr24", 24);
     Bgr32 = new PixelFormat("Bgr32", 32);
     Bgr555 = new PixelFormat("Bgr555", 16);
     Bgr565 = new PixelFormat("Bgr565", 16);
     Bgra32 = new PixelFormat("Bgra32", 32);
     BlackWhite = new PixelFormat("BlackWhite", 1);
     Cmyk32 = new PixelFormat("Cmyk32", 32);
     Default = new PixelFormat("Default", 0);
     Gray16 = new PixelFormat("Gray16", 16);
     Gray2 = new PixelFormat("Gray2", 2);
     Gray32Float = new PixelFormat("Gray32Float", 32);
     Gray4 = new PixelFormat("Gray4", 4);
     Gray8 = new PixelFormat("Gray8", 8);
     Indexed1 = new PixelFormat("Indexed1", 1);
     Indexed2 = new PixelFormat("Indexed2", 2);
     Indexed4 = new PixelFormat("Indexed4", 4);
     Indexed8 = new PixelFormat("Indexed8", 8);
     Pbgra32 = new PixelFormat("Pbgra32", 32);
     Prgba128Float = new PixelFormat("Prgba128Float", 128);
     Prgba64 = new PixelFormat("Prgba64", 64);
     Rgb128Float = new PixelFormat("Rgb128Float", 128);
     Rgb24 = new PixelFormat("Rgb24", 24);
     Rgb48 = new PixelFormat("Rgb48", 48);
     Rgba128Float = new PixelFormat("Rgba128Float", 128);
     Rgba64 = new PixelFormat("Rgba64", 64);
 }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:29,代码来源:PixelFormats.cs

示例11: GetConvolutionFilterEXT

		public static void GetConvolutionFilterEXT(ConvolutionTargetEXT target, PixelFormat format, PixelType type, IntPtr image)
		{
			Debug.Assert(Delegates.pglGetConvolutionFilterEXT != null, "pglGetConvolutionFilterEXT not implemented");
			Delegates.pglGetConvolutionFilterEXT((Int32)target, (Int32)format, (Int32)type, image);
			CallLog("glGetConvolutionFilterEXT({0}, {1}, {2}, 0x{3})", target, format, type, image.ToString("X8"));
			DebugCheckErrors();
		}
开发者ID:MagmaiKH,项目名称:OpenGL.Net,代码行数:7,代码来源:Gl.EXT_convolution.cs

示例12: EmptyTexture2D

 public EmptyTexture2D( int width, int height, int channels, PixelFormat format )
 {
     this.Width = width;
     this.Height = height;
     this.Channels = channels;
     this.Format = format;
 }
开发者ID:werwolfby,项目名称:Managed-OpenGL,代码行数:7,代码来源:EmptyTexture2D.cs

示例13: region

		public static Bitmap region(Rectangle area, bool cursor = true, PixelFormat pixel_format = PixelFormat.Format32bppRgb) {
			var bmp = new Bitmap(area.Width - 2, area.Height - 2, pixel_format);
			Graphics g = Graphics.FromImage(bmp);
			g.CopyFromScreen(area.X, area.Y, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
			
			if (cursor)
			{
				CURSORINFO cursor_info;
				cursor_info.cbSize = Marshal.SizeOf(typeof (CURSORINFO));

				if (GetCursorInfo(out cursor_info))
					if (cursor_info.flags == (int)0x0001)
					{
						var hdc = g.GetHdc();
						DrawIconEx(
                            hdc, cursor_info.ptScreenPos.x - area.X, cursor_info.ptScreenPos.y - area.Y, cursor_info.hCursor,
                            0, 0, 0, IntPtr.Zero, (int)0x0003
                        );
						g.ReleaseHdc();
					}
			}
			
			g.Dispose();
			return bmp;
		}
开发者ID:Dryabadi,项目名称:WebMCam,代码行数:25,代码来源:Image_Capture.cs

示例14: DisplayMode

 /// <summary>
 /// Initializes a new instance of the <see cref="DisplayMode"/> class.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="refreshRate">The refresh rate.</param>
 public DisplayMode(PixelFormat format, int width, int height, Rational refreshRate)
 {
     Format = format;
     Width = width;
     Height = height;
     RefreshRate = refreshRate;
 }
开发者ID:cg123,项目名称:xenko,代码行数:14,代码来源:DisplayMode.cs

示例15: ToBitmap

        /// <summary>
        /// Converts a color frame to a System.Drawing.Bitmap.
        /// </summary>
        /// <param name="frame">A ColorImageFrame generated from a Kinect sensor.</param>
        /// <param name="format">Image format.</param>
        /// <returns>The specified frame in a System.Drawing.Bitmap format.</returns>
        public static Bitmap ToBitmap(this ColorImageFrame frame, PixelFormat format)
        {
            byte[] pixels = new byte[frame.PixelDataLength];
            frame.CopyPixelDataTo(pixels);

            return pixels.ToBitmap(frame.Width, frame.Height, format);
        }
开发者ID:nerndt,项目名称:iRobotKinect,代码行数:13,代码来源:ColorExtensions.cs


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