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

C# PixelBuffer类代码示例

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

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



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

示例1: SaveFromMemory

        private static void SaveFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream, ImageFormat imageFormat)
        {
            using (var bitmap = new Bitmap(description.Width, description.Height))
            {
                var sourceArea = new Rectangle(0, 0, bitmap.Width, bitmap.Height);

                // Lock System.Drawing.Bitmap
                var bitmapData = bitmap.LockBits(sourceArea, ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                try
                {
                    // Copy memory
                    if (description.Format == PixelFormat.R8G8B8A8_UNorm || description.Format == PixelFormat.R8G8B8A8_UNorm_SRgb)
                        CopyMemoryBGRA(bitmapData.Scan0, pixelBuffers[0].DataPointer, pixelBuffers[0].BufferStride);
                    else if (description.Format == PixelFormat.B8G8R8A8_UNorm || description.Format == PixelFormat.B8G8R8A8_UNorm_SRgb)
                        Utilities.CopyMemory(bitmapData.Scan0, pixelBuffers[0].DataPointer, pixelBuffers[0].BufferStride);
                    else
                        throw new NotSupportedException(string.Format("Pixel format [{0}] is not supported", description.Format));
                }
                finally
                {
                    bitmap.UnlockBits(bitmapData);
                }

                // Save
                bitmap.Save(imageStream, imageFormat);
            }
        }
开发者ID:joewan,项目名称:xenko,代码行数:28,代码来源:StandardImageHelper.Windows.cs


示例2: SaveFromMemory

        private static void SaveFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream, Bitmap.CompressFormat imageFormat)
        {
            var colors = pixelBuffers[0].GetPixels<int>();

            using (var bitmap = Bitmap.CreateBitmap(description.Width, description.Height, Bitmap.Config.Argb8888))
            {
                var pixelData = bitmap.LockPixels();
                var sizeToCopy = colors.Length * sizeof(int);

                unsafe
                {
                    fixed (int* pSrc = colors)
                    {
                        // Copy the memory
                        if (description.Format == PixelFormat.R8G8B8A8_UNorm || description.Format == PixelFormat.R8G8B8A8_UNorm_SRgb)
                        {
                            CopyMemoryBGRA(pixelData, (IntPtr)pSrc, sizeToCopy);
                        }
                        else if (description.Format == PixelFormat.B8G8R8A8_UNorm || description.Format == PixelFormat.B8G8R8A8_UNorm_SRgb)
                        {
                            Utilities.CopyMemory(pixelData, (IntPtr)pSrc, sizeToCopy);
                        }
                        else
                        {
                            throw new NotSupportedException(string.Format("Pixel format [{0}] is not supported", description.Format));
                        }
                    }
                }

                bitmap.UnlockPixels();
                bitmap.Compress(imageFormat, 100, imageStream);
            }
        }
开发者ID:cg123,项目名称:xenko,代码行数:33,代码来源:StandardImageHelper.Android.cs


