private static void compress(Stream input, CompressOptions options, Stream output) { Debug.Assert(input != null); Debug.Assert(options != null); Debug.Assert(output != null); jpeg_compress_struct cinfo = new jpeg_compress_struct(new cd_jpeg_error_mgr()); /* Initialize JPEG parameters. * Much of this may be overridden later. * In particular, we don't yet know the input file's color space, * but we need to provide some value for jpeg_set_defaults() to work. */ cinfo.In_color_space = J_COLOR_SPACE.JCS_RGB; /* arbitrary guess */ cinfo.jpeg_set_defaults(); /* Figure out the input file format, and set up to read it. */ cjpeg_source_struct src_mgr = new bmp_source_struct(cinfo); src_mgr.input_file = input; /* Read the input file header to obtain file size & colorspace. */ src_mgr.start_input(); /* Now that we know input colorspace, fix colorspace-dependent defaults */ cinfo.jpeg_default_colorspace(); /* Adjust default compression parameters */ if (!applyOptions(cinfo, options)) { return; } /* Specify data destination for compression */ cinfo.jpeg_stdio_dest(output); /* Start compressor */ cinfo.jpeg_start_compress(true); /* Process data */ while (cinfo.Next_scanline < cinfo.Image_height) { int num_scanlines = src_mgr.get_pixel_rows(); cinfo.jpeg_write_scanlines(src_mgr.buffer, num_scanlines); } /* Finish compression and release memory */ src_mgr.finish_input(); cinfo.jpeg_finish_compress(); /* All done. */ if (cinfo.Err.Num_warnings != 0) { Console.WriteLine("Corrupt-data warning count is not zero"); } }
public void Compress(string compressFile, IEnumerable<CompressFile> files, FileMode fileMode = FileMode.Create, CompressOptions compressOptions = CompressOptions.None) { _compressManager.Compress(compressFile, files, fileMode); if ((compressOptions & CompressOptions.DeleteSourceFiles) == CompressOptions.DeleteSourceFiles) { foreach (CompressFile file in files) zFile.Delete(file.File); } }
public static byte[] Compress(byte[] source, Compressor compressor, CompressionLevel level) { uint compressionBound = OodleLZ_GetCompressedBufferSizeNeeded((ulong)source.LongLength); CompressOptions options = CompressOptions.GetDefault(compressor, level); byte[] dest = new byte[compressionBound]; uint destLength = OodleLZ_Compress(compressor, source, (ulong)source.LongLength, dest, level, options, 0, 0, IntPtr.Zero, 0); Array.Resize(ref dest, (int)destLength); return(dest); }
private static int RunCompressAndReturnExitCode(CompressOptions options) { var compressor = new ConcurrentBlockCompressor( new Compressor(), options.SourceFile, options.CompressToFile, 1048576 ); return(RunCommand(compressor.Compress, options.CompressToFile)); }
private void CompressOptionGUI() { EditorGUILayout.LabelField("CompressOption Setting", new GUIStyle("BoldLabel")); var oldOption = Options.CompressOption; CompressOptions curOption = (CompressOptions)EditorGUILayout.EnumPopup("CompressOptions", Options.CompressOption); if (oldOption != curOption) { WriteInfos(AssetBundleOptionType.CompressOption, curOption); } }
private static void compress(Stream input, CompressOptions options, Stream output) { Debug.Assert(input != null); Debug.Assert(options != null); Debug.Assert(output != null); jpeg_compress_struct cinfo = new jpeg_compress_struct(new cd_jpeg_error_mgr()); /* Initialize JPEG parameters. * Much of this may be overridden later. * In particular, we don't yet know the input file's color space, * but we need to provide some value for jpeg_set_defaults() to work. */ cinfo.In_color_space = J_COLOR_SPACE.JCS_RGB; /* arbitrary guess */ cinfo.jpeg_set_defaults(); /* Figure out the input file format, and set up to read it. */ cjpeg_source_struct src_mgr = new bmp_source_struct(cinfo); src_mgr.input_file = input; /* Read the input file header to obtain file size & colorspace. */ src_mgr.start_input(); /* Now that we know input colorspace, fix colorspace-dependent defaults */ cinfo.jpeg_default_colorspace(); /* Adjust default compression parameters */ if (!applyOptions(cinfo, options)) return; /* Specify data destination for compression */ cinfo.jpeg_stdio_dest(output); /* Start compressor */ cinfo.jpeg_start_compress(true); /* Process data */ while (cinfo.Next_scanline < cinfo.Image_height) { int num_scanlines = src_mgr.get_pixel_rows(); cinfo.jpeg_write_scanlines(src_mgr.buffer, num_scanlines); } /* Finish compression and release memory */ src_mgr.finish_input(); cinfo.jpeg_finish_compress(); /* All done. */ if (cinfo.Err.Num_warnings != 0) Console.WriteLine("Corrupt-data warning count is not zero"); }
public void OnEnable(Rect pos, EditorWindow parent) { m_buildTarget = ABBuilder.Instance.CurBuildPlatform; // (AssetbundleHelper.BuildPlatform)EditorPrefs.GetInt(kBuildPrefPrefix + "BuildTarget", (int)m_buildTarget); m_compression = (CompressOptions)EditorPrefs.GetInt(kBuildPrefPrefix + "Compression", (int)m_compression); m_toggleData = new List <ToggleData>(); m_toggleData.Add(new ToggleData( false, "Exclude Type Information", "Do not include type information within the asset bundle (don't write type tree).", BuildAssetBundleOptions.DisableWriteTypeTree)); m_toggleData.Add(new ToggleData( false, "Force Rebuild", "Force rebuild the asset bundles", BuildAssetBundleOptions.ForceRebuildAssetBundle)); m_toggleData.Add(new ToggleData( false, "Ignore Type Tree Changes", "Ignore the type tree changes when doing the incremental build check.", BuildAssetBundleOptions.IgnoreTypeTreeChanges)); m_toggleData.Add(new ToggleData( false, "Append Hash", "Append the hash to the assetBundle name.", BuildAssetBundleOptions.AppendHashToAssetBundleName)); m_toggleData.Add(new ToggleData( false, "Strict Mode", "Do not allow the build to succeed if any errors are reporting during it.", BuildAssetBundleOptions.StrictMode)); m_toggleData.Add(new ToggleData( false, "Dry Run Build", "Do a dry run build.", BuildAssetBundleOptions.DryRunBuild)); m_ForceRebuild = new ToggleData( false, "Clear Folders", "Will wipe out all contents of build directory as well as StreamingAssets/AssetBundles if you are choosing to copy build there."); m_CopyToStreaming = new ToggleData( false, "Copy to StreamingAssets", "After build completes, will copy all build content to " + m_streamingPath + " for use in stand-alone player."); m_TargetContent = new GUIContent("Build Target", "Choose target platform to build for."); m_CompressionContent = new GUIContent("Compression", "Choose no compress, standard (LZMA), or chunk based (LZ4)"); m_useDefaultPath = EditorPrefs.GetBool(kBuildPrefPrefix + "DefaultOutputBuildPath", m_useDefaultPath); }
private static BuildAssetBundleOptions ConvertCompressOption(CompressOptions compressOption) { if (compressOption == CompressOptions.Uncompressed) { return(BuildAssetBundleOptions.UncompressedAssetBundle); } else if (compressOption == CompressOptions.ChunkBasedCompression) { return(BuildAssetBundleOptions.ChunkBasedCompression); } else { return(BuildAssetBundleOptions.None); } }
private void DrawBuildConfig(Rect r) { RectUtils.DrawOutline(r, 1); GUILayout.BeginArea(new Rect(r.x + 15, r.y + 8, r.width - 30, r.height - 16)); if (GUILayout.Button(content_chooseOutputPath)) { string dataPath = Application.dataPath; string selectedPath = EditorUtility.OpenFolderPanel("path", dataPath, ""); if (!string.IsNullOrEmpty(selectedPath)) { buildConfig.outputPath = selectedPath; } } GUI.enabled = false; buildConfig.outputPath = EditorGUILayout.TextField(content_outputPath, buildConfig.outputPath); GUI.enabled = true; GUILayout.Space(space); buildConfig.version = EditorGUILayout.TextField(content_version, buildConfig.version); GUILayout.Space(space); buildConfig.clearOutputFolder = EditorGUILayout.Toggle(content_clearFolders, buildConfig.clearOutputFolder); GUILayout.Space(space); buildConfig.copy2SteamingAssets = EditorGUILayout.Toggle(content_copy2StreamingAssets, buildConfig.copy2SteamingAssets); GUILayout.Space(space); GUILayout.Space(space); m_Compression = (CompressOptions)EditorGUILayout.IntPopup( content_compressionDesc, (int)m_Compression, content_compressionOptions, compressionValues); GUILayout.Space(space); buildConfig.excludeTypeInfo = EditorGUILayout.Toggle(content_excludeTypeInfo, buildConfig.excludeTypeInfo); GUILayout.Space(space); buildConfig.forceRebuild = EditorGUILayout.Toggle(content_forceRebuild, buildConfig.forceRebuild); GUILayout.Space(space); buildConfig.igonreTypeTreeChanges = EditorGUILayout.Toggle(content_ingonreTypeTreeChanges, buildConfig.igonreTypeTreeChanges); GUILayout.Space(space); buildConfig.appendHash = EditorGUILayout.Toggle(content_appendHash, buildConfig.appendHash); GUILayout.Space(space); buildConfig.strictMode = EditorGUILayout.Toggle(content_strictMode, buildConfig.strictMode); GUILayout.Space(space); buildConfig.dryRunBuild = EditorGUILayout.Toggle(content_dryRunBuild, buildConfig.dryRunBuild); GUILayout.Space(space); GUILayout.EndArea(); }
/// <summary> /// Initializes a new instance of the <see cref="CompressWhitespaceFilter"/> class. /// </summary> /// <param name="contentStream">The content stream.</param> /// <param name="compressOptions">The compress options.</param> public CompressWhitespaceFilter(Stream contentStream, CompressOptions compressOptions) { if (compressOptions == CompressOptions.GZip) { this._contentGZipStream = new GZipStream(contentStream, CompressionMode.Compress); this._contentStream = this._contentGZipStream; } else if (compressOptions == CompressOptions.Deflate) { this._content_DeflateStream = new DeflateStream(contentStream, CompressionMode.Compress); this._contentStream = this._content_DeflateStream; } else { this._contentStream = contentStream; } this._compressOptions = compressOptions; }
private static ErrorCode Compress(CompressOptions options) { try { using (var source = File.OpenRead(options.SourceFileName)) using (var destination = File.Create(options.DestinationFileName)) { var dispatcher = new Dispatcher(new GzipCompressionStrategy(), new MultipartGzipFormatter()); dispatcher.Compress(source, destination); } } catch (Exception e) { return(HandleError((dynamic)e, options)); } return(ErrorCode.Success); }
static string m_programName; /* program name for error messages */ public static void Main(string[] args) { m_programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); Options options = parseArguments(args); if (options == null) { usage(); return; } /* Open the input file. */ using (FileStream inputFile = openInputFile(options.InputFileName)) { if (inputFile == null) { return; } /* Open the output file. */ using (FileStream outputFile = createOutputFile(options.OutputFileName)) { if (outputFile == null) { return; } CompressOptions compressOptions = options as CompressOptions; if (compressOptions != null) { compress(inputFile, compressOptions, outputFile); } DecompressOptions decompressOptions = options as DecompressOptions; if (decompressOptions != null) { decompress(inputFile, decompressOptions, outputFile); } } } }
public void Compress(string compressFile, IEnumerable<string> files, FileMode fileMode = FileMode.Create, CompressOptions compressOptions = CompressOptions.None, string rootDirectory = null) { bool entryAsFilename = false; if ((compressOptions & CompressOptions.StorePartialPath) == CompressOptions.StorePartialPath) { if (rootDirectory == null) throw new PBException("need root directory to store partial path in zip file"); } else { rootDirectory = null; if ((compressOptions & CompressOptions.StorePath) != CompressOptions.StorePath) entryAsFilename = true; } _compressManager.Compress(compressFile, GetCompressFiles(files, rootDirectory, entryAsFilename), fileMode); if ((compressOptions & CompressOptions.DeleteSourceFiles) == CompressOptions.DeleteSourceFiles) { foreach (string file in files) zFile.Delete(file); } }
public void OnGUI(Rect pos) { m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition); bool newState = false; //basic options EditorGUILayout.Space(); GUILayout.BeginVertical(); m_buildTarget = ABBuilder.Instance.CurBuildPlatform; EditorGUILayout.TextField(m_TargetContent, m_buildTarget.ToString()); EditorPrefs.SetInt(kBuildPrefPrefix + "BuildTarget", (int)m_buildTarget); m_outputPath = ABBuilder.Instance.GetPathPrefix_Assetbundle(); EditorUserBuildSettings.SetPlatformSettings(ABBuilder.GetCurrentBuildPlatformName(), "AssetBundleOutputPath", m_outputPath); //output path EditorGUILayout.Space(); GUILayout.BeginHorizontal(); var newPath = EditorGUILayout.TextField("Output Path", m_outputPath); if (newPath != m_outputPath) { m_useDefaultPath = false; m_outputPath = newPath; EditorUserBuildSettings.SetPlatformSettings(ABBuilder.GetCurrentBuildPlatformName(), "AssetBundleOutputPath", m_outputPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (string.IsNullOrEmpty(m_outputPath)) { m_outputPath = EditorUserBuildSettings.GetPlatformSettings(ABBuilder.GetCurrentBuildPlatformName(), "AssetBundleOutputPath"); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); newState = GUILayout.Toggle( m_ForceRebuild.state, m_ForceRebuild.content); if (newState != m_ForceRebuild.state) { EditorPrefs.SetBool(m_ForceRebuild.PrefKey, newState); m_ForceRebuild.state = newState; } newState = GUILayout.Toggle( m_CopyToStreaming.state, m_CopyToStreaming.content); if (newState != m_CopyToStreaming.state) { EditorPrefs.SetBool(m_CopyToStreaming.PrefKey, newState); m_CopyToStreaming.state = newState; } // advanced options EditorGUILayout.Space(); m_advancedSettings = EditorGUILayout.Foldout(m_advancedSettings, "Advanced Settings"); if (m_advancedSettings) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup( m_CompressionContent, (int)m_compression, m_CompressionOptions, m_CompressionValues); if (cmp != m_compression) { m_compression = cmp; EditorPrefs.SetInt(kBuildPrefPrefix + "Compression", (int)m_compression); } foreach (var tog in m_toggleData) { newState = EditorGUILayout.ToggleLeft( tog.content, tog.state); if (newState != tog.state) { EditorPrefs.SetBool(tog.PrefKey, newState); tog.state = newState; } } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } // build. EditorGUILayout.Space(); if (GUILayout.Button("Build")) { ExecuteBuild(); } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
internal void OnGUI() { m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition); bool newState = false; var styleLabel = new GUIStyle(GUI.skin.GetStyle("Label")); styleLabel.alignment = TextAnchor.UpperCenter; GUILayout.Label(new GUIContent("Example build setup"), styleLabel); //basic options EditorGUILayout.Space(); GUILayout.BeginVertical(); // build target using (new EditorGUI.DisabledScope(!Model.AssetBundleModel.assetBundleData.canSpecifyBuildTarget)) { ValidBuildTarget buildTarget = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_UserData.m_BuildTarget); if (buildTarget != m_UserData.m_BuildTarget) { m_UserData.m_BuildTarget = buildTarget; if (m_UserData.m_UseDefaultPath) { m_UserData.m_OutputPath = "AssetBundles/"; m_UserData.m_OutputPath += m_UserData.m_BuildTarget.ToString(); //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } } } ////output path using (new EditorGUI.DisabledScope(!Model.AssetBundleModel.assetBundleData.canSpecifyBuildOutputDirectory)) { EditorGUILayout.Space(); GUILayout.BeginHorizontal(); var newPath = EditorGUILayout.TextField("Output Path", m_UserData.m_OutputPath); if (!System.String.IsNullOrEmpty(newPath) && newPath != m_UserData.m_OutputPath) { m_UserData.m_UseDefaultPath = false; m_UserData.m_OutputPath = newPath; //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f))) { BrowseForFolder(); } if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f))) { ResetPathToDefault(); } //if (string.IsNullOrEmpty(m_OutputPath)) // m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath"); GUILayout.EndHorizontal(); EditorGUILayout.Space(); newState = GUILayout.Toggle( m_ForceRebuild.state, m_ForceRebuild.content); CheckToggleDataState(m_ForceRebuild, newState); newState = GUILayout.Toggle( m_ResetAssetBundleName.state, m_ResetAssetBundleName.content); CheckToggleDataState(m_ResetAssetBundleName, newState); newState = GUILayout.Toggle( m_CheckRedundant.state, m_CheckRedundant.content ); CheckToggleDataState(m_CheckRedundant, newState); newState = GUILayout.Toggle( m_CopyToStreaming.state, m_CopyToStreaming.content); CheckToggleDataState(m_CopyToStreaming, newState); newState = GUILayout.Toggle( m_Reporter.state, m_Reporter.content ); CheckToggleDataState(m_Reporter, newState); } // advanced options using (new EditorGUI.DisabledScope(!Model.AssetBundleModel.assetBundleData.canSpecifyBuildOptions)) { EditorGUILayout.Space(); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup( m_CompressionContent, (int)m_UserData.m_Compression, m_CompressionOptions, m_CompressionValues); if (cmp != m_UserData.m_Compression) { m_UserData.m_Compression = cmp; } foreach (var toggleData in m_ToggleDatas) { newState = EditorGUILayout.ToggleLeft( toggleData.content, toggleData.state); CheckToggleDataState(toggleData, newState); } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } } // build. EditorGUILayout.Space(); if (GUILayout.Button("Build")) { EditorApplication.delayCall += ExecuteBuild; } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
public void OnGUI(Rect pos) { m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition); bool newState = false; //basic options EditorGUILayout.Space(); GUILayout.BeginVertical(); // build target using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) { ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_BuildTarget); if (tgt != m_BuildTarget) { m_BuildTarget = tgt; if (m_UseDefaultPath) { m_OutputPath = "AssetBundles/"; m_OutputPath += m_BuildTarget.ToString(); EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } } } ////output path using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) { EditorGUILayout.Space(); GUILayout.BeginHorizontal(); var newPath = EditorGUILayout.TextField("Output Path", m_OutputPath); if (newPath != m_OutputPath) { m_UseDefaultPath = false; m_OutputPath = newPath; EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f))) { BrowseForFolder(); } if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f))) { ResetPathToDefault(); } if (string.IsNullOrEmpty(m_OutputPath)) { m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath"); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); newState = GUILayout.Toggle( m_ForceRebuild.state, m_ForceRebuild.content); if (newState != m_ForceRebuild.state) { if (newState) { m_OnToggles.Add(m_ForceRebuild.content.text); } else { m_OnToggles.Remove(m_ForceRebuild.content.text); } m_ForceRebuild.state = newState; } newState = GUILayout.Toggle( m_CopyToStreaming.state, m_CopyToStreaming.content); if (newState != m_CopyToStreaming.state) { if (newState) { m_OnToggles.Add(m_CopyToStreaming.content.text); } else { m_OnToggles.Remove(m_CopyToStreaming.content.text); } m_CopyToStreaming.state = newState; } } // advanced options using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) { EditorGUILayout.Space(); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup( m_CompressionContent, (int)m_Compression, m_CompressionOptions, m_CompressionValues); if (cmp != m_Compression) { m_Compression = cmp; } foreach (var tog in m_ToggleData) { newState = EditorGUILayout.ToggleLeft( tog.content, tog.state); if (newState != tog.state) { if (newState) { m_OnToggles.Add(tog.content.text); } else { m_OnToggles.Remove(tog.content.text); } tog.state = newState; } } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } } // build. EditorGUILayout.Space(); if (GUILayout.Button("Build")) { EditorApplication.delayCall += ExecuteBuild; } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
/// <summary> /// Parse optional switches. /// Returns true if switches were parsed successfully; false otherwise. /// fileIndex receives index of first file-name argument (== -1 if none). /// for_real is false on the first (dummy) pass; we may skip any expensive /// processing. /// </summary> private static CompressOptions parseSwitchesForCompression(string[] argv) { Debug.Assert(argv != null); if (argv.Length <= 1) return null; CompressOptions options = new CompressOptions(); /* Scan command line options, adjust parameters */ int lastFileArgSeen = -1; for (int argn = 1; argn < argv.Length; argn++) { string arg = argv[argn]; if (arg[0] != '-') { /* Not a switch, must be a file name argument */ lastFileArgSeen = argn; break; } arg = arg.Substring(1); if (cdjpeg_utils.keymatch(arg, "baseline", 1)) { /* Force baseline-compatible output (8-bit quantizer values). */ options.ForceBaseline = true; } else if (cdjpeg_utils.keymatch(arg, "dct", 2)) { /* Select DCT algorithm. */ argn++; /* advance to next argument */ if (argn >= argv.Length) return null; if (cdjpeg_utils.keymatch(argv[argn], "int", 1)) options.DCTMethod = J_DCT_METHOD.JDCT_ISLOW; else if (cdjpeg_utils.keymatch(argv[argn], "fast", 2)) options.DCTMethod = J_DCT_METHOD.JDCT_IFAST; else if (cdjpeg_utils.keymatch(argv[argn], "float", 2)) options.DCTMethod = J_DCT_METHOD.JDCT_FLOAT; else return null; } else if (cdjpeg_utils.keymatch(arg, "debug", 1) || cdjpeg_utils.keymatch(arg, "verbose", 1)) { /* Enable debug printouts. */ options.Debug = true; /* On first -d, print version identification */ if (!m_printedVersion) { Console.Write(string.Format("Bit Miracle's CJPEG, version {0}\n{1}\n", jpeg_common_struct.Version, jpeg_common_struct.Copyright)); m_printedVersion = true; } } else if (cdjpeg_utils.keymatch(arg, "grayscale", 2) || cdjpeg_utils.keymatch(arg, "greyscale", 2)) { /* Force a monochrome JPEG file to be generated. */ options.Grayscale = true; } else if (cdjpeg_utils.keymatch(arg, "optimize", 1) || cdjpeg_utils.keymatch(arg, "optimise", 1)) { /* Enable entropy parm optimization. */ options.Optimize = true; } else if (cdjpeg_utils.keymatch(arg, "outfile", 4)) { /* Set output file name. */ argn++;/* advance to next argument */ if (argn >= argv.Length) return null; options.OutputFileName = argv[argn]; } else if (cdjpeg_utils.keymatch(arg, "progressive", 1)) { /* Select simple progressive mode. */ options.Progressive = true; /* We must postpone execution until num_components is known. */ } else if (cdjpeg_utils.keymatch(arg, "quality", 1)) { /* Quality factor (quantization table scaling factor). */ argn++;/* advance to next argument */ if (argn >= argv.Length) return null; try { options.Quality = int.Parse(argv[argn]); } catch (Exception e) { Console.WriteLine(e.Message); return null; } } else if (cdjpeg_utils.keymatch(arg, "qslots", 2)) { /* Quantization table slot numbers. */ argn++; /* advance to next argument */ if (argn >= argv.Length) return null; options.Qslots = argv[argn]; /* Must delay setting qslots until after we have processed any * colorspace-determining switches, since jpeg_set_colorspace sets * default quant table numbers. */ } else if (cdjpeg_utils.keymatch(arg, "qtables", 2)) { /* Quantization tables fetched from file. */ argn++; /* advance to next argument */ if (argn >= argv.Length) return null; options.Qtables = argv[argn]; /* We postpone actually reading the file in case -quality comes later. */ } else if (cdjpeg_utils.keymatch(arg, "restart", 1)) { /* Restart interval in MCU rows (or in MCUs with 'b'). */ argn++; /* advance to next argument */ if (argn >= argv.Length) return null; bool inBlocks = false; if (argv[argn].EndsWith("b") || argv[argn].EndsWith("B")) inBlocks = true; string parsee = argv[argn]; if (inBlocks) parsee = parsee.Remove(parsee.Length - 1); int val; try { val = int.Parse(parsee); } catch (Exception e) { Console.WriteLine(e.Message); return null; } if (val < 0 || val > 65535) return null; if (inBlocks) { options.RestartInterval = val; options.RestartInRows = 0; /* else prior '-restart n' overrides me */ } else { options.RestartInRows = val; /* restart_interval will be computed during startup */ } } else if (cdjpeg_utils.keymatch(arg, "sample", 2)) { /* Set sampling factors. */ argn++; /* advance to next argument */ if (argn >= argv.Length) return null; options.Sample = argv[argn]; /* Must delay setting sample factors until after we have processed any * colorspace-determining switches, since jpeg_set_colorspace sets * default sampling factors. */ } else if (cdjpeg_utils.keymatch(arg, "smooth", 2)) { /* Set input smoothing factor. */ argn++; /* advance to next argument */ if (argn >= argv.Length) return null; try { int val = int.Parse(argv[argn]); if (val < 0 || val > 100) return null; options.SmoothingFactor = val; } catch (Exception e) { Console.WriteLine(e.Message); return null; } } else /* bogus switch */ return null; } /* Must have either -outfile switch or explicit output file name */ if (options.OutputFileName.Length == 0) { // file_index should point to input file if (lastFileArgSeen != argv.Length - 2) { Console.WriteLine(string.Format("{0}: must name one input and one output file.", m_programName)); return null; } // output file comes right after input one options.InputFileName = argv[lastFileArgSeen]; options.OutputFileName = argv[lastFileArgSeen + 1]; } else { // file_index should point to input file if (lastFileArgSeen != argv.Length - 1) { Console.WriteLine(string.Format("{0}: must name one input and one output file.", m_programName)); return null; } options.InputFileName = argv[lastFileArgSeen]; } return options; }
static void RunWithCompressOptions(CompressOptions options) => CompressedSection.Compress(options.InputFile, options.OutputFile);
private static bool applyOptions(jpeg_compress_struct compressor, CompressOptions options) { compressor.jpeg_set_quality(options.Quality, options.ForceBaseline); compressor.Dct_method = options.DCTMethod; if (options.Debug) compressor.Err.Trace_level = 1; if (options.Grayscale) compressor.jpeg_set_colorspace(J_COLOR_SPACE.JCS_GRAYSCALE); if (options.Optimize) compressor.Optimize_coding = true; compressor.Restart_interval = options.RestartInterval; compressor.Restart_in_rows = options.RestartInRows; compressor.Smoothing_factor = options.SmoothingFactor; int q_scale_factor = 100; if (options.Quality != 75) q_scale_factor = jpeg_compress_struct.jpeg_quality_scaling(options.Quality); /* Set quantization tables for selected quality. */ /* Some or all may be overridden if -qtables is present. */ if (options.Qtables != "") /* process -qtables if it was present */ { if (!read_quant_tables(compressor, options.Qtables, q_scale_factor, options.ForceBaseline)) return false; } if (options.Qslots != "") /* process -qslots if it was present */ { if (!set_quant_slots(compressor, options.Qslots)) return false; } if (options.Sample != "") /* process -sample if it was present */ { if (!set_sample_factors(compressor, options.Sample)) return false; } if (options.Progressive) /* process -progressive; -scans can override */ compressor.jpeg_simple_progression(); return true; }
internal void OnGUI(Rect pos) { m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition); bool newState = false; var centeredStyle = GUI.skin.GetStyle("Label"); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(new GUIContent("Example build setup"), centeredStyle); //basic options EditorGUILayout.Space(); GUILayout.BeginVertical(); // build target using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) { ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_UserData.m_BuildTarget); if (tgt != m_UserData.m_BuildTarget) { m_UserData.m_BuildTarget = tgt; if (m_UserData.m_UseDefaultPath) { m_UserData.m_OutputPath = "AssetBundles/"; m_UserData.m_OutputPath += m_UserData.m_BuildTarget.ToString(); //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } } } if (GUILayout.Button("Add Current Selected Folder", GUILayout.MaxWidth(200))) { AddSelectedFolder(); } if (m_UserData.m_BuildFolderList != null && m_UserData.m_BuildFolderList.Count > 0) { EditorGUILayout.Space(); GUILayout.BeginVertical(); int buildFolderIndex = 1; int removeIndex = -1; foreach (var buildFolder in m_UserData.m_BuildFolderList) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(buildFolderIndex.ToString(), buildFolder.Path); buildFolder.SingleAssetBundle = GUILayout.Toggle(buildFolder.SingleAssetBundle, "Single AssetBundle"); if (buildFolder.SingleAssetBundle) { if (string.IsNullOrEmpty(buildFolder.AssetBundleName)) { buildFolder.AssetBundleName = buildFolder.Path.Substring(buildFolder.Path.LastIndexOf("/", StringComparison.Ordinal) + 1); } buildFolder.AssetBundleName = EditorGUILayout.TextField("AssetBundle Name", buildFolder.AssetBundleName); } buildFolder.VariantType = EditorGUILayout.TextField("AssetBundle Variant", buildFolder.VariantType); if (GUILayout.Button("-", GUILayout.MaxWidth(30))) { removeIndex = buildFolderIndex - 1; } buildFolderIndex++; GUILayout.EndHorizontal(); } if (removeIndex >= 0) { m_UserData.m_BuildFolderList.RemoveAt(removeIndex); } GUILayout.EndVertical(); } ////output path using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) { EditorGUILayout.Space(); GUILayout.BeginHorizontal(); var newPath = EditorGUILayout.TextField("Output Path", m_UserData.m_OutputPath); if ((newPath != m_UserData.m_OutputPath) && (newPath != string.Empty)) { m_UserData.m_UseDefaultPath = false; m_UserData.m_OutputPath = newPath; //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f))) { BrowseForFolder(); } if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f))) { ResetPathToDefault(); } //if (string.IsNullOrEmpty(m_OutputPath)) // m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath"); GUILayout.EndHorizontal(); EditorGUILayout.Space(); newState = GUILayout.Toggle( m_ForceRebuild.state, m_ForceRebuild.content); if (newState != m_ForceRebuild.state) { if (newState) { m_UserData.m_OnToggles.Add(m_ForceRebuild.content.text); } else { m_UserData.m_OnToggles.Remove(m_ForceRebuild.content.text); } m_ForceRebuild.state = newState; } newState = GUILayout.Toggle( m_CopyToStreaming.state, m_CopyToStreaming.content); if (newState != m_CopyToStreaming.state) { if (newState) { m_UserData.m_OnToggles.Add(m_CopyToStreaming.content.text); } else { m_UserData.m_OnToggles.Remove(m_CopyToStreaming.content.text); } m_CopyToStreaming.state = newState; } newState = GUILayout.Toggle( m_Encrypt.state, m_Encrypt.content); if (newState != m_Encrypt.state) { if (newState) { m_UserData.m_OnToggles.Add(m_Encrypt.content.text); } else { m_UserData.m_OnToggles.Remove(m_Encrypt.content.text); } m_Encrypt.state = newState; } newState = GUILayout.Toggle( m_Merge.state, m_Merge.content); if (newState != m_Merge.state) { if (newState) { m_UserData.m_OnToggles.Add(m_Merge.content.text); } else { m_UserData.m_OnToggles.Remove(m_Merge.content.text); } m_Merge.state = newState; } } // advanced options using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) { EditorGUILayout.Space(); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup( m_CompressionContent, (int)m_UserData.m_Compression, m_CompressionOptions, m_CompressionValues); if (cmp != m_UserData.m_Compression) { m_UserData.m_Compression = cmp; } foreach (var tog in m_ToggleData) { newState = EditorGUILayout.ToggleLeft( tog.content, tog.state); if (newState != tog.state) { if (newState) { m_UserData.m_OnToggles.Add(tog.content.text); } else { m_UserData.m_OnToggles.Remove(tog.content.text); } tog.state = newState; } } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } } EditorGUILayout.Space(); if (GUILayout.Button("Set AssetBundle Name")) { EditorApplication.delayCall += ExecuteSetAssetBundleName; } // build. EditorGUILayout.Space(); if (GUILayout.Button("Build")) { EditorApplication.delayCall += ExecuteBuild; } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
private static bool applyOptions(jpeg_compress_struct compressor, CompressOptions options) { compressor.jpeg_set_quality(options.Quality, options.ForceBaseline); compressor.Dct_method = options.DCTMethod; if (options.Debug) { compressor.Err.Trace_level = 1; } if (options.Grayscale) { compressor.jpeg_set_colorspace(J_COLOR_SPACE.JCS_GRAYSCALE); } if (options.Optimize) { compressor.Optimize_coding = true; } compressor.Restart_interval = options.RestartInterval; compressor.Restart_in_rows = options.RestartInRows; compressor.Smoothing_factor = options.SmoothingFactor; int q_scale_factor = 100; if (options.Quality != 75) { q_scale_factor = jpeg_compress_struct.jpeg_quality_scaling(options.Quality); } /* Set quantization tables for selected quality. */ /* Some or all may be overridden if -qtables is present. */ if (options.Qtables != "") /* process -qtables if it was present */ { if (!read_quant_tables(compressor, options.Qtables, q_scale_factor, options.ForceBaseline)) { return(false); } } if (options.Qslots != "") /* process -qslots if it was present */ { if (!set_quant_slots(compressor, options.Qslots)) { return(false); } } if (options.Sample != "") /* process -sample if it was present */ { if (!set_sample_factors(compressor, options.Sample)) { return(false); } } if (options.Progressive) /* process -progressive; -scans can override */ { compressor.jpeg_simple_progression(); } return(true); }
/// <summary> /// Parse optional switches. /// Returns true if switches were parsed successfully; false otherwise. /// fileIndex receives index of first file-name argument (== -1 if none). /// for_real is false on the first (dummy) pass; we may skip any expensive /// processing. /// </summary> private static CompressOptions parseSwitchesForCompression(string[] argv) { Debug.Assert(argv != null); if (argv.Length <= 1) { return(null); } CompressOptions options = new CompressOptions(); /* Scan command line options, adjust parameters */ int lastFileArgSeen = -1; for (int argn = 1; argn < argv.Length; argn++) { string arg = argv[argn]; if (arg[0] != '-') { /* Not a switch, must be a file name argument */ lastFileArgSeen = argn; break; } arg = arg.Substring(1); if (cdjpeg_utils.keymatch(arg, "baseline", 1)) { /* Force baseline-compatible output (8-bit quantizer values). */ options.ForceBaseline = true; } else if (cdjpeg_utils.keymatch(arg, "dct", 2)) { /* Select DCT algorithm. */ argn++; /* advance to next argument */ if (argn >= argv.Length) { return(null); } if (cdjpeg_utils.keymatch(argv[argn], "int", 1)) { options.DCTMethod = J_DCT_METHOD.JDCT_ISLOW; } else if (cdjpeg_utils.keymatch(argv[argn], "fast", 2)) { options.DCTMethod = J_DCT_METHOD.JDCT_IFAST; } else if (cdjpeg_utils.keymatch(argv[argn], "float", 2)) { options.DCTMethod = J_DCT_METHOD.JDCT_FLOAT; } else { return(null); } } else if (cdjpeg_utils.keymatch(arg, "debug", 1) || cdjpeg_utils.keymatch(arg, "verbose", 1)) { /* Enable debug printouts. */ options.Debug = true; /* On first -d, print version identification */ if (!m_printedVersion) { Console.Write(string.Format("Bit Miracle's CJPEG, version {0}\n{1}\n", jpeg_common_struct.Version, jpeg_common_struct.Copyright)); m_printedVersion = true; } } else if (cdjpeg_utils.keymatch(arg, "grayscale", 2) || cdjpeg_utils.keymatch(arg, "greyscale", 2)) { /* Force a monochrome JPEG file to be generated. */ options.Grayscale = true; } else if (cdjpeg_utils.keymatch(arg, "optimize", 1) || cdjpeg_utils.keymatch(arg, "optimise", 1)) { /* Enable entropy parm optimization. */ options.Optimize = true; } else if (cdjpeg_utils.keymatch(arg, "outfile", 4)) { /* Set output file name. */ argn++;/* advance to next argument */ if (argn >= argv.Length) { return(null); } options.OutputFileName = argv[argn]; } else if (cdjpeg_utils.keymatch(arg, "progressive", 1)) { /* Select simple progressive mode. */ options.Progressive = true; /* We must postpone execution until num_components is known. */ } else if (cdjpeg_utils.keymatch(arg, "quality", 1)) { /* Quality factor (quantization table scaling factor). */ argn++;/* advance to next argument */ if (argn >= argv.Length) { return(null); } try { options.Quality = int.Parse(argv[argn]); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } } else if (cdjpeg_utils.keymatch(arg, "qslots", 2)) { /* Quantization table slot numbers. */ argn++; /* advance to next argument */ if (argn >= argv.Length) { return(null); } options.Qslots = argv[argn]; /* Must delay setting qslots until after we have processed any * colorspace-determining switches, since jpeg_set_colorspace sets * default quant table numbers. */ } else if (cdjpeg_utils.keymatch(arg, "qtables", 2)) { /* Quantization tables fetched from file. */ argn++; /* advance to next argument */ if (argn >= argv.Length) { return(null); } options.Qtables = argv[argn]; /* We postpone actually reading the file in case -quality comes later. */ } else if (cdjpeg_utils.keymatch(arg, "restart", 1)) { /* Restart interval in MCU rows (or in MCUs with 'b'). */ argn++; /* advance to next argument */ if (argn >= argv.Length) { return(null); } bool inBlocks = false; if (argv[argn].EndsWith("b") || argv[argn].EndsWith("B")) { inBlocks = true; } string parsee = argv[argn]; if (inBlocks) { parsee = parsee.Remove(parsee.Length - 1); } int val; try { val = int.Parse(parsee); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } if (val < 0 || val > 65535) { return(null); } if (inBlocks) { options.RestartInterval = val; options.RestartInRows = 0; /* else prior '-restart n' overrides me */ } else { options.RestartInRows = val; /* restart_interval will be computed during startup */ } } else if (cdjpeg_utils.keymatch(arg, "sample", 2)) { /* Set sampling factors. */ argn++; /* advance to next argument */ if (argn >= argv.Length) { return(null); } options.Sample = argv[argn]; /* Must delay setting sample factors until after we have processed any * colorspace-determining switches, since jpeg_set_colorspace sets * default sampling factors. */ } else if (cdjpeg_utils.keymatch(arg, "smooth", 2)) { /* Set input smoothing factor. */ argn++; /* advance to next argument */ if (argn >= argv.Length) { return(null); } try { int val = int.Parse(argv[argn]); if (val < 0 || val > 100) { return(null); } options.SmoothingFactor = val; } catch (Exception e) { Console.WriteLine(e.Message); return(null); } } else /* bogus switch */ { return(null); } } /* Must have either -outfile switch or explicit output file name */ if (options.OutputFileName.Length == 0) { // file_index should point to input file if (lastFileArgSeen != argv.Length - 2) { Console.WriteLine(string.Format("{0}: must name one input and one output file.", m_programName)); return(null); } // output file comes right after input one options.InputFileName = argv[lastFileArgSeen]; options.OutputFileName = argv[lastFileArgSeen + 1]; } else { // file_index should point to input file if (lastFileArgSeen != argv.Length - 1) { Console.WriteLine(string.Format("{0}: must name one input and one output file.", m_programName)); return(null); } options.InputFileName = argv[lastFileArgSeen]; } return(options); }
public void Compress(string compressFile, IEnumerable <string> files, FileMode fileMode = FileMode.Create, CompressOptions compressOptions = CompressOptions.None, string rootDirectory = null) { bool entryAsFilename = false; if ((compressOptions & CompressOptions.StorePartialPath) == CompressOptions.StorePartialPath) { if (rootDirectory == null) { throw new PBException("need root directory to store partial path in zip file"); } } else { rootDirectory = null; if ((compressOptions & CompressOptions.StorePath) != CompressOptions.StorePath) { entryAsFilename = true; } } _compressManager.Compress(compressFile, GetCompressFiles(files, rootDirectory, entryAsFilename), fileMode); if ((compressOptions & CompressOptions.DeleteSourceFiles) == CompressOptions.DeleteSourceFiles) { foreach (string file in files) { zFile.Delete(file); } } }
internal void OnGUI() { m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition); bool newState = false; var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label")); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(new GUIContent("Example build setup"), centeredStyle); //basic options EditorGUILayout.Space(); GUILayout.BeginVertical(); // build target using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) { var rValueContent = new GUIContent(ABBuilder.Instance.CurBuildPlatform.ToString()); EditorGUILayout.LabelField(m_TargetContent, rValueContent); var tgt = ABBuilder.Instance.CurBuildPlatform; m_UserData.m_BuildTarget = (int)tgt; m_UserData.m_OutputPath = ABBuilder.Instance.GetPathPrefix_Assetbundle(); } ////output path using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) { EditorGUILayout.Space(); GUILayout.BeginHorizontal(); var newPath = EditorGUILayout.TextField("Output Path", m_UserData.m_OutputPath); if (!System.String.IsNullOrEmpty(newPath) && newPath != m_UserData.m_OutputPath) { m_UserData.m_UseDefaultPath = false; m_UserData.m_OutputPath = newPath; //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); //if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f))) // BrowseForFolder(); //if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f))) // ResetPathToDefault(); //if (string.IsNullOrEmpty(m_OutputPath)) // m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath"); GUILayout.EndHorizontal(); EditorGUILayout.Space(); newState = GUILayout.Toggle( m_ForceRebuild.state, m_ForceRebuild.content); if (newState != m_ForceRebuild.state) { if (newState) { m_UserData.m_OnToggles.Add(m_ForceRebuild.content.text); } else { m_UserData.m_OnToggles.Remove(m_ForceRebuild.content.text); } m_ForceRebuild.state = newState; } newState = GUILayout.Toggle( m_CopyToStreaming.state, m_CopyToStreaming.content); if (newState != m_CopyToStreaming.state) { if (newState) { m_UserData.m_OnToggles.Add(m_CopyToStreaming.content.text); } else { m_UserData.m_OnToggles.Remove(m_CopyToStreaming.content.text); } m_CopyToStreaming.state = newState; } } // advanced options using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) { EditorGUILayout.Space(); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup( m_CompressionContent, (int)m_UserData.m_Compression, m_CompressionOptions, m_CompressionValues); if (cmp != m_UserData.m_Compression) { m_UserData.m_Compression = cmp; } foreach (var tog in m_ToggleData) { newState = EditorGUILayout.ToggleLeft( tog.content, tog.state); if (newState != tog.state) { if (newState) { m_UserData.m_OnToggles.Add(tog.content.text); } else { m_UserData.m_OnToggles.Remove(tog.content.text); } tog.state = newState; } } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } } // build. EditorGUILayout.Space(); if (GUILayout.Button("Build")) { EditorApplication.delayCall += ExecuteBuild; } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
public void OnGUI(Rect pos) { m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition); bool newState = false; //basic options EditorGUILayout.Space(); GUILayout.BeginVertical(); ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_BuildTarget); if (tgt != m_BuildTarget) { m_BuildTarget = tgt; EditorPrefs.SetInt(k_BuildPrefPrefix + "BuildTarget", (int)m_BuildTarget); if (m_UseDefaultPath) { m_OutputPath = "AssetBundles/"; m_OutputPath += m_BuildTarget.ToString(); EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } } ////output path EditorGUILayout.Space(); GUILayout.BeginHorizontal(); var newPath = EditorGUILayout.TextField("Output Path", m_OutputPath); if (newPath != m_OutputPath) { m_UseDefaultPath = false; m_OutputPath = newPath; EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f))) { BrowseForFolder(); } if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f))) { ResetPathToDefault(); } if (string.IsNullOrEmpty(m_OutputPath)) { m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath"); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); newState = GUILayout.Toggle( m_ForceRebuild.state, m_ForceRebuild.content); if (newState != m_ForceRebuild.state) { EditorPrefs.SetBool(m_ForceRebuild.prefsKey, newState); m_ForceRebuild.state = newState; } newState = GUILayout.Toggle( m_CopyToStreaming.state, m_CopyToStreaming.content); if (newState != m_CopyToStreaming.state) { EditorPrefs.SetBool(m_CopyToStreaming.prefsKey, newState); m_CopyToStreaming.state = newState; } // advanced options EditorGUILayout.Space(); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup( m_CompressionContent, (int)m_Compression, m_CompressionOptions, m_CompressionValues); if (cmp != m_Compression) { m_Compression = cmp; EditorPrefs.SetInt(k_BuildPrefPrefix + "Compression", (int)m_Compression); } foreach (var tog in m_ToggleData) { newState = EditorGUILayout.ToggleLeft( tog.content, tog.state); if (newState != tog.state) { EditorPrefs.SetBool(tog.prefsKey, newState); tog.state = newState; } } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } // build. EditorGUILayout.Space(); if (GUILayout.Button("Build")) { ExecuteBuild(); } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
public void Compress(string compressFile, IEnumerable <CompressFile> files, FileMode fileMode = FileMode.Create, CompressOptions compressOptions = CompressOptions.None) { _compressManager.Compress(compressFile, files, fileMode); if ((compressOptions & CompressOptions.DeleteSourceFiles) == CompressOptions.DeleteSourceFiles) { foreach (CompressFile file in files) { zFile.Delete(file.File); } } }
private static extern uint OodleLZ_Compress(Compressor compressor, byte[] src_buf, ulong src_len, byte[] dst_buf, CompressionLevel level, CompressOptions options, ulong offs, ulong unused, IntPtr scratch, ulong scratch_size);