AmaroK86.ImageFormat.ImageFile.resize C# (CSharp) Méthode

resize() public méthode

public resize ( ) : byte[]
Résultat byte[]
        virtual public byte[] resize()
        {
            return imgData;
        }

Usage Example

Exemple #1
0
        public void ReplaceImage(ImageFile ddsfile)
        {
            ImageSize imgSize = ddsfile.imgSize;

            int imageIdx = imgList.FindIndex(img => img.imgSize == imgSize);
            ImageInfo imgInfo = imgList[imageIdx];

            if (imgInfo.storageType == storage.empty && imgInfo.imgSize.width > imgList.First(img => img.storageType != storage.empty).imgSize.width)
                imgInfo.storageType = imgList.First(img => img.storageType != storage.empty).storageType;
            else if (imgInfo.storageType == storage.empty)
                imgInfo.storageType = imgList.Last(img => img.storageType != storage.empty).storageType;
            if (imgInfo.storageType == storage.arcCpr || imgInfo.storageType == storage.arcUnc)
                throw new FormatException("Replacement of externally stored textures is not allowed");
            else if (imgInfo.storageType == storage.empty)
                throw new FormatException("Cannot replace images with empty image lists");

            byte[] imgBuff = ddsfile.resize();

            using (MemoryStream ms = new MemoryStream())
            {
                ms.WriteBytes(imageData);
                imgInfo.uncSize = imgBuff.Length;
                if ((long)imgInfo.uncSize != ImageFile.ImageDataSize(ddsfile.imgSize, ddsfile.format, ddsfile.BPP))
                    throw new FormatException("Input texture not correct length!");

                if (imgInfo.storageType == storage.pccCpr)
                {
                    SaltLZOHelper lzo = new SaltLZOHelper();
                    imgBuff = lzo.CompressTex(imgBuff);
                }
                if (imgBuff.Length <= imgInfo.cprSize && imgInfo.offset > 0)
                    ms.Seek(imgInfo.offset, SeekOrigin.Begin);
                else
                    imgInfo.offset = (int)ms.Position;
                imgInfo.cprSize = imgBuff.Length;
                ms.WriteBytes(imgBuff);
                imageData = ms.ToArray();
            }
            imgList[imageIdx] = imgInfo;
        }