Esempio n. 1
0
		/// <summary>
		/// Create target texture with specified size and format
		/// </summary>
		/// <param name="width"></param>
		/// <param name="height"></param>
		/// <param name="format"></param>
		internal TargetTexture ( RenderTarget2D renderTarget )
		{
			createdFromRT	=	true;

			this.Width	=	renderTarget.Width;
			this.Height	=	renderTarget.Height;
			this.Format	=	TargetFormat.LowDynamicRange;

			RenderTarget	=	renderTarget; 
			Srv				=	RenderTarget;
		}
Esempio n. 2
0
        /// <summary>
        /// Create target texture with specified size and format
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="format"></param>
        internal TargetTexture(RenderTarget2D renderTarget)
        {
            createdFromRT = true;

            this.Width  = renderTarget.Width;
            this.Height = renderTarget.Height;
            this.Format = TargetFormat.LowDynamicRange;

            RenderTarget = renderTarget;
            Srv          = RenderTarget;
        }
Esempio n. 3
0
 public PfimConfig(
     int bufferSize            = 0x8000,
     TargetFormat targetFormat = TargetFormat.Native,
     bool decompress           = true,
     IImageAllocator allocator = null,
     bool applyColorMap        = true)
 {
     Allocator     = allocator ?? new DefaultAllocator();
     BufferSize    = bufferSize;
     TargetFormat  = targetFormat;
     Decompress    = decompress;
     ApplyColorMap = applyColorMap;
 }
Esempio n. 4
0
		/// <summary>
		/// Create target texture with specified size and format
		/// </summary>
		/// <param name="width"></param>
		/// <param name="height"></param>
		/// <param name="format"></param>
		public TargetTexture ( RenderSystem rs, int width, int height, TargetFormat format )
		{
			this.Width	=	width;
			this.Height	=	height;
			this.Format	=	format;

			var clrFrmt	=	ColorFormat.Unknown;
			var samples	=	1;

			switch (format) {
				case TargetFormat.LowDynamicRange		: clrFrmt = ColorFormat.Rgba8;	break;
				case TargetFormat.LowDynamicRangeMSAA	: clrFrmt = ColorFormat.Rgba8;	samples = 4; break;
				case TargetFormat.HighDynamicRange		: clrFrmt = ColorFormat.Rgba16F;	break;
				default: throw new ArgumentException("format");
			}

			RenderTarget	=	new RenderTarget2D( rs.Device, clrFrmt, width, height, samples ); 
			Srv	=	RenderTarget;
		}	
