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


C# Surface.GetPoint方法代码示例

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


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

示例1: CompressImage

		// ---------------------------------------------------------------------------------------
		//	CompressImage
		// ---------------------------------------------------------------------------------------
		//
		//	Params
		//		inputSurface	:	Source byte array containing RGBA pixel data
		//		flags			:	Flags for squish compression control
		//
		//	Return	
		//		blockData		:	Array of bytes containing compressed blocks
		//
		// ---------------------------------------------------------------------------------------

		internal static byte[] CompressImage( Surface inputSurface, int squishFlags, ProgressFn progressFn )
		{
			// We need the input to be in a byte array for squish.. so create one.
			byte[]	pixelData	= new byte[ inputSurface.Width * inputSurface.Height * 4 ];

			for ( int y = 0; y < inputSurface.Height; y++ )
			{
				for ( int x = 0; x < inputSurface.Width; x++ )
				{
					ColorBgra	pixelColour = inputSurface.GetPoint( x, y );
					int			pixelOffset	= ( y * inputSurface.Width * 4 ) + ( x * 4 );
						
					pixelData[ pixelOffset + 0 ]	= pixelColour.R;
					pixelData[ pixelOffset + 1 ]	= pixelColour.G;
					pixelData[ pixelOffset + 2 ]	= pixelColour.B;
					pixelData[ pixelOffset + 3 ]	= pixelColour.A;
				}
			}

			// Compute size of compressed block area, and allocate 
			int blockCount = ( ( inputSurface.Width + 3 )/4 ) * ( ( inputSurface.Height + 3 )/4 );
			int blockSize = ( ( squishFlags & ( int )DdsSquish.SquishFlags.kDxt1 ) != 0 ) ? 8 : 16;

			// Allocate room for compressed blocks
			byte[]	blockData		= new byte[ blockCount * blockSize ];
	
			// Invoke squish::CompressImage() with the required parameters
			CallCompressImage( pixelData, inputSurface.Width, inputSurface.Height, blockData, squishFlags, progressFn );
				
			// Return our block data to caller..
			return	blockData;	
		}
开发者ID:herbqiao,项目名称:paint.net,代码行数:45,代码来源:DdsSquish.cs

示例2: SuperSamplingFitSurface

        /// <summary>
        /// Fits the source surface to this surface using super sampling. If the source surface is less wide
        /// or less tall than this surface (i.e. magnification), bicubic resampling is used instead. If either
        /// the source or destination has a dimension that is only 1 pixel, nearest neighbor is used.
        /// </summary>
        /// <param name="source">The surface to read pixels from.</param>
        /// <param name="dstRoi">The rectangle to clip rendering to.</param>
        /// <remarks>This method was implemented with correctness, not performance, in mind.</remarks>
        public void SuperSamplingFitSurface(Surface source, Rectangle dstRoi)
        {
            if (source.Width == Width && source.Height == Height)
            {
                CopySurface(source);
            }
            else if (source.Width <= Width || source.Height <= Height)
            {
                if (source.width < 2 || source.height < 2 || this.width < 2 || this.height < 2)
                {
                    this.NearestNeighborFitSurface(source, dstRoi);
                }
                else
                {
                    this.BicubicFitSurface(source, dstRoi);
                }
            }
            else unsafe
            {
                Rectangle dstRoi2 = Rectangle.Intersect(dstRoi, this.Bounds);

                for (int dstY = dstRoi2.Top; dstY < dstRoi2.Bottom; ++dstY)
                {
                    double srcTop = (double)(dstY * source.height) / (double)height;
                    double srcTopFloor = Math.Floor(srcTop);
                    double srcTopWeight = 1 - (srcTop - srcTopFloor);
                    int srcTopInt = (int)srcTopFloor;

                    double srcBottom = (double)((dstY + 1) * source.height) / (double)height;
                    double srcBottomFloor = Math.Floor(srcBottom - 0.00001);
                    double srcBottomWeight = srcBottom - srcBottomFloor;
                    int srcBottomInt = (int)srcBottomFloor;

                    ColorBgra *dstPtr = this.GetPointAddressUnchecked(dstRoi2.Left, dstY);

                    for (int dstX = dstRoi2.Left; dstX < dstRoi2.Right; ++dstX)
                    {
                        double srcLeft = (double)(dstX * source.width) / (double)width;
                        double srcLeftFloor = Math.Floor(srcLeft);
                        double srcLeftWeight = 1 - (srcLeft - srcLeftFloor);
                        int srcLeftInt = (int)srcLeftFloor;

                        double srcRight = (double)((dstX + 1) * source.width) / (double)width;
                        double srcRightFloor = Math.Floor(srcRight - 0.00001);
                        double srcRightWeight = srcRight - srcRightFloor;
                        int srcRightInt = (int)srcRightFloor;

                        double blueSum = 0;
                        double greenSum = 0;
                        double redSum = 0;
                        double alphaSum = 0;

                        // left fractional edge
                        ColorBgra *srcLeftPtr = source.GetPointAddressUnchecked(srcLeftInt, srcTopInt + 1);

                        for (int srcY = srcTopInt + 1; srcY < srcBottomInt; ++srcY)
                        {
                            double a = srcLeftPtr->A;
                            blueSum += srcLeftPtr->B * srcLeftWeight * a;
                            greenSum += srcLeftPtr->G * srcLeftWeight * a;
                            redSum += srcLeftPtr->R * srcLeftWeight * a;
                            alphaSum += srcLeftPtr->A * srcLeftWeight;
                            srcLeftPtr = (ColorBgra*)((byte*)srcLeftPtr + source.stride);
                        }

                        // right fractional edge
                        ColorBgra *srcRightPtr = source.GetPointAddressUnchecked(srcRightInt, srcTopInt + 1);
                        for (int srcY = srcTopInt + 1; srcY < srcBottomInt; ++srcY)
                        {
                            double a = srcRightPtr->A;
                            blueSum += srcRightPtr->B * srcRightWeight * a;
                            greenSum += srcRightPtr->G * srcRightWeight * a;
                            redSum += srcRightPtr->R * srcRightWeight * a;
                            alphaSum += srcRightPtr->A * srcRightWeight;
                            srcRightPtr = (ColorBgra*)((byte*)srcRightPtr + source.stride);
                        }

                        // top fractional edge
                        ColorBgra *srcTopPtr = source.GetPointAddressUnchecked(srcLeftInt + 1, srcTopInt);
                        for (int srcX = srcLeftInt + 1; srcX < srcRightInt; ++srcX)
                        {
                            double a = srcTopPtr->A;
                            blueSum += srcTopPtr->B * srcTopWeight * a;
                            greenSum += srcTopPtr->G * srcTopWeight * a;
                            redSum += srcTopPtr->R * srcTopWeight * a;
                            alphaSum += srcTopPtr->A * srcTopWeight;
                            ++srcTopPtr;
                        }

                        // bottom fractional edge
                        ColorBgra *srcBottomPtr = source.GetPointAddressUnchecked(srcLeftInt + 1, srcBottomInt);
                        for (int srcX = srcLeftInt + 1; srcX < srcRightInt; ++srcX)
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:molecule-svn,代码行数:101,代码来源:Surface.cs


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