ActiveTextureManagement.TexInfo.Resize C# (CSharp) Метод

Resize() публичный Метод

public Resize ( ) : void
Результат void
        public void Resize()
        {
            resizeWidth = width / scale;
            resizeHeight = height / scale;

            int tmpScale = scale - 1;
            while (resizeWidth < minSize && tmpScale > 0)
            {
                resizeWidth = width / tmpScale--;
            }
            tmpScale = scale - 1;
            while (resizeHeight < minSize && tmpScale > 0)
            {
                resizeHeight = height / tmpScale--;
            }

            if (maxSize != 0)
            {
                if (resizeWidth > maxSize)
                {
                    resizeWidth = maxSize;
                }
                if (resizeHeight > maxSize)
                {
                    resizeHeight = maxSize;
                }
            }

            needsResize = (resizeHeight != height || resizeWidth != width);
        }

Same methods

TexInfo::Resize ( int width, int height ) : void

Usage Example

Пример #1
0
        public static void IMGToTexture(TexInfo Texture, bool mipmaps, bool isNormalFormat)
        {
            TextureInfoWrapper texture = Texture.texture;

            TextureConverter.InitImageBuffer();
            FileStream imgStream = new FileStream(Texture.filename, FileMode.Open, FileAccess.Read);

            imgStream.Position = 0;
            imgStream.Read(imageBuffer, 0, MAX_IMAGE_SIZE);
            imgStream.Close();

            Texture2D tex = texture.texture;

            tex.LoadImage(imageBuffer);
            bool convertToNormalFormat = texture.isNormalMap && !isNormalFormat ? true : false;
            bool hasMipmaps            = tex.mipmapCount == 1 ? false : true;

            if (Texture.loadOriginalFirst)
            {
                Texture.Resize(tex.width, tex.height);
            }
            TextureFormat format = tex.format;

            if (texture.isNormalMap)
            {
                format = TextureFormat.ARGB32;
            }
            if (Texture.needsResize)
            {
                TextureConverter.Resize(texture, Texture.resizeWidth, Texture.resizeHeight, mipmaps, convertToNormalFormat);
            }
            else if (convertToNormalFormat || hasMipmaps != mipmaps || format != tex.format)
            {
                Color32[] pixels = tex.GetPixels32();
                if (convertToNormalFormat)
                {
                    for (int i = 0; i < pixels.Length; i++)
                    {
                        pixels[i].a = pixels[i].r;
                        pixels[i].r = pixels[i].g;
                        pixels[i].b = pixels[i].g;
                    }
                }
                if (tex.format != format || hasMipmaps != mipmaps)
                {
                    tex.Resize(tex.width, tex.height, format, mipmaps);
                }
                tex.SetPixels32(pixels);
                tex.Apply(mipmaps);
            }
        }
All Usage Examples Of ActiveTextureManagement.TexInfo::Resize