Esempio n. 5
0
        public static string ToRQLString(this TargetFormat format)
        {
            switch (format)
            {
            case TargetFormat.Jpeg:
                return("jpg");

            case TargetFormat.Gif:
                return("gif");

            case TargetFormat.Png:
                return("png");

            case TargetFormat.SameAsOriginalFormat:
                return("source");

            default:
                throw new ArgumentException(string.Format("Unknown {0} value: {1}", typeof(TargetFormat).Name,
                                                          format));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Create target texture with specified size and format
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="format"></param>
        public TargetTexture(RenderSystem rs, int width, int height, TargetFormat format)
        {
            this.Width  = width;
            this.Height = height;
            this.Format = format;

            var clrFrmt = ColorFormat.Unknown;
            var samples = 1;

            switch (format)
            {
            case TargetFormat.LowDynamicRange: clrFrmt = ColorFormat.Rgba8;  break;

            case TargetFormat.LowDynamicRangeMSAA: clrFrmt = ColorFormat.Rgba8;  samples = 4; break;

            case TargetFormat.HighDynamicRange: clrFrmt = ColorFormat.Rgba16F;        break;

            default: throw new ArgumentException("format");
            }

            RenderTarget = new RenderTarget2D(rs.Device, clrFrmt, width, height, samples);
            Srv          = RenderTarget;
        }
        public static ContainerTag Get(string path, TargetFormat format)
        {
            // support finding files inside the assembly

            string file = File.ReadAllText(path);

            switch (format)
            {
            case TargetFormat.CSS_MIN:
                return(Style().With(RawHtml(Config.CssMinifier(file))));

            case TargetFormat.JS_MIN:
                return(Script().With(RawHtml(Config.CssMinifier(file))));

            case TargetFormat.CSS:
                return(Style().With(RawHtml(file)));

            case TargetFormat.JS:
                return(Script().With(RawHtml(file)));

            default:
                throw new Exception("Invalid target format");
            }
        }
Esempio n. 8
0
 public override void Parse(string arg)
 {
     if (arg.Equals("--target:format=filesystem", StringComparison.InvariantCultureIgnoreCase))
     {
         this.targetFormat = TargetFormat.FileSystem;
     }
     else if (arg.Equals("--target:format=zip", StringComparison.InvariantCultureIgnoreCase))
     {
         this.targetFormat = TargetFormat.Zip;
     }
     else if (arg.Equals("--settings:format=json", StringComparison.InvariantCultureIgnoreCase))
     {
         this.settingsFormat = SettingsFormat.JSON;
     }
     else if (arg.Equals("--settings:format=xml", StringComparison.InvariantCultureIgnoreCase))
     {
         this.settingsFormat = SettingsFormat.XML;
     }
     else if (arg.Equals("--overwrite:no", StringComparison.InvariantCultureIgnoreCase))
     {
         this.overwrite = Overwrite.No;
     }
     else if (arg.Equals("--overwrite:prompt", StringComparison.InvariantCultureIgnoreCase))
     {
         this.overwrite = Overwrite.Prompt;
     }
     else if (arg.Equals("--overwrite:yes", StringComparison.InvariantCultureIgnoreCase))
     {
         this.overwrite = Overwrite.Yes;
     }
     else if (arg.Equals("--order:none", StringComparison.InvariantCultureIgnoreCase))
     {
         this.order = Order.None;
     }
     else if (arg.Equals("--order:sorted", StringComparison.InvariantCultureIgnoreCase))
     {
         this.order = Order.Sorted;
     }
     else if (arg.Equals("-0", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--compress:none", StringComparison.InvariantCultureIgnoreCase))
     {
         this.compressionLevel = CompressionLevel.NoCompression;
     }
     else if (arg.Equals("-1", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--compress:fast", StringComparison.InvariantCultureIgnoreCase))
     {
         this.compressionLevel = CompressionLevel.Fastest;
     }
     else if (arg.Equals("-9", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--compress:small", StringComparison.InvariantCultureIgnoreCase))
     {
         this.compressionLevel = CompressionLevel.Optimal;
     }
     else if (arg.Equals("--direntries", StringComparison.InvariantCultureIgnoreCase))
     {
         this.zipDirectoryEntries = true;
     }
     else if (arg.Equals("--nodirentries", StringComparison.InvariantCultureIgnoreCase))
     {
         this.zipDirectoryEntries = false;
     }
     else if (!TryParseLocality(arg))
     {
         base.Parse(arg);
     }
 }
        private void OnGUI()
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            exportFoldout = EditorGUILayout.Foldout(exportFoldout, "Extract Textures");
            if (exportFoldout)
            {
                EditorGUI.indentLevel += 1;
                // EditorGUILayout.LabelField("Export Array", EditorStyles.boldLabel);
                asset = (Texture2DArray)EditorGUILayout.ObjectField("Array asset", asset, typeof(Texture2DArray),
                                                                    false);

                var assetPath        = asset == null ? "" : AssetDatabase.GetAssetPath(asset);
                var targetExtractDir = asset == null ? "" : Path.GetDirectoryName(assetPath) + "\\ExportedTextures";
                if (asset != null)
                {
                    EditorGUILayout.LabelField(
                        $"Array: {asset.depth}x {asset.format.ToString()}, {asset.width}x{asset.height}");
                    EditorGUILayout.LabelField($"{assetPath}");
                }
                else
                {
                    EditorGUILayout.LabelField("No array referenced.");
                }

                exportType   = (ExportType)EditorGUILayout.EnumPopup("Export type", exportType);
                targetFormat = (TargetFormat)EditorGUILayout.EnumPopup("Format", targetFormat);

                using (new EditorGUI.DisabledScope(asset == null)) {
                    if (GUILayout.Button("Extract textures"))
                    {
                        Extract(assetPath, targetExtractDir);
                    }
                }

                EditorGUILayout.LabelField("Exporting textures to:");
                EditorGUILayout.LabelField($"{targetExtractDir}");

                EditorGUI.indentLevel -= 1;
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            importFoldout = EditorGUILayout.Foldout(importFoldout, "Merge Textures");
            // ReSharper disable once InvertIf
            if (importFoldout)
            {
                EditorGUI.indentLevel += 1;

                EditorGUILayout.LabelField("All textures must be of the same size and format.");
                EditorGUILayout.LabelField("(Whether that is the case will not be validated.)");

                // TEXTURES
                EditorGUILayout.Space();
                texArrayFoldout = EditorGUILayout.Foldout(texArrayFoldout, "Textures");
                if (texArrayFoldout)
                {
                    EditorGUI.indentLevel += 1;
                    var oldArrSize = importArray.Count;
                    var size       = EditorGUILayout.IntField("Size", oldArrSize);
                    if (oldArrSize != size)
                    {
                        if (size < 0)
                        {
                            size = 0;
                        }
                        // Resizing an array. Because the Unity folks couldn't be arsed to make a f*****g method to do this for us, apparently.
                        if (size > oldArrSize)
                        {
                            importArray.AddRange(Enumerable.Repeat <Texture2D>(null, size - oldArrSize));
                        }
                        else
                        {
                            importArray.RemoveRange(size, oldArrSize - size);
                        }
                    }
                    // Now draw all the textures and so on.
                    for (var i = 0; i < importArray.Count; i++)
                    {
                        importArray[i] = (Texture2D)EditorGUILayout.ObjectField($"Element {i}", importArray[i],
                                                                                typeof(Texture2D), false);
                    }
                    EditorGUI.indentLevel -= 1;
                }

                // OTHER SHIT
                useMips      = EditorGUILayout.Toggle("Use mips", useMips);
                encodeFormat = (TargetFormat)EditorGUILayout.EnumPopup("Encoding format", encodeFormat);

                EditorGUILayout.Space();

                EditorGUILayout.LabelField($"Target path: {exportPath}");
                if (GUILayout.Button("Choose new destination"))
                {
                    exportPath = EditorUtility.SaveFilePanel(
                        "Save textures to an .asset array",
                        exportPath == "" ? Application.dataPath : exportPath,
                        "textureArray.asset",
                        "asset");
                }
                EditorGUILayout.LabelField("NB: You MUST save this in Assets or a subdirectory.");

                EditorGUILayout.Space();

                using (new EditorGUI.DisabledScope(exportPath == "" || importArray?.Count(x => x != null) < 1)) {
                    if (GUILayout.Button("Merge"))
                    {
                        Merge();
                    }
                }

                EditorGUI.indentLevel -= 1;


                EditorGUI.indentLevel -= 1;
            }

            EditorGUILayout.EndScrollView();
        }
 public void AdjustOutputFileName(TargetFormat format)
 {
     OutputFileName = Path.GetFileNameWithoutExtension(OutputFileName) + "." + format.ToString().ToLower();
 }