Axiom.RenderSystems.OpenGL.GLTexture.RescaleNPower2 C# (CSharp) Метод

RescaleNPower2() приватный Метод

private RescaleNPower2 ( Image src ) : byte[]
src Image
Результат byte[]
		private byte[] RescaleNPower2( Image src )
		{
			// Scale image to n^2 dimensions
			int newWidth = ( 1 << MostSignificantBitSet( SrcWidth ) );

			if ( newWidth != SrcWidth )
			{
				newWidth <<= 1;
			}

			int newHeight = ( 1 << MostSignificantBitSet( SrcHeight ) );
			if ( newHeight != SrcHeight )
			{
				newHeight <<= 1;
			}

			byte[] tempData;

			if ( newWidth != SrcWidth || newHeight != SrcHeight )
			{
				int newImageSize = newWidth * newHeight * ( HasAlpha ? 4 : 3 );

				tempData = new byte[ newImageSize ];

				if ( Glu.gluScaleImage( this.GLFormat, SrcWidth, SrcHeight,
					Gl.GL_UNSIGNED_BYTE, src.Data, newWidth, newHeight,
					Gl.GL_UNSIGNED_BYTE, tempData ) != 0 )
				{

					throw new AxiomException( "Error while rescaling image!" );
				}

				Image.ApplyGamma( tempData, Gamma, newImageSize, srcBpp );

				SrcWidth = Width = newWidth;
				SrcHeight = Height = newHeight;
			}
			else
			{
				tempData = new byte[ src.Size ];
				Array.Copy( src.Data, tempData, src.Size );
				Image.ApplyGamma( tempData, Gamma, src.Size, srcBpp );
			}

			return tempData;
		}