示例3: SaveFromMemory

 private static void SaveFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream, Bitmap.CompressFormat imageFormat)
 {
     var colors = pixelBuffers[0].GetPixels<int>();
     using (var bitmap = Bitmap.CreateBitmap(colors, description.Width, description.Height, Bitmap.Config.Argb8888))
     {
         bitmap.Compress(imageFormat, 0, imageStream);
     }
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:8,代码来源:StandardImageHelper.Android.cs


示例4: AlphaBlend

 public virtual void AlphaBlend(int x, int y, int width, int height,
         PixelBuffer bitmap, int srcX, int srcY, int srcWidth, int srcHeight,
         byte alpha)
 {
     if (null != AlphaBlendHandler)
         AlphaBlendHandler(x, y, width, height,
             bitmap, srcX, srcY, srcWidth, srcHeight, alpha);
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:8,代码来源:SpaceControlDelegate.cs


示例5: UISurface

        protected UISurface(string title, int x, int y, int width, int height, Guid uniqueID)
        {
            fTitle = title;
            fFrame = new RECT(x, y, width, height);
            fBackingBuffer = new PixelBuffer(width, height);
            fGraphDelegate = new GraphPortDelegate();
            fGraphDelegate.AddGraphPort(fBackingBuffer.GraphPort);

            fUniqueID = uniqueID;

            UISurface.gSurfaces.Add(uniqueID, this);
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:12,代码来源:UISurface.cs


示例6: PassiveSpace

        public PassiveSpace(string title, RECT aframe)
            : base(title, aframe)
        {
            fBackingBuffer = new PixelBuffer(Frame.Width, aframe.Height);

            fWrappedGraphPort = new GraphPortDelegate();
            fWrappedGraphPort.AddGraphPort(fBackingBuffer.GraphPort);
            fWrappedGraphPort.AddGraphPort(base.GraphPort);

            // Add the channel for commands
            fSessionManager = new SessionManager();
            fControlChannel = new SpaceControlChannel(fSessionManager, fSessionManager.UniqueSessionName, this);
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:13,代码来源:PassiveSpace.cs


示例7: BitBlt

        public override void BitBlt(int x, int y, PixelBuffer pixBuff)
        {
            // Create a buffer
            // It has to be big enough for the bitmap data, as well as the x,y, and command
            int dataSize = pixBuff.Pixels.Stride * pixBuff.Pixels.Height;
            BufferChunk chunk = new BufferChunk(dataSize + 128);

            // now put the basic command and simple components in
            chunk += SpaceControlChannel.SC_BitBlt;
            CodecUtils.Pack(chunk, x, y);
            CodecUtils.Pack(chunk, pixBuff.Pixels.Width, pixBuff.Pixels.Height);
            chunk += dataSize;

            // Finally, copy in the data
            chunk.CopyFrom(pixBuff.Pixels.Data, dataSize);

            PackCommand(chunk);
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:18,代码来源:SpaceCommandEncoder.cs


示例8: SaveFromMemory

        public static void SaveFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, System.IO.Stream imageStream)
        {
            var stream = new BinarySerializationWriter(imageStream);

            // Write magic code
            stream.Write(MagicCode);

            // Write image header
            imageDescriptionSerializer.Serialize(ref description, ArchiveMode.Serialize, stream);

            // Write total size
            int totalSize = 0;
            foreach (var pixelBuffer in pixelBuffers)
                totalSize += pixelBuffer.BufferStride;

            stream.Write(totalSize);

            // Write buffers contiguously
            foreach (var pixelBuffer in pixelBuffers)
            {
                stream.Serialize(pixelBuffer.DataPointer, pixelBuffer.BufferStride);
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:23,代码来源:ImageHelper.cs


示例9: PrepareHeightMap8Bit

 private static void PrepareHeightMap8Bit(MyHeightmapFace map, PixelBuffer imageData)
 {
     for (int y = 0; y < map.Resolution; y++)
     {
         for (int x = 0; x < map.Resolution; x++)
         {
             map.SetValue(x, y, (ushort)(imageData.GetPixel<byte>(x, y) * 256));
         }
     }
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:10,代码来源:MyHeightMapLoadingSystem.cs


示例10: Save

        /// <summary>
        /// Saves this instance to a stream.
        /// </summary>
        /// <param name="pixelBuffers">The buffers to save.</param>
        /// <param name="count">The number of buffers to save.</param>
        /// <param name="description">Global description of the buffer.</param>
        /// <param name="imageStream">The destination stream.</param>
        /// <param name="fileType">Specify the output format.</param>
        /// <remarks>This method support the following format: <c>dds, bmp, jpg, png, gif, tiff, wmp, tga</c>.</remarks>
        internal static void Save(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream, ImageFileType fileType)
        {
            foreach (var loadSaveDelegate in loadSaveDelegates)
            {
                if (loadSaveDelegate.FileType == fileType)
                {
                    loadSaveDelegate.Save(pixelBuffers, count, description, imageStream);
                    return;
                }

            }
            throw new NotSupportedException("This file format is not yet implemented.");
        }
开发者ID:Julyuary,项目名称:paradox,代码行数:22,代码来源:Image.cs


示例11: SetShaderParameters

        private bool SetShaderParameters(DeviceContext deviceContext, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix, ShaderResourceView texture, Vector4 pixelColor)
        {
            try
            {
                DataStream mappedResource;

                #region Matrix Constant Buffer
                // Transpose the matrices to prepare them for shader.
                worldMatrix.Transpose();
                viewMatrix.Transpose();
                projectionMatrix.Transpose();

                // Lock the constant buffer so it can be written to.
                deviceContext.MapSubresource(ConstantMatrixBuffer, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None, out mappedResource);

                // Copy the matrices into the constant buffer.
                var matrixBuffer = new MatrixBuffer()
                {
                    world = worldMatrix,
                    view = viewMatrix,
                    projection = projectionMatrix
                };

                mappedResource.Write(matrixBuffer);

                // Unlock the constant buffer.
                deviceContext.UnmapSubresource(ConstantMatrixBuffer, 0);

                // Set the position of the constant buffer in the vertex shader.
                var bufferNumber = 0;

                // Finally set the constant buffer in the vertex shader with the updated values.
                deviceContext.VertexShader.SetConstantBuffer(bufferNumber, ConstantMatrixBuffer);

                // Set shader resource in the pixel shader.
                deviceContext.PixelShader.SetShaderResource(0, texture);
                #endregion

                #region Pixel Constant Shader
                // Lock the pixel constant buffer so it can be written to.
                deviceContext.MapSubresource(ConstantPixelBuffer, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None, out mappedResource);

                // Copy the matrices into the constant buffer.
                var pixelBuffer = new PixelBuffer()
                {
                    pixelColor = pixelColor
                };

                mappedResource.Write(pixelBuffer);

                // Unlock the constant buffer.
                deviceContext.UnmapSubresource(ConstantPixelBuffer, 0);

                // Set the position of the constant buffer in the vertex shader.
                bufferNumber = 0;

                // Finally set the constant buffer in the vertex shader with the updated values.
                deviceContext.PixelShader.SetConstantBuffer(bufferNumber, ConstantPixelBuffer);
                #endregion

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:nyx1220,项目名称:sharpdx-examples,代码行数:67,代码来源:FontShader.cs


示例12: OnAlphaBlend

 public virtual void OnAlphaBlend(int x, int y, int width, int height,
         PixelBuffer bitmap, int srcX, int srcY, int srcWidth, int srcHeight,
         byte alpha)
 {
     if (null != OnAlphaBlendEvent)
         OnAlphaBlendEvent(x, y, width, height,
             bitmap, srcX, srcY, srcWidth, srcHeight, alpha);
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:8,代码来源:SpaceControlDelegate.cs


示例13: CreateBitmap

 public virtual PixelBuffer CreateBitmap(int width, int height)
 {
     PixelBuffer newOne = new PixelBuffer(width, height);
     
     return newOne;
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:6,代码来源:GDIGeometryRenderer.cs


示例14: DrawBitmap

 public virtual void DrawBitmap(PixelBuffer img, Rectangle srcRect, Rectangle dstRect)
 {
     AlphaBlend(dstRect.Left, dstRect.Top, dstRect.Width, dstRect.Height,
             img.DCHandle, srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height,
             img.Alpha);
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:6,代码来源:GDIGeometryRenderer.cs


示例15: EncodeMultiframe

        //-------------------------------------------------------------------------------------
        // Encodes an image array
        //-------------------------------------------------------------------------------------
        private static void EncodeMultiframe( PixelBuffer[] images, int count, WICFlags flags, Guid guidContainerFormat, Stream stream )
        {
            if ( images.Length < 2 )
                throw new ArgumentException("Cannot encode to multiple frame. Image doesn't have multiple frame");

            using (var encoder = new BitmapEncoder(Factory, guidContainerFormat))
            {
                using (var eInfo = encoder.EncoderInfo)
                {
                    if (!eInfo.IsMultiframeSupported)
                        throw new NotSupportedException("Cannot encode to multiple frame. Format is not supporting multiple frame");
                }

                encoder.Initialize(stream);

                for (int i = 0; i < Math.Min(images.Length, count); i++)
                {
                    var pixelBuffer = images[i];
                    using (var frame = new BitmapFrameEncode(encoder))
                        EncodeImage(pixelBuffer, flags, frame);
                }

                encoder.Commit();
            }
        }
开发者ID:numo16,项目名称:SharpDX,代码行数:28,代码来源:WICHelper.cs


示例16: EncodeSingleFrame

 private static void EncodeSingleFrame( PixelBuffer pixelBuffer, WICFlags flags, Guid guidContainerFormat, Stream stream )
 {
     using (var encoder = new BitmapEncoder(Factory, guidContainerFormat, stream))
     {
         using (var frame = new BitmapFrameEncode(encoder))
         {
             if (guidContainerFormat == ContainerFormatGuids.Bmp)
             {
                 try
                 {
                     frame.Options.Set("EnableV5Header32bppBGRA", true);
                 }
                 catch
                 {
                 }
             }
             EncodeImage(pixelBuffer, flags, frame);
             encoder.Commit();
         }
     }
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:21,代码来源:WICHelper.cs


示例17: SaveTiffToWICMemory

 public static void SaveTiffToWICMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
 {
     SaveToWICMemory(pixelBuffers, count, WICFlags.AllFrames, ImageFileType.Tiff, imageStream);
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:4,代码来源:WICHelper.cs


示例18: BitBlt

	// Generalized bit block transfer
	// Can transfer from any device context to this one.
    public virtual void BitBlt(int x, int y, PixelBuffer bitmap)
    {
        bool retValue = BitBlt(x, y, bitmap.Width, bitmap.Height, 
            bitmap.DCHandle, 0, 0, TernaryRasterOps.SRCCOPY);
    }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:7,代码来源:GDIGeometryRenderer.cs


示例19: SaveWmpToWICMemory

 public static void SaveWmpToWICMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
 {
     SaveToWICMemory(pixelBuffers, 1, WICFlags.None, ImageFileType.Wmp, imageStream);
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:4,代码来源:WICHelper.cs


示例20: OnCopyPixels

 public virtual void OnCopyPixels(int x, int y, int width, int height, PixelBuffer pixBuff)
 {
     if (null != OnCopyPixelsEvent)
         OnCopyPixelsEvent(x, y, width, height, pixBuff);
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:5,代码来源:SpaceControlDelegate.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# PixelFormat类代码示例发布时间:2022-05-24
下一篇:
C# Pixel类代码示例发布时间: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