AmaroK86.ImageFormat.DDS.subtype C# (CSharp) Method

subtype() public method

public subtype ( ) : string
return string
        public override string subtype()
        {
            if ((DDSHeader.pfFlags & 0x4) == 0x4) // DXT
            {
                switch (DDSHeader.FourCC)
                {
                    case (int)FourCC.DXT1: return "DXT1";
                    case (int)FourCC.DXT5: return "DXT5";
                    case (int)FourCC.ATI2: return "ATI2";
                    default: throw new FormatException("Unknown 4CC");
                }
            }
            else if ((DDSHeader.pfFlags & 0x40) == 0x40) // Uncompressed RGB
            {
                if (DDSHeader.RBitMask == 0xFF0000 && DDSHeader.GBitMask == 0xFF00 && DDSHeader.BBitMask == 0xFF)
                {
                    if ((DDSHeader.pfFlags & 0x1) == 0x1 && DDSHeader.ABitMask == -16777216 && DDSHeader.RGBBitCount == 0x20)
                        return "A8R8G8B8";
                    else if ((DDSHeader.pfFlags & 0x1) == 0x0 && DDSHeader.RGBBitCount == 0x18)
                        return "R8G8B8";
                }
                // Heff: Support for the weirder ABGR version:
                else if (DDSHeader.RBitMask == 0x0000FF && DDSHeader.GBitMask == 0x00FF00 && DDSHeader.BBitMask == 0xFF0000)
                {
                    if ((DDSHeader.pfFlags & 0x1) == 0x1 && DDSHeader.ABitMask == -16777216 && DDSHeader.RGBBitCount == 0x20)
                        return "A8B8G8R8";
                    else if ((DDSHeader.pfFlags & 0x1) == 0x0 && DDSHeader.RGBBitCount == 0x18) // Heff: unsure if this is used anywhere.
                        return "B8G8R8";
                }
            }
            else if ((DDSHeader.pfFlags & 0x80000) == 0x80000 && DDSHeader.RGBBitCount == 0x10 && DDSHeader.RBitMask == 0xFF && DDSHeader.GBitMask == 0xFF00) // V8U8
            {
                return "V8U8";
            }
            else if ((DDSHeader.pfFlags & 0x20000) == 0x20000 && DDSHeader.RGBBitCount == 0x8 && DDSHeader.RBitMask == 0xFF)
                return "G8";

            throw new FormatException("Unknown format");
        }

Usage Example

示例#1
0
        public void singleImageUpscale(string imagePathToAdd, string archiveDir)
        {
            ImageSize biggerImageSizeOnList = imgList.Max(image => image.imgSize);
            // check if replacing image is supported
            ImageFile imgFile;
            string fileFormat = Path.GetExtension(imagePathToAdd);
            switch (fileFormat)
            {
                case ".dds": imgFile = new DDS(imagePathToAdd, null); break;
                case ".DDS": imgFile = new DDS(imagePathToAdd, null); break;
                default: throw new FormatException(fileFormat + " image extension not supported");
            }

            if (texFormat == "PF_NormalMap_HQ")
            {
                if (imgFile.format != "ATI2")
                    throw new FormatException("Different image format, original is " + texFormat + ", new is " + imgFile.subtype());
            }
            else if (String.Compare(texFormat, "PF_" + imgFile.format, true) != 0 &&
                String.Compare(texFormat, imgFile.format, true) != 0)
            {
                throw new FormatException("Different image format, original is " + texFormat + ", new is " + imgFile.subtype());
            }

            // !!! warning, this method breaks consistency between imgList and imageData[] !!!
            ImageInfo newImgInfo = new ImageInfo();
            newImgInfo.storageType = imgList.Find(img => img.storageType != storage.empty && img.storageType != storage.pccSto).storageType;
            newImgInfo.imgSize = imgFile.imgSize;
            newImgInfo.uncSize = imgFile.resize().Length;
            newImgInfo.cprSize = 0x00; // not yet filled
            newImgInfo.offset = 0x00; // not yet filled
            imgList.RemoveAt(0);  // Remove old single image and add new one
            imgList.Add(newImgInfo);

            //now I let believe the program that I'm doing an image replace, saving lot of code ;)
            replaceImage2(newImgInfo.imgSize.ToString(), imagePathToAdd, archiveDir);

            // update Sizes
            properties["SizeX"].Value.IntValue = (int)newImgInfo.imgSize.width;
            properties["SizeY"].Value.IntValue = (int)newImgInfo.imgSize.height;
        }
All Usage Examples Of AmaroK86.ImageFormat.DDS::subtype