├── .gitattributes ├── .gitignore ├── L10nStrings.cs ├── LICENSE.txt ├── OptiPngFileType.cs ├── OptiPngFileType.csproj ├── OptiPngFileType.sln ├── OptiPngSaveConfigToken.cs ├── OptiPngSaveConfigWidget.cs ├── OptiPngSaveConfigWidget.ui.cs ├── PaintDotNet ├── EtchedLine.cs ├── HeaderLabel.cs ├── UI.cs └── VisualStyleClass.cs └── Properties └── AssemblyInfo.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | 28 | # Visual Studio 2015/2017 cache/options directory 29 | .vs/ 30 | # Uncomment if you have tasks that create the project's static files in wwwroot 31 | #wwwroot/ 32 | 33 | # Visual Studio 2017 auto generated files 34 | Generated\ Files/ 35 | 36 | # MSTest test Results 37 | [Tt]est[Rr]esult*/ 38 | [Bb]uild[Ll]og.* 39 | 40 | # NUNIT 41 | *.VisualState.xml 42 | TestResult.xml 43 | 44 | # Build Results of an ATL Project 45 | [Dd]ebugPS/ 46 | [Rr]eleasePS/ 47 | dlldata.c 48 | 49 | # Benchmark Results 50 | BenchmarkDotNet.Artifacts/ 51 | 52 | # .NET Core 53 | project.lock.json 54 | project.fragment.lock.json 55 | artifacts/ 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_h.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *_wpftmp.csproj 81 | *.log 82 | *.vspscc 83 | *.vssscc 84 | .builds 85 | *.pidb 86 | *.svclog 87 | *.scc 88 | 89 | # Chutzpah Test files 90 | _Chutzpah* 91 | 92 | # Visual C++ cache files 93 | ipch/ 94 | *.aps 95 | *.ncb 96 | *.opendb 97 | *.opensdf 98 | *.sdf 99 | *.cachefile 100 | *.VC.db 101 | *.VC.VC.opendb 102 | 103 | # Visual Studio profiler 104 | *.psess 105 | *.vsp 106 | *.vspx 107 | *.sap 108 | 109 | # Visual Studio Trace Files 110 | *.e2e 111 | 112 | # TFS 2012 Local Workspace 113 | $tf/ 114 | 115 | # Guidance Automation Toolkit 116 | *.gpState 117 | 118 | # ReSharper is a .NET coding add-in 119 | _ReSharper*/ 120 | *.[Rr]e[Ss]harper 121 | *.DotSettings.user 122 | 123 | # JustCode is a .NET coding add-in 124 | .JustCode 125 | 126 | # TeamCity is a build add-in 127 | _TeamCity* 128 | 129 | # DotCover is a Code Coverage Tool 130 | *.dotCover 131 | 132 | # AxoCover is a Code Coverage Tool 133 | .axoCover/* 134 | !.axoCover/settings.json 135 | 136 | # Visual Studio code coverage results 137 | *.coverage 138 | *.coveragexml 139 | 140 | # NCrunch 141 | _NCrunch_* 142 | .*crunch*.local.xml 143 | nCrunchTemp_* 144 | 145 | # MightyMoose 146 | *.mm.* 147 | AutoTest.Net/ 148 | 149 | # Web workbench (sass) 150 | .sass-cache/ 151 | 152 | # Installshield output folder 153 | [Ee]xpress/ 154 | 155 | # DocProject is a documentation generator add-in 156 | DocProject/buildhelp/ 157 | DocProject/Help/*.HxT 158 | DocProject/Help/*.HxC 159 | DocProject/Help/*.hhc 160 | DocProject/Help/*.hhk 161 | DocProject/Help/*.hhp 162 | DocProject/Help/Html2 163 | DocProject/Help/html 164 | 165 | # Click-Once directory 166 | publish/ 167 | 168 | # Publish Web Output 169 | *.[Pp]ublish.xml 170 | *.azurePubxml 171 | # Note: Comment the next line if you want to checkin your web deploy settings, 172 | # but database connection strings (with potential passwords) will be unencrypted 173 | *.pubxml 174 | *.publishproj 175 | 176 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 177 | # checkin your Azure Web App publish settings, but sensitive information contained 178 | # in these scripts will be unencrypted 179 | PublishScripts/ 180 | 181 | # NuGet Packages 182 | *.nupkg 183 | # The packages folder can be ignored because of Package Restore 184 | **/[Pp]ackages/* 185 | # except build/, which is used as an MSBuild target. 186 | !**/[Pp]ackages/build/ 187 | # Uncomment if necessary however generally it will be regenerated when needed 188 | #!**/[Pp]ackages/repositories.config 189 | # NuGet v3's project.json files produces more ignorable files 190 | *.nuget.props 191 | *.nuget.targets 192 | 193 | # Microsoft Azure Build Output 194 | csx/ 195 | *.build.csdef 196 | 197 | # Microsoft Azure Emulator 198 | ecf/ 199 | rcf/ 200 | 201 | # Windows Store app package directories and files 202 | AppPackages/ 203 | BundleArtifacts/ 204 | Package.StoreAssociation.xml 205 | _pkginfo.txt 206 | *.appx 207 | 208 | # Visual Studio cache files 209 | # files ending in .cache can be ignored 210 | *.[Cc]ache 211 | # but keep track of directories ending in .cache 212 | !*.[Cc]ache/ 213 | 214 | # Others 215 | ClientBin/ 216 | ~$* 217 | *~ 218 | *.dbmdl 219 | *.dbproj.schemaview 220 | *.jfm 221 | *.pfx 222 | *.publishsettings 223 | orleans.codegen.cs 224 | 225 | # Including strong name files can present a security risk 226 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 227 | #*.snk 228 | 229 | # Since there are multiple workflows, uncomment next line to ignore bower_components 230 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 231 | #bower_components/ 232 | 233 | # RIA/Silverlight projects 234 | Generated_Code/ 235 | 236 | # Backup & report files from converting an old project file 237 | # to a newer Visual Studio version. Backup files are not needed, 238 | # because we have git ;-) 239 | _UpgradeReport_Files/ 240 | Backup*/ 241 | UpgradeLog*.XML 242 | UpgradeLog*.htm 243 | ServiceFabricBackup/ 244 | *.rptproj.bak 245 | 246 | # SQL Server files 247 | *.mdf 248 | *.ldf 249 | *.ndf 250 | 251 | # Business Intelligence projects 252 | *.rdl.data 253 | *.bim.layout 254 | *.bim_*.settings 255 | *.rptproj.rsuser 256 | 257 | # Microsoft Fakes 258 | FakesAssemblies/ 259 | 260 | # GhostDoc plugin setting file 261 | *.GhostDoc.xml 262 | 263 | # Node.js Tools for Visual Studio 264 | .ntvs_analysis.dat 265 | node_modules/ 266 | 267 | # Visual Studio 6 build log 268 | *.plg 269 | 270 | # Visual Studio 6 workspace options file 271 | *.opt 272 | 273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 274 | *.vbw 275 | 276 | # Visual Studio LightSwitch build output 277 | **/*.HTMLClient/GeneratedArtifacts 278 | **/*.DesktopClient/GeneratedArtifacts 279 | **/*.DesktopClient/ModelManifest.xml 280 | **/*.Server/GeneratedArtifacts 281 | **/*.Server/ModelManifest.xml 282 | _Pvt_Extensions 283 | 284 | # Paket dependency manager 285 | .paket/paket.exe 286 | paket-files/ 287 | 288 | # FAKE - F# Make 289 | .fake/ 290 | 291 | # JetBrains Rider 292 | .idea/ 293 | *.sln.iml 294 | 295 | # CodeRush personal settings 296 | .cr/personal 297 | 298 | # Python Tools for Visual Studio (PTVS) 299 | __pycache__/ 300 | *.pyc 301 | 302 | # Cake - Uncomment if you are using it 303 | # tools/** 304 | # !tools/packages.config 305 | 306 | # Tabs Studio 307 | *.tss 308 | 309 | # Telerik's JustMock configuration file 310 | *.jmconfig 311 | 312 | # BizTalk build output 313 | *.btp.cs 314 | *.btm.cs 315 | *.odx.cs 316 | *.xsd.cs 317 | 318 | # OpenCover UI analysis results 319 | OpenCover/ 320 | 321 | # Azure Stream Analytics local run output 322 | ASALocalRun/ 323 | 324 | # MSBuild Binary and Structured Log 325 | *.binlog 326 | 327 | # NVidia Nsight GPU debugger configuration file 328 | *.nvuser 329 | 330 | # MFractors (Xamarin productivity tool) working folder 331 | .mfractor/ 332 | 333 | # Local History for Visual Studio 334 | .localhistory/ 335 | -------------------------------------------------------------------------------- /L10nStrings.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace ILikePi.FileTypes.OptiPng 4 | { 5 | internal static class L10nStrings 6 | { 7 | private static readonly string uiCulture = CultureInfo.CurrentUICulture.Name; 8 | 9 | internal static string EffectName 10 | { 11 | get 12 | { 13 | switch (uiCulture) 14 | { 15 | case "ru": 16 | return "Оптимизированный PNG"; 17 | case "de": 18 | return "Optimiertes PNG"; 19 | default: 20 | return "Optimized PNG"; 21 | } 22 | } 23 | } 24 | 25 | internal static string Trials1 26 | { 27 | get 28 | { 29 | switch (uiCulture) 30 | { 31 | case "ru": 32 | return "Эвристика (1 проход)"; 33 | case "de": 34 | return "Heuristik (1 Durchlauf)"; 35 | default: 36 | return "Heuristics (1 trial)"; 37 | } 38 | } 39 | } 40 | 41 | internal static string Trials8 42 | { 43 | get 44 | { 45 | switch (uiCulture) 46 | { 47 | case "ru": 48 | return "8 проходов"; 49 | case "de": 50 | return "8 Durchläufe"; 51 | default: 52 | return "8 trials"; 53 | } 54 | } 55 | } 56 | 57 | internal static string Trials16 58 | { 59 | get 60 | { 61 | switch (uiCulture) 62 | { 63 | case "ru": 64 | return "16 проходов"; 65 | case "de": 66 | return "16 Durchläufe"; 67 | default: 68 | return "16 trials"; 69 | } 70 | } 71 | } 72 | 73 | internal static string Trials24 74 | { 75 | get 76 | { 77 | switch (uiCulture) 78 | { 79 | case "ru": 80 | return "24 проходов"; 81 | case "de": 82 | return "24 Durchläufe"; 83 | default: 84 | return "24 trials"; 85 | } 86 | } 87 | } 88 | 89 | internal static string Trials48 90 | { 91 | get 92 | { 93 | switch (uiCulture) 94 | { 95 | case "ru": 96 | return "48 проходов"; 97 | case "de": 98 | return "48 Durchläufe"; 99 | default: 100 | return "48 trials"; 101 | } 102 | } 103 | } 104 | 105 | internal static string Trials120 106 | { 107 | get 108 | { 109 | switch (uiCulture) 110 | { 111 | case "ru": 112 | return "120 проходов"; 113 | case "de": 114 | return "120 Durchläufe"; 115 | default: 116 | return "120 trials"; 117 | } 118 | } 119 | } 120 | 121 | internal static string Trials240 122 | { 123 | get 124 | { 125 | switch (uiCulture) 126 | { 127 | case "ru": 128 | return "240 проходов"; 129 | case "de": 130 | return "240 Durchläufe"; 131 | default: 132 | return "240 trials"; 133 | } 134 | } 135 | } 136 | 137 | internal static string PoweredByOptiPNG 138 | { 139 | get 140 | { 141 | switch (uiCulture) 142 | { 143 | case "ru": 144 | return "Работает на OptiPNG"; 145 | case "de": 146 | return "nutzt OptiPNG"; 147 | default: 148 | return "Powered by OptiPNG"; 149 | } 150 | } 151 | } 152 | 153 | internal static string ColorReduction 154 | { 155 | get 156 | { 157 | switch (uiCulture) 158 | { 159 | case "ru": 160 | return "Уменьшение цвета"; 161 | case "de": 162 | return "Farbreduktion"; 163 | default: 164 | return "Color reduction"; 165 | } 166 | } 167 | } 168 | 169 | internal static string Grayscale 170 | { 171 | get 172 | { 173 | switch (uiCulture) 174 | { 175 | case "ru": 176 | return "Оттенки серого"; 177 | case "de": 178 | return "&Graustufen"; 179 | default: 180 | return "&Grayscale"; 181 | } 182 | } 183 | } 184 | 185 | internal static string GrayscaleDescription 186 | { 187 | get 188 | { 189 | switch (uiCulture) 190 | { 191 | case "ru": 192 | return "Черно-белый без прозрачности"; 193 | case "de": 194 | return "Schwarzweiß ohne Transparenz"; 195 | default: 196 | return "Black/white without transparency"; 197 | } 198 | } 199 | } 200 | 201 | internal static string Rgb 202 | { 203 | get 204 | { 205 | switch (uiCulture) 206 | { 207 | case "ru": 208 | return "RGB"; 209 | case "de": 210 | return "&RGB"; 211 | default: 212 | return "&RGB"; 213 | } 214 | } 215 | } 216 | 217 | internal static string RgbDescription 218 | { 219 | get 220 | { 221 | switch (uiCulture) 222 | { 223 | case "ru": 224 | return "RGB без прозрачности"; 225 | case "de": 226 | return "RGB ohne Transparenz"; 227 | default: 228 | return "RGB without transparency"; 229 | } 230 | } 231 | } 232 | 233 | internal static string MultiplyByAlpha 234 | { 235 | get 236 | { 237 | switch (uiCulture) 238 | { 239 | case "ru": 240 | return "Умножение на альфа-канал"; 241 | case "de": 242 | return "mit Alphakanal &multiplizieren"; 243 | default: 244 | return "&Multiply by alpha channel"; 245 | } 246 | } 247 | } 248 | 249 | internal static string MultiplyByAlphaDescription 250 | { 251 | get 252 | { 253 | switch (uiCulture) 254 | { 255 | case "ru": 256 | return "Для цветовых режимов которая не поддерживают альфа - канал,\r\nумножить на альфа-канал"; 257 | case "de": 258 | return "In Farbmod ohne Unterstützung für einen Alphakanal, mit diesem multiplizieren"; 259 | default: 260 | return "For color modes that do not support the alpha channel, multiply by the alpha channel"; 261 | } 262 | } 263 | } 264 | 265 | internal static string Palette 266 | { 267 | get 268 | { 269 | switch (uiCulture) 270 | { 271 | case "ru": 272 | return "Палитра"; 273 | default: 274 | return "&Palette"; 275 | } 276 | } 277 | } 278 | 279 | internal static string PaletteDescription 280 | { 281 | get 282 | { 283 | switch (uiCulture) 284 | { 285 | case "ru": 286 | return "Не более 256 различных цветов"; 287 | case "de": 288 | return "Nicht mehr als 256 separate Farben"; 289 | default: 290 | return "No more than 256 distinct colors"; 291 | } 292 | } 293 | } 294 | 295 | internal static string DitheringLevel 296 | { 297 | get 298 | { 299 | switch (uiCulture) 300 | { 301 | case "ru": 302 | return "Уровень сглаживания"; 303 | case "de": 304 | return "Rasterstufe"; 305 | default: 306 | return "&Dithering level:"; 307 | } 308 | } 309 | } 310 | 311 | internal static string TransparencyThreshold 312 | { 313 | get 314 | { 315 | switch (uiCulture) 316 | { 317 | case "ru": 318 | return "Порог прозрачности:"; 319 | case "de": 320 | return "&Transparenzgrenze"; 321 | default: 322 | return "&Transparency threshold:"; 323 | } 324 | } 325 | } 326 | 327 | internal static string TransparencyThresholdDescription 328 | { 329 | get 330 | { 331 | switch (uiCulture) 332 | { 333 | case "ru": 334 | return "Пиксели с альфа-значением меньше порога будут полностью прозрачными."; 335 | case "de": 336 | return "Pixel mit einem Alphawert unterhalb der Grenze werden völlig transparent."; 337 | default: 338 | return "Pixels with an alpha value less than the threshold will be fully transparent."; 339 | } 340 | } 341 | } 342 | 343 | internal static string GrayScaleWithAlpha 344 | { 345 | get 346 | { 347 | switch (uiCulture) 348 | { 349 | case "ru": 350 | return "Оттенки серого с альфа"; 351 | case "de": 352 | return "G&raustufen mit Alphakanal"; 353 | default: 354 | return "Gr&ayscale with alpha"; 355 | } 356 | } 357 | } 358 | 359 | internal static string GrayScaleWithAlphaDescription 360 | { 361 | get 362 | { 363 | switch (uiCulture) 364 | { 365 | case "ru": 366 | return "Черно-белый с прозрачностью"; 367 | case "de": 368 | return "Schwarzweiß mit Transparenz"; 369 | default: 370 | return "Black/white with transparency"; 371 | } 372 | } 373 | } 374 | 375 | internal static string RgbWithAlpha 376 | { 377 | get 378 | { 379 | switch (uiCulture) 380 | { 381 | case "ru": 382 | return "RGB с альфа-каналом"; 383 | case "de": 384 | return "RG&B mit Alphakanal"; 385 | default: 386 | return "RG&B with alpha"; 387 | } 388 | } 389 | } 390 | 391 | internal static string RgbWithAlphaDescription 392 | { 393 | get 394 | { 395 | switch (uiCulture) 396 | { 397 | case "ru": 398 | return "RGB с прозрачностью (всегда без потерь)"; 399 | case "de": 400 | return "RGB mit Transparenz (stets verlustfrei)"; 401 | default: 402 | return "RGB with transparency (always lossless)"; 403 | } 404 | } 405 | } 406 | 407 | internal static string Compression 408 | { 409 | get 410 | { 411 | switch (uiCulture) 412 | { 413 | case "ru": 414 | return "Сжатия"; 415 | case "de": 416 | return "Komprimierung"; 417 | default: 418 | return "Compression"; 419 | } 420 | } 421 | } 422 | 423 | internal static string CompressionDescription 424 | { 425 | get 426 | { 427 | switch (uiCulture) 428 | { 429 | case "ru": 430 | return "Это пресеты OptiPNG. По сути они говорят OptiPNG, сколько грубой силы использовать.\r\nБолее высокие значения не всегда могут давать меньшие размеры,\r\nесли нижняя предустановка уже имеет оптимальные настройки."; 431 | case "de": 432 | return "Diese Vorgeisntellungen bestimmen wie brachial OptiPNG arbeiten soll.\r\nHöhere Werte ergeben keine kleinere Dateigröße, falls eine niedrigere Einstellung bereits zum optimalen Ergebnis führt."; 433 | default: 434 | return "These presets tell OptiPNG how much brute force to use.\r\nHigher values may not always give smaller sizes if a lower preset already has optimal settings."; 435 | } 436 | } 437 | } 438 | 439 | internal static string Optimize 440 | { 441 | get 442 | { 443 | switch (uiCulture) 444 | { 445 | case "ru": 446 | return "Оптимизировать"; 447 | case "de": 448 | return "&Optimieren"; 449 | default: 450 | return "&Optimize"; 451 | } 452 | } 453 | } 454 | 455 | internal static string OptimizeDescription 456 | { 457 | get 458 | { 459 | switch (uiCulture) 460 | { 461 | case "ru": 462 | return "Снимите этот флажок, если требуется только предосмотр.\r\nВы можете безопасно завершить оптимизацию закрыв окно консоли."; 463 | case "de": 464 | return "Abwählen falls nur Vorschau erwünscht.\r\nDie Optimierung wird durch Schließen des Fensters sicher beendet."; 465 | default: 466 | return "Uncheck this if you just want to preview.\r\nYou can safely end optimization by closing the console window."; 467 | } 468 | } 469 | } 470 | 471 | internal static string Interlace 472 | { 473 | get 474 | { 475 | switch (uiCulture) 476 | { 477 | case "ru": 478 | return "Чередование"; 479 | case "de": 480 | return "Ze&ilensprung"; 481 | default: 482 | return "&Interlace"; 483 | } 484 | } 485 | } 486 | 487 | internal static string InterlaceDescription 488 | { 489 | get 490 | { 491 | switch (uiCulture) 492 | { 493 | case "ru": 494 | return "Позволяет браузерам сначала отображать версии изображения\r\nс низкой детализацией и улучшать детализацию по мере загрузки.\r\nВключение этого параметра обычно увеличивает размер файла."; 495 | case "de": 496 | return "Erlaubt Browsern zuerst eine geringer aufgelöste Version des Bildes anzuzeigen und mit zunehmendem Ladefortschritt mehr Details.\r\nDiese Option erhöht die Dateigröße meistens etwas."; 497 | default: 498 | return "Allows browsers to display low detail versions of an image first and improve the detail as more is downloaded.\r\nTurning this on generally increases the file size."; 499 | } 500 | } 501 | } 502 | 503 | internal static string QuietMode 504 | { 505 | get 506 | { 507 | switch (uiCulture) 508 | { 509 | case "ru": 510 | return "Тихий режим"; 511 | case "de": 512 | return "Stummer Modus"; 513 | default: 514 | return "&Quiet mode"; 515 | } 516 | } 517 | } 518 | 519 | internal static string QuietModeDescription 520 | { 521 | get 522 | { 523 | switch (uiCulture) 524 | { 525 | case "ru": 526 | return "С помощью этого флажка OptiPNG будет запущен в тихом режиме."; 527 | case "de": 528 | return "Mit dieser Option werden nur schwere Fehlermeldungen von OptiPNG gemeldet."; 529 | default: 530 | return "With this option checked, only fatal errors will be reported from OptiPNG."; 531 | } 532 | } 533 | } 534 | } 535 | } 536 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | ======= 2 | OptiPNG 3 | ======= 4 | 5 | Copyright (C) 2001-2007 Cosmin Truta. 6 | 7 | This software is provided 'as-is', without any express or implied 8 | warranty. In no event will the author(s) be held liable for any damages 9 | arising from the use of this software. 10 | 11 | Permission is granted to anyone to use this software for any purpose, 12 | including commercial applications, and to alter it and redistribute it 13 | freely, subject to the following restrictions: 14 | 15 | 1. The origin of this software must not be misrepresented; you must not 16 | claim that you wrote the original software. If you use this software 17 | in a product, an acknowledgment in the product documentation would be 18 | appreciated but is not required. 19 | 20 | 2. Altered source versions must be plainly marked as such, and must not 21 | be misrepresented as being the original software. 22 | 23 | 3. This notice may not be removed or altered from any source distribution. 24 | 25 | =========== 26 | Layer Saver 27 | =========== 28 | 29 | GNU GENERAL PUBLIC LICENSE 30 | Version 3, 29 June 2007 31 | 32 | Copyright (C) 2007 Free Software Foundation, Inc. 33 | Everyone is permitted to copy and distribute verbatim copies 34 | of this license document, but changing it is not allowed. 35 | 36 | Preamble 37 | 38 | The GNU General Public License is a free, copyleft license for 39 | software and other kinds of works. 40 | 41 | The licenses for most software and other practical works are designed 42 | to take away your freedom to share and change the works. By contrast, 43 | the GNU General Public License is intended to guarantee your freedom to 44 | share and change all versions of a program--to make sure it remains free 45 | software for all its users. We, the Free Software Foundation, use the 46 | GNU General Public License for most of our software; it applies also to 47 | any other work released this way by its authors. You can apply it to 48 | your programs, too. 49 | 50 | When we speak of free software, we are referring to freedom, not 51 | price. Our General Public Licenses are designed to make sure that you 52 | have the freedom to distribute copies of free software (and charge for 53 | them if you wish), that you receive source code or can get it if you 54 | want it, that you can change the software or use pieces of it in new 55 | free programs, and that you know you can do these things. 56 | 57 | To protect your rights, we need to prevent others from denying you 58 | these rights or asking you to surrender the rights. Therefore, you have 59 | certain responsibilities if you distribute copies of the software, or if 60 | you modify it: responsibilities to respect the freedom of others. 61 | 62 | For example, if you distribute copies of such a program, whether 63 | gratis or for a fee, you must pass on to the recipients the same 64 | freedoms that you received. You must make sure that they, too, receive 65 | or can get the source code. And you must show them these terms so they 66 | know their rights. 67 | 68 | Developers that use the GNU GPL protect your rights with two steps: 69 | (1) assert copyright on the software, and (2) offer you this License 70 | giving you legal permission to copy, distribute and/or modify it. 71 | 72 | For the developers' and authors' protection, the GPL clearly explains 73 | that there is no warranty for this free software. For both users' and 74 | authors' sake, the GPL requires that modified versions be marked as 75 | changed, so that their problems will not be attributed erroneously to 76 | authors of previous versions. 77 | 78 | Some devices are designed to deny users access to install or run 79 | modified versions of the software inside them, although the manufacturer 80 | can do so. This is fundamentally incompatible with the aim of 81 | protecting users' freedom to change the software. The systematic 82 | pattern of such abuse occurs in the area of products for individuals to 83 | use, which is precisely where it is most unacceptable. Therefore, we 84 | have designed this version of the GPL to prohibit the practice for those 85 | products. If such problems arise substantially in other domains, we 86 | stand ready to extend this provision to those domains in future versions 87 | of the GPL, as needed to protect the freedom of users. 88 | 89 | Finally, every program is threatened constantly by software patents. 90 | States should not allow patents to restrict development and use of 91 | software on general-purpose computers, but in those that do, we wish to 92 | avoid the special danger that patents applied to a free program could 93 | make it effectively proprietary. To prevent this, the GPL assures that 94 | patents cannot be used to render the program non-free. 95 | 96 | The precise terms and conditions for copying, distribution and 97 | modification follow. 98 | 99 | TERMS AND CONDITIONS 100 | 101 | 0. Definitions. 102 | 103 | "This License" refers to version 3 of the GNU General Public License. 104 | 105 | "Copyright" also means copyright-like laws that apply to other kinds of 106 | works, such as semiconductor masks. 107 | 108 | "The Program" refers to any copyrightable work licensed under this 109 | License. Each licensee is addressed as "you". "Licensees" and 110 | "recipients" may be individuals or organizations. 111 | 112 | To "modify" a work means to copy from or adapt all or part of the work 113 | in a fashion requiring copyright permission, other than the making of an 114 | exact copy. The resulting work is called a "modified version" of the 115 | earlier work or a work "based on" the earlier work. 116 | 117 | A "covered work" means either the unmodified Program or a work based 118 | on the Program. 119 | 120 | To "propagate" a work means to do anything with it that, without 121 | permission, would make you directly or secondarily liable for 122 | infringement under applicable copyright law, except executing it on a 123 | computer or modifying a private copy. Propagation includes copying, 124 | distribution (with or without modification), making available to the 125 | public, and in some countries other activities as well. 126 | 127 | To "convey" a work means any kind of propagation that enables other 128 | parties to make or receive copies. Mere interaction with a user through 129 | a computer network, with no transfer of a copy, is not conveying. 130 | 131 | An interactive user interface displays "Appropriate Legal Notices" 132 | to the extent that it includes a convenient and prominently visible 133 | feature that (1) displays an appropriate copyright notice, and (2) 134 | tells the user that there is no warranty for the work (except to the 135 | extent that warranties are provided), that licensees may convey the 136 | work under this License, and how to view a copy of this License. If 137 | the interface presents a list of user commands or options, such as a 138 | menu, a prominent item in the list meets this criterion. 139 | 140 | 1. Source Code. 141 | 142 | The "source code" for a work means the preferred form of the work 143 | for making modifications to it. "Object code" means any non-source 144 | form of a work. 145 | 146 | A "Standard Interface" means an interface that either is an official 147 | standard defined by a recognized standards body, or, in the case of 148 | interfaces specified for a particular programming language, one that 149 | is widely used among developers working in that language. 150 | 151 | The "System Libraries" of an executable work include anything, other 152 | than the work as a whole, that (a) is included in the normal form of 153 | packaging a Major Component, but which is not part of that Major 154 | Component, and (b) serves only to enable use of the work with that 155 | Major Component, or to implement a Standard Interface for which an 156 | implementation is available to the public in source code form. A 157 | "Major Component", in this context, means a major essential component 158 | (kernel, window system, and so on) of the specific operating system 159 | (if any) on which the executable work runs, or a compiler used to 160 | produce the work, or an object code interpreter used to run it. 161 | 162 | The "Corresponding Source" for a work in object code form means all 163 | the source code needed to generate, install, and (for an executable 164 | work) run the object code and to modify the work, including scripts to 165 | control those activities. However, it does not include the work's 166 | System Libraries, or general-purpose tools or generally available free 167 | programs which are used unmodified in performing those activities but 168 | which are not part of the work. For example, Corresponding Source 169 | includes interface definition files associated with source files for 170 | the work, and the source code for shared libraries and dynamically 171 | linked subprograms that the work is specifically designed to require, 172 | such as by intimate data communication or control flow between those 173 | subprograms and other parts of the work. 174 | 175 | The Corresponding Source need not include anything that users 176 | can regenerate automatically from other parts of the Corresponding 177 | Source. 178 | 179 | The Corresponding Source for a work in source code form is that 180 | same work. 181 | 182 | 2. Basic Permissions. 183 | 184 | All rights granted under this License are granted for the term of 185 | copyright on the Program, and are irrevocable provided the stated 186 | conditions are met. This License explicitly affirms your unlimited 187 | permission to run the unmodified Program. The output from running a 188 | covered work is covered by this License only if the output, given its 189 | content, constitutes a covered work. This License acknowledges your 190 | rights of fair use or other equivalent, as provided by copyright law. 191 | 192 | You may make, run and propagate covered works that you do not 193 | convey, without conditions so long as your license otherwise remains 194 | in force. You may convey covered works to others for the sole purpose 195 | of having them make modifications exclusively for you, or provide you 196 | with facilities for running those works, provided that you comply with 197 | the terms of this License in conveying all material for which you do 198 | not control copyright. Those thus making or running the covered works 199 | for you must do so exclusively on your behalf, under your direction 200 | and control, on terms that prohibit them from making any copies of 201 | your copyrighted material outside their relationship with you. 202 | 203 | Conveying under any other circumstances is permitted solely under 204 | the conditions stated below. Sublicensing is not allowed; section 10 205 | makes it unnecessary. 206 | 207 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 208 | 209 | No covered work shall be deemed part of an effective technological 210 | measure under any applicable law fulfilling obligations under article 211 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 212 | similar laws prohibiting or restricting circumvention of such 213 | measures. 214 | 215 | When you convey a covered work, you waive any legal power to forbid 216 | circumvention of technological measures to the extent such circumvention 217 | is effected by exercising rights under this License with respect to 218 | the covered work, and you disclaim any intention to limit operation or 219 | modification of the work as a means of enforcing, against the work's 220 | users, your or third parties' legal rights to forbid circumvention of 221 | technological measures. 222 | 223 | 4. Conveying Verbatim Copies. 224 | 225 | You may convey verbatim copies of the Program's source code as you 226 | receive it, in any medium, provided that you conspicuously and 227 | appropriately publish on each copy an appropriate copyright notice; 228 | keep intact all notices stating that this License and any 229 | non-permissive terms added in accord with section 7 apply to the code; 230 | keep intact all notices of the absence of any warranty; and give all 231 | recipients a copy of this License along with the Program. 232 | 233 | You may charge any price or no price for each copy that you convey, 234 | and you may offer support or warranty protection for a fee. 235 | 236 | 5. Conveying Modified Source Versions. 237 | 238 | You may convey a work based on the Program, or the modifications to 239 | produce it from the Program, in the form of source code under the 240 | terms of section 4, provided that you also meet all of these conditions: 241 | 242 | a) The work must carry prominent notices stating that you modified 243 | it, and giving a relevant date. 244 | 245 | b) The work must carry prominent notices stating that it is 246 | released under this License and any conditions added under section 247 | 7. This requirement modifies the requirement in section 4 to 248 | "keep intact all notices". 249 | 250 | c) You must license the entire work, as a whole, under this 251 | License to anyone who comes into possession of a copy. This 252 | License will therefore apply, along with any applicable section 7 253 | additional terms, to the whole of the work, and all its parts, 254 | regardless of how they are packaged. This License gives no 255 | permission to license the work in any other way, but it does not 256 | invalidate such permission if you have separately received it. 257 | 258 | d) If the work has interactive user interfaces, each must display 259 | Appropriate Legal Notices; however, if the Program has interactive 260 | interfaces that do not display Appropriate Legal Notices, your 261 | work need not make them do so. 262 | 263 | A compilation of a covered work with other separate and independent 264 | works, which are not by their nature extensions of the covered work, 265 | and which are not combined with it such as to form a larger program, 266 | in or on a volume of a storage or distribution medium, is called an 267 | "aggregate" if the compilation and its resulting copyright are not 268 | used to limit the access or legal rights of the compilation's users 269 | beyond what the individual works permit. Inclusion of a covered work 270 | in an aggregate does not cause this License to apply to the other 271 | parts of the aggregate. 272 | 273 | 6. Conveying Non-Source Forms. 274 | 275 | You may convey a covered work in object code form under the terms 276 | of sections 4 and 5, provided that you also convey the 277 | machine-readable Corresponding Source under the terms of this License, 278 | in one of these ways: 279 | 280 | a) Convey the object code in, or embodied in, a physical product 281 | (including a physical distribution medium), accompanied by the 282 | Corresponding Source fixed on a durable physical medium 283 | customarily used for software interchange. 284 | 285 | b) Convey the object code in, or embodied in, a physical product 286 | (including a physical distribution medium), accompanied by a 287 | written offer, valid for at least three years and valid for as 288 | long as you offer spare parts or customer support for that product 289 | model, to give anyone who possesses the object code either (1) a 290 | copy of the Corresponding Source for all the software in the 291 | product that is covered by this License, on a durable physical 292 | medium customarily used for software interchange, for a price no 293 | more than your reasonable cost of physically performing this 294 | conveying of source, or (2) access to copy the 295 | Corresponding Source from a network server at no charge. 296 | 297 | c) Convey individual copies of the object code with a copy of the 298 | written offer to provide the Corresponding Source. This 299 | alternative is allowed only occasionally and noncommercially, and 300 | only if you received the object code with such an offer, in accord 301 | with subsection 6b. 302 | 303 | d) Convey the object code by offering access from a designated 304 | place (gratis or for a charge), and offer equivalent access to the 305 | Corresponding Source in the same way through the same place at no 306 | further charge. You need not require recipients to copy the 307 | Corresponding Source along with the object code. If the place to 308 | copy the object code is a network server, the Corresponding Source 309 | may be on a different server (operated by you or a third party) 310 | that supports equivalent copying facilities, provided you maintain 311 | clear directions next to the object code saying where to find the 312 | Corresponding Source. Regardless of what server hosts the 313 | Corresponding Source, you remain obligated to ensure that it is 314 | available for as long as needed to satisfy these requirements. 315 | 316 | e) Convey the object code using peer-to-peer transmission, provided 317 | you inform other peers where the object code and Corresponding 318 | Source of the work are being offered to the general public at no 319 | charge under subsection 6d. 320 | 321 | A separable portion of the object code, whose source code is excluded 322 | from the Corresponding Source as a System Library, need not be 323 | included in conveying the object code work. 324 | 325 | A "User Product" is either (1) a "consumer product", which means any 326 | tangible personal property which is normally used for personal, family, 327 | or household purposes, or (2) anything designed or sold for incorporation 328 | into a dwelling. In determining whether a product is a consumer product, 329 | doubtful cases shall be resolved in favor of coverage. For a particular 330 | product received by a particular user, "normally used" refers to a 331 | typical or common use of that class of product, regardless of the status 332 | of the particular user or of the way in which the particular user 333 | actually uses, or expects or is expected to use, the product. A product 334 | is a consumer product regardless of whether the product has substantial 335 | commercial, industrial or non-consumer uses, unless such uses represent 336 | the only significant mode of use of the product. 337 | 338 | "Installation Information" for a User Product means any methods, 339 | procedures, authorization keys, or other information required to install 340 | and execute modified versions of a covered work in that User Product from 341 | a modified version of its Corresponding Source. The information must 342 | suffice to ensure that the continued functioning of the modified object 343 | code is in no case prevented or interfered with solely because 344 | modification has been made. 345 | 346 | If you convey an object code work under this section in, or with, or 347 | specifically for use in, a User Product, and the conveying occurs as 348 | part of a transaction in which the right of possession and use of the 349 | User Product is transferred to the recipient in perpetuity or for a 350 | fixed term (regardless of how the transaction is characterized), the 351 | Corresponding Source conveyed under this section must be accompanied 352 | by the Installation Information. But this requirement does not apply 353 | if neither you nor any third party retains the ability to install 354 | modified object code on the User Product (for example, the work has 355 | been installed in ROM). 356 | 357 | The requirement to provide Installation Information does not include a 358 | requirement to continue to provide support service, warranty, or updates 359 | for a work that has been modified or installed by the recipient, or for 360 | the User Product in which it has been modified or installed. Access to a 361 | network may be denied when the modification itself materially and 362 | adversely affects the operation of the network or violates the rules and 363 | protocols for communication across the network. 364 | 365 | Corresponding Source conveyed, and Installation Information provided, 366 | in accord with this section must be in a format that is publicly 367 | documented (and with an implementation available to the public in 368 | source code form), and must require no special password or key for 369 | unpacking, reading or copying. 370 | 371 | 7. Additional Terms. 372 | 373 | "Additional permissions" are terms that supplement the terms of this 374 | License by making exceptions from one or more of its conditions. 375 | Additional permissions that are applicable to the entire Program shall 376 | be treated as though they were included in this License, to the extent 377 | that they are valid under applicable law. If additional permissions 378 | apply only to part of the Program, that part may be used separately 379 | under those permissions, but the entire Program remains governed by 380 | this License without regard to the additional permissions. 381 | 382 | When you convey a copy of a covered work, you may at your option 383 | remove any additional permissions from that copy, or from any part of 384 | it. (Additional permissions may be written to require their own 385 | removal in certain cases when you modify the work.) You may place 386 | additional permissions on material, added by you to a covered work, 387 | for which you have or can give appropriate copyright permission. 388 | 389 | Notwithstanding any other provision of this License, for material you 390 | add to a covered work, you may (if authorized by the copyright holders of 391 | that material) supplement the terms of this License with terms: 392 | 393 | a) Disclaiming warranty or limiting liability differently from the 394 | terms of sections 15 and 16 of this License; or 395 | 396 | b) Requiring preservation of specified reasonable legal notices or 397 | author attributions in that material or in the Appropriate Legal 398 | Notices displayed by works containing it; or 399 | 400 | c) Prohibiting misrepresentation of the origin of that material, or 401 | requiring that modified versions of such material be marked in 402 | reasonable ways as different from the original version; or 403 | 404 | d) Limiting the use for publicity purposes of names of licensors or 405 | authors of the material; or 406 | 407 | e) Declining to grant rights under trademark law for use of some 408 | trade names, trademarks, or service marks; or 409 | 410 | f) Requiring indemnification of licensors and authors of that 411 | material by anyone who conveys the material (or modified versions of 412 | it) with contractual assumptions of liability to the recipient, for 413 | any liability that these contractual assumptions directly impose on 414 | those licensors and authors. 415 | 416 | All other non-permissive additional terms are considered "further 417 | restrictions" within the meaning of section 10. If the Program as you 418 | received it, or any part of it, contains a notice stating that it is 419 | governed by this License along with a term that is a further 420 | restriction, you may remove that term. If a license document contains 421 | a further restriction but permits relicensing or conveying under this 422 | License, you may add to a covered work material governed by the terms 423 | of that license document, provided that the further restriction does 424 | not survive such relicensing or conveying. 425 | 426 | If you add terms to a covered work in accord with this section, you 427 | must place, in the relevant source files, a statement of the 428 | additional terms that apply to those files, or a notice indicating 429 | where to find the applicable terms. 430 | 431 | Additional terms, permissive or non-permissive, may be stated in the 432 | form of a separately written license, or stated as exceptions; 433 | the above requirements apply either way. 434 | 435 | 8. Termination. 436 | 437 | You may not propagate or modify a covered work except as expressly 438 | provided under this License. Any attempt otherwise to propagate or 439 | modify it is void, and will automatically terminate your rights under 440 | this License (including any patent licenses granted under the third 441 | paragraph of section 11). 442 | 443 | However, if you cease all violation of this License, then your 444 | license from a particular copyright holder is reinstated (a) 445 | provisionally, unless and until the copyright holder explicitly and 446 | finally terminates your license, and (b) permanently, if the copyright 447 | holder fails to notify you of the violation by some reasonable means 448 | prior to 60 days after the cessation. 449 | 450 | Moreover, your license from a particular copyright holder is 451 | reinstated permanently if the copyright holder notifies you of the 452 | violation by some reasonable means, this is the first time you have 453 | received notice of violation of this License (for any work) from that 454 | copyright holder, and you cure the violation prior to 30 days after 455 | your receipt of the notice. 456 | 457 | Termination of your rights under this section does not terminate the 458 | licenses of parties who have received copies or rights from you under 459 | this License. If your rights have been terminated and not permanently 460 | reinstated, you do not qualify to receive new licenses for the same 461 | material under section 10. 462 | 463 | 9. Acceptance Not Required for Having Copies. 464 | 465 | You are not required to accept this License in order to receive or 466 | run a copy of the Program. Ancillary propagation of a covered work 467 | occurring solely as a consequence of using peer-to-peer transmission 468 | to receive a copy likewise does not require acceptance. However, 469 | nothing other than this License grants you permission to propagate or 470 | modify any covered work. These actions infringe copyright if you do 471 | not accept this License. Therefore, by modifying or propagating a 472 | covered work, you indicate your acceptance of this License to do so. 473 | 474 | 10. Automatic Licensing of Downstream Recipients. 475 | 476 | Each time you convey a covered work, the recipient automatically 477 | receives a license from the original licensors, to run, modify and 478 | propagate that work, subject to this License. You are not responsible 479 | for enforcing compliance by third parties with this License. 480 | 481 | An "entity transaction" is a transaction transferring control of an 482 | organization, or substantially all assets of one, or subdividing an 483 | organization, or merging organizations. If propagation of a covered 484 | work results from an entity transaction, each party to that 485 | transaction who receives a copy of the work also receives whatever 486 | licenses to the work the party's predecessor in interest had or could 487 | give under the previous paragraph, plus a right to possession of the 488 | Corresponding Source of the work from the predecessor in interest, if 489 | the predecessor has it or can get it with reasonable efforts. 490 | 491 | You may not impose any further restrictions on the exercise of the 492 | rights granted or affirmed under this License. For example, you may 493 | not impose a license fee, royalty, or other charge for exercise of 494 | rights granted under this License, and you may not initiate litigation 495 | (including a cross-claim or counterclaim in a lawsuit) alleging that 496 | any patent claim is infringed by making, using, selling, offering for 497 | sale, or importing the Program or any portion of it. 498 | 499 | 11. Patents. 500 | 501 | A "contributor" is a copyright holder who authorizes use under this 502 | License of the Program or a work on which the Program is based. The 503 | work thus licensed is called the contributor's "contributor version". 504 | 505 | A contributor's "essential patent claims" are all patent claims 506 | owned or controlled by the contributor, whether already acquired or 507 | hereafter acquired, that would be infringed by some manner, permitted 508 | by this License, of making, using, or selling its contributor version, 509 | but do not include claims that would be infringed only as a 510 | consequence of further modification of the contributor version. For 511 | purposes of this definition, "control" includes the right to grant 512 | patent sublicenses in a manner consistent with the requirements of 513 | this License. 514 | 515 | Each contributor grants you a non-exclusive, worldwide, royalty-free 516 | patent license under the contributor's essential patent claims, to 517 | make, use, sell, offer for sale, import and otherwise run, modify and 518 | propagate the contents of its contributor version. 519 | 520 | In the following three paragraphs, a "patent license" is any express 521 | agreement or commitment, however denominated, not to enforce a patent 522 | (such as an express permission to practice a patent or covenant not to 523 | sue for patent infringement). To "grant" such a patent license to a 524 | party means to make such an agreement or commitment not to enforce a 525 | patent against the party. 526 | 527 | If you convey a covered work, knowingly relying on a patent license, 528 | and the Corresponding Source of the work is not available for anyone 529 | to copy, free of charge and under the terms of this License, through a 530 | publicly available network server or other readily accessible means, 531 | then you must either (1) cause the Corresponding Source to be so 532 | available, or (2) arrange to deprive yourself of the benefit of the 533 | patent license for this particular work, or (3) arrange, in a manner 534 | consistent with the requirements of this License, to extend the patent 535 | license to downstream recipients. "Knowingly relying" means you have 536 | actual knowledge that, but for the patent license, your conveying the 537 | covered work in a country, or your recipient's use of the covered work 538 | in a country, would infringe one or more identifiable patents in that 539 | country that you have reason to believe are valid. 540 | 541 | If, pursuant to or in connection with a single transaction or 542 | arrangement, you convey, or propagate by procuring conveyance of, a 543 | covered work, and grant a patent license to some of the parties 544 | receiving the covered work authorizing them to use, propagate, modify 545 | or convey a specific copy of the covered work, then the patent license 546 | you grant is automatically extended to all recipients of the covered 547 | work and works based on it. 548 | 549 | A patent license is "discriminatory" if it does not include within 550 | the scope of its coverage, prohibits the exercise of, or is 551 | conditioned on the non-exercise of one or more of the rights that are 552 | specifically granted under this License. You may not convey a covered 553 | work if you are a party to an arrangement with a third party that is 554 | in the business of distributing software, under which you make payment 555 | to the third party based on the extent of your activity of conveying 556 | the work, and under which the third party grants, to any of the 557 | parties who would receive the covered work from you, a discriminatory 558 | patent license (a) in connection with copies of the covered work 559 | conveyed by you (or copies made from those copies), or (b) primarily 560 | for and in connection with specific products or compilations that 561 | contain the covered work, unless you entered into that arrangement, 562 | or that patent license was granted, prior to 28 March 2007. 563 | 564 | Nothing in this License shall be construed as excluding or limiting 565 | any implied license or other defenses to infringement that may 566 | otherwise be available to you under applicable patent law. 567 | 568 | 12. No Surrender of Others' Freedom. 569 | 570 | If conditions are imposed on you (whether by court order, agreement or 571 | otherwise) that contradict the conditions of this License, they do not 572 | excuse you from the conditions of this License. If you cannot convey a 573 | covered work so as to satisfy simultaneously your obligations under this 574 | License and any other pertinent obligations, then as a consequence you may 575 | not convey it at all. For example, if you agree to terms that obligate you 576 | to collect a royalty for further conveying from those to whom you convey 577 | the Program, the only way you could satisfy both those terms and this 578 | License would be to refrain entirely from conveying the Program. 579 | 580 | 13. Use with the GNU Affero General Public License. 581 | 582 | Notwithstanding any other provision of this License, you have 583 | permission to link or combine any covered work with a work licensed 584 | under version 3 of the GNU Affero General Public License into a single 585 | combined work, and to convey the resulting work. The terms of this 586 | License will continue to apply to the part which is the covered work, 587 | but the special requirements of the GNU Affero General Public License, 588 | section 13, concerning interaction through a network will apply to the 589 | combination as such. 590 | 591 | 14. Revised Versions of this License. 592 | 593 | The Free Software Foundation may publish revised and/or new versions of 594 | the GNU General Public License from time to time. Such new versions will 595 | be similar in spirit to the present version, but may differ in detail to 596 | address new problems or concerns. 597 | 598 | Each version is given a distinguishing version number. If the 599 | Program specifies that a certain numbered version of the GNU General 600 | Public License "or any later version" applies to it, you have the 601 | option of following the terms and conditions either of that numbered 602 | version or of any later version published by the Free Software 603 | Foundation. If the Program does not specify a version number of the 604 | GNU General Public License, you may choose any version ever published 605 | by the Free Software Foundation. 606 | 607 | If the Program specifies that a proxy can decide which future 608 | versions of the GNU General Public License can be used, that proxy's 609 | public statement of acceptance of a version permanently authorizes you 610 | to choose that version for the Program. 611 | 612 | Later license versions may give you additional or different 613 | permissions. However, no additional obligations are imposed on any 614 | author or copyright holder as a result of your choosing to follow a 615 | later version. 616 | 617 | 15. Disclaimer of Warranty. 618 | 619 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 620 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 621 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 622 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 623 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 624 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 625 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 626 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 627 | 628 | 16. Limitation of Liability. 629 | 630 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 631 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 632 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 633 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 634 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 635 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 636 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 637 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 638 | SUCH DAMAGES. 639 | 640 | 17. Interpretation of Sections 15 and 16. 641 | 642 | If the disclaimer of warranty and limitation of liability provided 643 | above cannot be given local legal effect according to their terms, 644 | reviewing courts shall apply local law that most closely approximates 645 | an absolute waiver of all civil liability in connection with the 646 | Program, unless a warranty or assumption of liability accompanies a 647 | copy of the Program in return for a fee. 648 | 649 | END OF TERMS AND CONDITIONS 650 | 651 | How to Apply These Terms to Your New Programs 652 | 653 | If you develop a new program, and you want it to be of the greatest 654 | possible use to the public, the best way to achieve this is to make it 655 | free software which everyone can redistribute and change under these terms. 656 | 657 | To do so, attach the following notices to the program. It is safest 658 | to attach them to the start of each source file to most effectively 659 | state the exclusion of warranty; and each file should have at least 660 | the "copyright" line and a pointer to where the full notice is found. 661 | 662 | 663 | Copyright (C) 664 | 665 | This program is free software: you can redistribute it and/or modify 666 | it under the terms of the GNU General Public License as published by 667 | the Free Software Foundation, either version 3 of the License, or 668 | (at your option) any later version. 669 | 670 | This program is distributed in the hope that it will be useful, 671 | but WITHOUT ANY WARRANTY; without even the implied warranty of 672 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 673 | GNU General Public License for more details. 674 | 675 | You should have received a copy of the GNU General Public License 676 | along with this program. If not, see . 677 | 678 | Also add information on how to contact you by electronic and paper mail. 679 | 680 | If the program does terminal interaction, make it output a short 681 | notice like this when it starts in an interactive mode: 682 | 683 | Copyright (C) 684 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 685 | This is free software, and you are welcome to redistribute it 686 | under certain conditions; type `show c' for details. 687 | 688 | The hypothetical commands `show w' and `show c' should show the appropriate 689 | parts of the General Public License. Of course, your program's commands 690 | might be different; for a GUI interface, you would use an "about box". 691 | 692 | You should also get your employer (if you work as a programmer) or school, 693 | if any, to sign a "copyright disclaimer" for the program, if necessary. 694 | For more information on this, and how to apply and follow the GNU GPL, see 695 | . 696 | 697 | The GNU General Public License does not permit incorporating your program 698 | into proprietary programs. If your program is a subroutine library, you 699 | may consider it more useful to permit linking proprietary applications with 700 | the library. If this is what you want to do, use the GNU Lesser General 701 | Public License instead of this License. But first, please read 702 | . 703 | -------------------------------------------------------------------------------- /OptiPngFileType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * OptiPNG file type 3 | * Copyright (C) 2008 ilikepi3142@gmail.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | using PaintDotNet; 20 | using System; 21 | using System.Diagnostics; 22 | using System.Drawing; 23 | using System.Drawing.Imaging; 24 | using System.IO; 25 | using System.Reflection; 26 | 27 | namespace ILikePi.FileTypes.OptiPng 28 | { 29 | public sealed class OptiPngFileTypeFactory : IFileTypeFactory 30 | { 31 | public FileType[] GetFileTypeInstances() 32 | { 33 | return new[] { new OptiPngFileType() }; 34 | } 35 | } 36 | 37 | internal class OptiPngFileType : FileType 38 | { 39 | private readonly string tempFile; 40 | private OptiPngSaveConfigToken tempFileToken; 41 | private Surface tempFileSurface; 42 | private static readonly string OptiPNGPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "optipng.exe"); 43 | 44 | internal OptiPngFileType() 45 | #if LEGACY 46 | : base(L10nStrings.EffectName, FileTypeFlags.SupportsLoading | FileTypeFlags.SupportsSaving, new[] { ".png" }) 47 | #else 48 | : base(L10nStrings.EffectName, new FileTypeOptions { SaveExtensions = new[] { ".png" }, LoadExtensions = new[] { ".png" } }) 49 | #endif 50 | { 51 | if (!File.Exists(OptiPNGPath)) 52 | { 53 | throw new FileNotFoundException("Please ensure you've installed optipng.exe into the FileTypes folder.", "optipng.exe"); 54 | } 55 | 56 | string path = Path.Combine(Path.GetTempPath(), "PDN_OptiPNG_"); 57 | Random rnd = new Random(); 58 | do 59 | { 60 | tempFile = path + rnd.Next() + ".png"; 61 | } while (File.Exists(tempFile)); 62 | } 63 | 64 | protected override Document OnLoad(Stream input) 65 | { 66 | using (Image image = Image.FromStream(input)) 67 | { 68 | return Document.FromImage(image); 69 | } 70 | } 71 | 72 | protected override bool IsReflexive(OptiPngSaveConfigToken token) 73 | { 74 | return token.Color == ColorMode.RGBAlpha; 75 | } 76 | 77 | protected override void OnSaveT(Document input, Stream output, OptiPngSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback) 78 | { 79 | using (RenderArgs ra = new RenderArgs(scratchSurface)) 80 | { 81 | input.Render(ra, true); 82 | } 83 | 84 | // Only do reductions, saving, and optimizing if the document changed 85 | // This is to prevent reoptimizing when the user finalizes the settings by clicking "OK" 86 | if (!token.Equals(tempFileToken) || !areSurfacesEqual(scratchSurface, tempFileSurface)) 87 | { 88 | tempFileToken = (OptiPngSaveConfigToken)token.Clone(); 89 | tempFileSurface?.Dispose(); 90 | tempFileSurface = scratchSurface.Clone(); 91 | 92 | // Color reductions 93 | if (token.Color == ColorMode.Grayscale || token.Color == ColorMode.RGB) 94 | { 95 | eliminateAlphaChannel(scratchSurface, token.MultiplyByAlphaChannel); 96 | } 97 | 98 | if (token.Color == ColorMode.Grayscale || token.Color == ColorMode.GrayscaleAlpha) 99 | { 100 | new UnaryPixelOps.Desaturate().Apply(scratchSurface, scratchSurface.Bounds); 101 | } 102 | 103 | Bitmap final = (token.Color == ColorMode.Palette) 104 | ? reduceToPalette(scratchSurface, token.DitheringLevel, token.TransparencyThreshold, progressCallback) 105 | : scratchSurface.CreateAliasedBitmap(); 106 | 107 | float dpiX; 108 | float dpiY; 109 | 110 | switch (input.DpuUnit) 111 | { 112 | case MeasurementUnit.Centimeter: 113 | dpiX = (float)Document.DotsPerCmToDotsPerInch(input.DpuX); 114 | dpiY = (float)Document.DotsPerCmToDotsPerInch(input.DpuY); 115 | break; 116 | 117 | case MeasurementUnit.Inch: 118 | dpiX = (float)input.DpuX; 119 | dpiY = (float)input.DpuY; 120 | break; 121 | 122 | case MeasurementUnit.Pixel: 123 | default: 124 | dpiX = 1.0f; 125 | dpiY = 1.0f; 126 | break; 127 | } 128 | 129 | final.SetResolution(dpiX, dpiY); 130 | final.Save(tempFile, ImageFormat.Png); 131 | final.Dispose(); 132 | 133 | // Optimize if user wants it 134 | if (token.Optimize) 135 | { 136 | string args = $"\"{tempFile}\" -o{token.Compression} -i{(token.Interlace ? "1" : "0")}{(token.Quiet ? " -quiet" : string.Empty)}"; 137 | ProcessStartInfo startInfo = new ProcessStartInfo(OptiPNGPath, args); 138 | if (token.Quiet) 139 | { 140 | startInfo.CreateNoWindow = true; 141 | startInfo.UseShellExecute = false; 142 | } 143 | else 144 | { 145 | startInfo.WindowStyle = ProcessWindowStyle.Minimized; 146 | } 147 | 148 | using (Process process = Process.Start(startInfo)) 149 | { 150 | process.WaitForExit(); 151 | } 152 | } 153 | } 154 | 155 | // Rewrite to target 156 | using (FileStream transfer = new FileStream(tempFile, FileMode.Open, FileAccess.Read)) 157 | { 158 | int bufferLength = (int)Math.Min(transfer.Length, 4096L); 159 | byte[] buffer = new byte[bufferLength]; 160 | 161 | long remaining = transfer.Length; 162 | int readLength = bufferLength; 163 | 164 | do 165 | { 166 | if (readLength > remaining) 167 | { 168 | readLength = (int)remaining; 169 | } 170 | 171 | int bytesRead = transfer.Read(buffer, 0, readLength); 172 | output.Write(buffer, 0, bytesRead); 173 | 174 | remaining -= bytesRead; 175 | } while (remaining > 0); 176 | } 177 | } 178 | 179 | private static unsafe void eliminateAlphaChannel(Surface surface, bool multByAlpha) 180 | { 181 | BinaryPixelOp blendOp = new UserBlendOps.NormalBlendOp(); 182 | for (int y = 0; y < surface.Height; y++) 183 | { 184 | ColorBgra* ptr = surface.GetRowAddressUnchecked(y); 185 | 186 | for (int x = 0; x < surface.Width; x++) 187 | { 188 | if (multByAlpha) 189 | { 190 | ptr->Bgra = blendOp.Apply(ColorBgra.White, *ptr).Bgra; 191 | } 192 | else if (ptr->A == 0) 193 | { 194 | ptr->Bgra = 0xFFFFFFFF; 195 | } 196 | else 197 | { 198 | ptr->A = 255; 199 | } 200 | ptr++; 201 | } 202 | } 203 | } 204 | 205 | private unsafe Bitmap reduceToPalette(Surface surface, byte ditheringLevel, byte threshold, ProgressEventHandler progressCallback) 206 | { 207 | BinaryPixelOp blendOp = new UserBlendOps.NormalBlendOp(); 208 | 209 | for (int y = 0; y < surface.Height; y++) 210 | { 211 | ColorBgra* ptr = surface.GetRowAddressUnchecked(y); 212 | 213 | for (int x = 0; x < surface.Width; x++) 214 | { 215 | if (ptr->A < threshold) 216 | { 217 | ptr->Bgra = 0x00000000; 218 | } 219 | else 220 | { 221 | ptr->Bgra = blendOp.Apply(ColorBgra.White, *ptr).Bgra; 222 | } 223 | ptr++; 224 | } 225 | } 226 | 227 | return Quantize(surface, ditheringLevel, 256, true, progressCallback); 228 | } 229 | 230 | private static unsafe bool areSurfacesEqual(Surface a, Surface b) 231 | { 232 | if (a == null || b == null) 233 | { 234 | return false; 235 | } 236 | if (!a.Size.Equals(b.Size)) 237 | { 238 | return false; 239 | } 240 | for (int y = 0; y < a.Height; y++) 241 | { 242 | ColorBgra* ptrA = a.GetRowAddressUnchecked(y); 243 | ColorBgra* ptrB = b.GetRowAddressUnchecked(y); 244 | for (int x = 0; x < a.Width; x++) 245 | { 246 | if (!ptrA->Equals(*ptrB)) 247 | { 248 | return false; 249 | } 250 | ptrA++; 251 | ptrB++; 252 | } 253 | } 254 | return true; 255 | } 256 | 257 | ~OptiPngFileType() 258 | { 259 | if (File.Exists(tempFile)) 260 | { 261 | File.Delete(tempFile); 262 | } 263 | } 264 | 265 | protected override OptiPngSaveConfigToken OnCreateDefaultSaveConfigTokenT() 266 | { 267 | return new OptiPngSaveConfigToken(); 268 | } 269 | 270 | protected override OptiPngSaveConfigWidget OnCreateSaveConfigWidgetT() 271 | { 272 | return new OptiPngSaveConfigWidget(); 273 | } 274 | } 275 | } 276 | -------------------------------------------------------------------------------- /OptiPngFileType.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9.0.21022 4 | ILikePi.FileTypes.OptiPng 5 | net47;net35 6 | false 7 | true 8 | bin\$(Configuration)\ 9 | 436 10 | 11 | 12 | full 13 | DEBUG 14 | 15 | 16 | pdbonly 17 | 18 | 19 | 20 | LEGACY 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | C:\Program Files\paint.net\PaintDotNet.Base.dll 31 | 32 | 33 | C:\Program Files\paint.net\PaintDotNet.Core.dll 34 | 35 | 36 | C:\Program Files\paint.net\PaintDotNet.Data.dll 37 | 38 | 39 | 40 | 41 | C:\Program Files\paint.net\3.5\PaintDotNet.Base.dll 42 | 43 | 44 | C:\Program Files\paint.net\3.5\PaintDotNet.Core.dll 45 | 46 | 47 | C:\Program Files\paint.net\3.5\PaintDotNet.Data.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | UserControl 57 | 58 | 59 | UserControl 60 | 61 | 62 | Component 63 | 64 | 65 | Component 66 | 67 | 68 | -------------------------------------------------------------------------------- /OptiPngFileType.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28803.352 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OptiPngFileType", "OptiPngFileType.csproj", "{819B81F6-97C9-48D5-904D-DF42CEA4C672}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {819B81F6-97C9-48D5-904D-DF42CEA4C672}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {819B81F6-97C9-48D5-904D-DF42CEA4C672}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {819B81F6-97C9-48D5-904D-DF42CEA4C672}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {819B81F6-97C9-48D5-904D-DF42CEA4C672}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /OptiPngSaveConfigToken.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * OptiPNG file type 3 | * Copyright (C) 2008 ilikepi3142@gmail.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | using PaintDotNet; 20 | using System; 21 | 22 | namespace ILikePi.FileTypes.OptiPng 23 | { 24 | internal enum ColorMode 25 | { 26 | Grayscale, 27 | RGB, 28 | Palette, 29 | GrayscaleAlpha, 30 | RGBAlpha 31 | } 32 | 33 | [Serializable] 34 | internal class OptiPngSaveConfigToken : SaveConfigToken 35 | { 36 | private byte compression; 37 | private byte ditheringLevel; 38 | 39 | public OptiPngSaveConfigToken() 40 | { 41 | Color = ColorMode.RGBAlpha; 42 | Compression = 2; 43 | DitheringLevel = 7; 44 | TransparencyThreshold = 128; 45 | MultiplyByAlphaChannel = true; 46 | Interlace = false; 47 | Optimize = true; 48 | Quiet = true; 49 | } 50 | 51 | public override object Clone() 52 | { 53 | return MemberwiseClone(); 54 | } 55 | 56 | public override void Validate() 57 | { 58 | validateCompression(compression); 59 | validateDitheringLevel(ditheringLevel); 60 | } 61 | 62 | public override bool Equals(object obj) 63 | { 64 | if (obj is OptiPngSaveConfigToken token) 65 | { 66 | return token.Color == Color 67 | && token.compression == compression 68 | && token.ditheringLevel == ditheringLevel 69 | && token.TransparencyThreshold == TransparencyThreshold 70 | && token.Interlace == Interlace 71 | && token.MultiplyByAlphaChannel == MultiplyByAlphaChannel 72 | && token.Optimize == Optimize 73 | && token.Quiet == Quiet; 74 | } 75 | 76 | return false; 77 | } 78 | 79 | public override int GetHashCode() 80 | { 81 | return (int)Color + compression * 3 + ditheringLevel * 7; 82 | } 83 | 84 | public ColorMode Color { get; set; } 85 | 86 | public byte Compression 87 | { 88 | get 89 | { 90 | return compression; 91 | } 92 | set 93 | { 94 | validateCompression(value); 95 | compression = value; 96 | } 97 | } 98 | 99 | public byte DitheringLevel 100 | { 101 | get 102 | { 103 | return ditheringLevel; 104 | } 105 | set 106 | { 107 | validateDitheringLevel(value); 108 | ditheringLevel = value; 109 | } 110 | } 111 | 112 | public byte TransparencyThreshold { get; set; } 113 | 114 | public bool MultiplyByAlphaChannel { get; set; } 115 | 116 | public bool Interlace { get; set; } 117 | 118 | public bool Optimize { get; set; } 119 | 120 | public bool Quiet { get; set; } 121 | 122 | private void validateCompression(byte value) 123 | { 124 | if (value > 7 || value < 1) 125 | { 126 | throw new ArgumentOutOfRangeException(); 127 | } 128 | } 129 | 130 | private void validateDitheringLevel(byte value) 131 | { 132 | if (value > 8) 133 | { 134 | throw new ArgumentOutOfRangeException(); 135 | } 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /OptiPngSaveConfigWidget.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * OptiPNG file type 3 | * Copyright (C) 2008 ilikepi3142@gmail.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | using PaintDotNet; 20 | using System; 21 | using System.ComponentModel; 22 | using System.Diagnostics; 23 | using System.Windows.Forms; 24 | 25 | namespace ILikePi.FileTypes.OptiPng 26 | { 27 | internal partial class OptiPngSaveConfigWidget : SaveConfigWidget 28 | { 29 | protected override OptiPngSaveConfigToken CreateTokenFromWidget() 30 | { 31 | OptiPngSaveConfigToken token = new OptiPngSaveConfigToken(); 32 | 33 | if (grayscale.Checked) 34 | { 35 | token.Color = ColorMode.Grayscale; 36 | } 37 | else if (rgb.Checked) 38 | { 39 | token.Color = ColorMode.RGB; 40 | } 41 | else if (palette.Checked) 42 | { 43 | token.Color = ColorMode.Palette; 44 | } 45 | else if (grayscaleA.Checked) 46 | { 47 | token.Color = ColorMode.GrayscaleAlpha; 48 | } 49 | else if (rgbA.Checked) 50 | { 51 | token.Color = ColorMode.RGBAlpha; 52 | } 53 | 54 | token.Compression = (byte)compression.Value; 55 | token.DitheringLevel = (byte)ditheringLevel.Value; 56 | token.TransparencyThreshold = (byte)transThresh.Value; 57 | token.MultiplyByAlphaChannel = multiplyByAlpha.Checked; 58 | token.Interlace = interlace.Checked; 59 | token.Optimize = optimize.Checked; 60 | token.Quiet = quiet.Checked; 61 | 62 | return token; 63 | } 64 | 65 | protected override void InitWidgetFromToken(OptiPngSaveConfigToken sourceToken) 66 | { 67 | switch (sourceToken.Color) 68 | { 69 | case ColorMode.Grayscale: 70 | grayscale.Checked = true; 71 | break; 72 | case ColorMode.RGB: 73 | rgb.Checked = true; 74 | break; 75 | case ColorMode.Palette: 76 | palette.Checked = true; 77 | break; 78 | case ColorMode.GrayscaleAlpha: 79 | grayscaleA.Checked = true; 80 | break; 81 | case ColorMode.RGBAlpha: 82 | rgbA.Checked = true; 83 | break; 84 | } 85 | 86 | compression.Value = sourceToken.Compression; 87 | ditheringLevel.Value = sourceToken.DitheringLevel; 88 | transThresh.Value = sourceToken.TransparencyThreshold; 89 | multiplyByAlpha.Checked = sourceToken.MultiplyByAlphaChannel; 90 | interlace.Checked = sourceToken.Interlace; 91 | optimize.Checked = sourceToken.Optimize; 92 | quiet.Checked = sourceToken.Quiet; 93 | 94 | enforceDependencies(); 95 | } 96 | 97 | private void tokenChanged(object sender, EventArgs e) 98 | { 99 | enforceDependencies(); 100 | UpdateToken(); 101 | } 102 | 103 | private void compression_ValueChanged(object sender, EventArgs e) 104 | { 105 | switch ((byte)compression.Value) 106 | { 107 | case 1: 108 | compressionComment.Text = L10nStrings.Trials1; 109 | break; 110 | case 2: 111 | compressionComment.Text = L10nStrings.Trials8; 112 | break; 113 | case 3: 114 | compressionComment.Text = L10nStrings.Trials16; 115 | break; 116 | case 4: 117 | compressionComment.Text = L10nStrings.Trials24; 118 | break; 119 | case 5: 120 | compressionComment.Text = L10nStrings.Trials48; 121 | break; 122 | case 6: 123 | compressionComment.Text = L10nStrings.Trials120; 124 | break; 125 | case 7: 126 | compressionComment.Text = L10nStrings.Trials240; 127 | break; 128 | } 129 | } 130 | 131 | private void optiPng_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 132 | { 133 | try 134 | { 135 | Process.Start("http://optipng.sourceforge.net/"); 136 | } 137 | catch (Win32Exception) 138 | { 139 | // Sometimes windows says file not found when Firefox takes too long to open 140 | } 141 | } 142 | 143 | private void enforceDependencies() 144 | { 145 | if (rgb.Checked || grayscale.Checked) 146 | { 147 | multiplyByAlpha.Enabled = true; 148 | } 149 | else 150 | { 151 | multiplyByAlpha.Checked = false; 152 | multiplyByAlpha.Enabled = false; 153 | } 154 | 155 | ditheringLevel.Enabled = palette.Checked; 156 | ditheringLabel.Enabled = palette.Checked; 157 | transThresh.Enabled = palette.Checked; 158 | transThreshLabel.Enabled = palette.Checked; 159 | 160 | if (optimize.Checked) 161 | { 162 | interlace.Enabled = true; 163 | compression.Enabled = true; 164 | compressionComment.Enabled = true; 165 | } 166 | else 167 | { 168 | interlace.Checked = false; 169 | interlace.Enabled = false; 170 | compression.Enabled = false; 171 | compressionComment.Enabled = false; 172 | } 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /OptiPngSaveConfigWidget.ui.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * OptiPNG file type 3 | * Copyright (C) 2008 ilikepi3142@gmail.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | using PaintDotNet; 20 | using System; 21 | using System.Windows.Forms; 22 | 23 | namespace ILikePi.FileTypes.OptiPng 24 | { 25 | internal partial class OptiPngSaveConfigWidget 26 | { 27 | private static readonly Padding firstIndent = new Padding(0, 0, 0, 0); 28 | private static readonly Padding secondIndent = new Padding(16, 0, 0, 0); 29 | private readonly int NUD_WIDTH = 50; 30 | 31 | private RadioButton grayscale; 32 | private RadioButton rgb; 33 | private CheckBox multiplyByAlpha; 34 | private RadioButton palette; 35 | private Label ditheringLabel; 36 | private NumericUpDown ditheringLevel; 37 | private Label transThreshLabel; 38 | private NumericUpDown transThresh; 39 | private RadioButton grayscaleA; 40 | private RadioButton rgbA; 41 | 42 | private CheckBox optimize; 43 | private NumericUpDown compression; 44 | private Label compressionComment; 45 | private CheckBox interlace; 46 | private CheckBox quiet; 47 | 48 | private LinkLabel optiPng; 49 | 50 | public OptiPngSaveConfigWidget() 51 | : base(new OptiPngFileType()) 52 | { 53 | AutoSize = true; 54 | 55 | NUD_WIDTH = (int)(NUD_WIDTH * this.AutoScaleDimensions.Width / 96f); 56 | 57 | TableLayoutPanel main = new TableLayoutPanel 58 | { 59 | Dock = DockStyle.Fill, 60 | AutoSize = true 61 | }; 62 | 63 | ToolTip toolTip = new ToolTip(); 64 | initColors(toolTip, main); 65 | initCompression(toolTip, main); 66 | 67 | string poweredBy = L10nStrings.PoweredByOptiPNG; 68 | 69 | optiPng = new LinkLabel 70 | { 71 | AutoSize = true, 72 | LinkArea = new LinkArea(poweredBy.Length - 7, 7), 73 | Margin = new Padding(3, 10, 0, 0), 74 | Text = poweredBy 75 | }; 76 | optiPng.LinkClicked += optiPng_LinkClicked; 77 | main.Controls.Add(optiPng); 78 | 79 | InitWidgetFromToken(new OptiPngSaveConfigToken()); 80 | 81 | Controls.Add(main); 82 | } 83 | 84 | private void initColors(ToolTip toolTip, TableLayoutPanel main) 85 | { 86 | HeaderLabel colorHeader = newHeader(L10nStrings.ColorReduction); 87 | main.Controls.Add(colorHeader); 88 | 89 | grayscale = createBaseRadioBtn(); 90 | grayscale.Text = L10nStrings.Grayscale; 91 | grayscale.Margin = firstIndent; 92 | toolTip.SetToolTip(grayscale, L10nStrings.GrayscaleDescription); 93 | grayscale.CheckedChanged += tokenChanged; 94 | main.Controls.Add(grayscale); 95 | 96 | rgb = createBaseRadioBtn(); 97 | rgb.Text = L10nStrings.Rgb; 98 | rgb.Margin = firstIndent; 99 | toolTip.SetToolTip(rgb, L10nStrings.RgbDescription); 100 | rgb.CheckedChanged += tokenChanged; 101 | main.Controls.Add(rgb); 102 | 103 | multiplyByAlpha = createBaseChkBox(); 104 | multiplyByAlpha.Text = L10nStrings.MultiplyByAlpha; 105 | multiplyByAlpha.Margin = secondIndent; 106 | toolTip.SetToolTip(multiplyByAlpha, L10nStrings.MultiplyByAlphaDescription); 107 | multiplyByAlpha.CheckedChanged += tokenChanged; 108 | main.Controls.Add(multiplyByAlpha); 109 | 110 | palette = createBaseRadioBtn(); 111 | palette.Text = L10nStrings.Palette; 112 | palette.Margin = firstIndent; 113 | toolTip.SetToolTip(palette, L10nStrings.PaletteDescription); 114 | palette.CheckedChanged += tokenChanged; 115 | main.Controls.Add(palette); 116 | 117 | TableLayoutPanel dithering = new TableLayoutPanel 118 | { 119 | Dock = DockStyle.Fill, 120 | AutoSize = true, 121 | Margin = secondIndent 122 | }; 123 | 124 | ditheringLabel = new Label 125 | { 126 | Anchor = AnchorStyles.Left, 127 | AutoSize = true, 128 | Text = L10nStrings.DitheringLevel, 129 | Margin = Padding.Empty 130 | }; 131 | dithering.Controls.Add(ditheringLabel, 0, 0); 132 | 133 | ditheringLevel = new NumericUpDown 134 | { 135 | Width = NUD_WIDTH, 136 | Margin = Padding.Empty, 137 | Maximum = 8 138 | }; 139 | ditheringLevel.ValueChanged += tokenChanged; 140 | dithering.Controls.Add(ditheringLevel, 1, 0); 141 | 142 | transThreshLabel = new Label 143 | { 144 | Anchor = AnchorStyles.Left, 145 | AutoSize = true, 146 | Text = L10nStrings.TransparencyThreshold, 147 | Margin = Padding.Empty 148 | }; 149 | dithering.Controls.Add(transThreshLabel, 0, 1); 150 | 151 | transThresh = new NumericUpDown 152 | { 153 | Width = NUD_WIDTH, 154 | Margin = new Padding(0, 3, 0, 0), 155 | Maximum = 255 156 | }; 157 | toolTip.SetToolTip(transThresh, L10nStrings.TransparencyThresholdDescription); 158 | transThresh.ValueChanged += tokenChanged; 159 | dithering.Controls.Add(transThresh, 1, 1); 160 | 161 | main.Controls.Add(dithering); 162 | 163 | grayscaleA = createBaseRadioBtn(); 164 | grayscaleA.Text = L10nStrings.GrayScaleWithAlpha; 165 | grayscaleA.Margin = firstIndent; 166 | toolTip.SetToolTip(grayscaleA, L10nStrings.GrayScaleWithAlphaDescription); 167 | grayscaleA.CheckedChanged += tokenChanged; 168 | main.Controls.Add(grayscaleA); 169 | 170 | rgbA = createBaseRadioBtn(); 171 | rgbA.Text = L10nStrings.RgbWithAlpha; 172 | rgbA.Margin = firstIndent; 173 | toolTip.SetToolTip(rgbA, L10nStrings.RgbWithAlphaDescription); 174 | rgbA.CheckedChanged += tokenChanged; 175 | main.Controls.Add(rgbA); 176 | } 177 | 178 | private void initCompression(ToolTip toolTip, TableLayoutPanel main) 179 | { 180 | HeaderLabel compressionHeader = newHeader(L10nStrings.Compression); 181 | main.Controls.Add(compressionHeader); 182 | 183 | optimize = createBaseChkBox(); 184 | optimize.Text = L10nStrings.Optimize; 185 | optimize.Margin = firstIndent; 186 | toolTip.SetToolTip(optimize, L10nStrings.OptimizeDescription); 187 | optimize.CheckedChanged += tokenChanged; 188 | main.Controls.Add(optimize); 189 | 190 | TableLayoutPanel compressionPanel = new TableLayoutPanel 191 | { 192 | Dock = DockStyle.Fill, 193 | AutoSize = true, 194 | Margin = firstIndent 195 | }; 196 | 197 | compression = new NumericUpDown 198 | { 199 | Width = NUD_WIDTH, 200 | Maximum = 7, 201 | Minimum = 1, 202 | Margin = Padding.Empty 203 | }; 204 | toolTip.SetToolTip(compression, L10nStrings.CompressionDescription); 205 | compression.ValueChanged += tokenChanged; 206 | compression.ValueChanged += compression_ValueChanged; 207 | compressionPanel.Controls.Add(compression, 0, 0); 208 | 209 | compressionComment = new Label 210 | { 211 | Anchor = AnchorStyles.Left, 212 | AutoSize = true, 213 | Margin = Padding.Empty 214 | }; 215 | compressionPanel.Controls.Add(compressionComment, 1, 0); 216 | 217 | main.Controls.Add(compressionPanel); 218 | 219 | interlace = createBaseChkBox(); 220 | interlace.Text = L10nStrings.Interlace; 221 | interlace.Margin = firstIndent; 222 | toolTip.SetToolTip(interlace, L10nStrings.InterlaceDescription); 223 | interlace.CheckedChanged += tokenChanged; 224 | main.Controls.Add(interlace); 225 | 226 | quiet = createBaseChkBox(); 227 | quiet.Text = L10nStrings.QuietMode; 228 | quiet.Margin = firstIndent; 229 | toolTip.SetToolTip(quiet, L10nStrings.QuietModeDescription); 230 | quiet.CheckedChanged += tokenChanged; 231 | main.Controls.Add(quiet); 232 | } 233 | 234 | private RadioButton createBaseRadioBtn() 235 | { 236 | return new RadioButton 237 | { 238 | AutoSize = true 239 | }; 240 | } 241 | 242 | private CheckBox createBaseChkBox() 243 | { 244 | return new CheckBox 245 | { 246 | AutoSize = true 247 | }; 248 | } 249 | 250 | private HeaderLabel newHeader(string text) 251 | { 252 | return new HeaderLabel 253 | { 254 | Dock = DockStyle.Fill, 255 | Text = text 256 | }; 257 | } 258 | 259 | protected override void OnForeColorChanged(EventArgs e) 260 | { 261 | base.OnForeColorChanged(e); 262 | 263 | optiPng.LinkColor = ForeColor; 264 | } 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /PaintDotNet/EtchedLine.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Paint.NET // 3 | // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. // 4 | // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. // 5 | // See src/Resources/Files/License.txt for full licensing and attribution // 6 | // details. // 7 | // . // 8 | ///////////////////////////////////////////////////////////////////////////////// 9 | 10 | using System.ComponentModel; 11 | using System.Drawing; 12 | using System.Windows.Forms; 13 | using System.Windows.Forms.VisualStyles; 14 | 15 | namespace PaintDotNet 16 | { 17 | internal sealed class EtchedLine 18 | : Control 19 | { 20 | private bool selfDrawn = false; 21 | private Label label; 22 | 23 | public void InitForCurrentVisualStyle() 24 | { 25 | // If we are Vista Aero, draw using a GroupBox 26 | // Else, use the "etched line via a label w/ a border style" trick 27 | // We would use the "GroupBox" style w/ Luna, except that it wasn't 28 | // working correctly for some reason. 29 | 30 | switch (UI.VisualStyleClass) 31 | { 32 | case VisualStyleClass.Aero: 33 | this.selfDrawn = true; 34 | break; 35 | 36 | case VisualStyleClass.Luna: 37 | case VisualStyleClass.Classic: 38 | case VisualStyleClass.Other: 39 | this.selfDrawn = false; 40 | break; 41 | 42 | default: 43 | throw new InvalidEnumArgumentException(); 44 | } 45 | 46 | if (this.selfDrawn && (this.label != null && Controls.Contains(this.label))) 47 | { 48 | SuspendLayout(); 49 | Controls.Remove(this.label); 50 | ResumeLayout(false); 51 | PerformLayout(); 52 | Invalidate(true); 53 | } 54 | else if (!this.selfDrawn && (this.label != null || !Controls.Contains(this.label))) 55 | { 56 | if (this.label == null) 57 | { 58 | this.label = new Label 59 | { 60 | BorderStyle = BorderStyle.Fixed3D 61 | }; 62 | } 63 | 64 | SuspendLayout(); 65 | Controls.Add(this.label); 66 | ResumeLayout(false); 67 | PerformLayout(); 68 | Invalidate(true); 69 | } 70 | } 71 | 72 | public EtchedLine() 73 | { 74 | InitForCurrentVisualStyle(); 75 | DoubleBuffered = true; 76 | ResizeRedraw = true; 77 | TabStop = false; 78 | SetStyle(ControlStyles.Selectable, false); 79 | } 80 | 81 | public override Size GetPreferredSize(Size proposedSize) 82 | { 83 | return new Size(proposedSize.Width, 2); 84 | } 85 | 86 | protected override void OnPaint(PaintEventArgs e) 87 | { 88 | if (this.selfDrawn) 89 | { 90 | GroupBoxRenderer.DrawGroupBox(e.Graphics, new Rectangle(0, 0, Width, 1), GroupBoxState.Normal); 91 | } 92 | 93 | base.OnPaint(e); 94 | } 95 | 96 | protected override void OnLayout(LayoutEventArgs levent) 97 | { 98 | if (!this.selfDrawn) 99 | { 100 | this.label.Bounds = new Rectangle(0, 0, Width, Height); 101 | } 102 | 103 | base.OnLayout(levent); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /PaintDotNet/HeaderLabel.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Paint.NET // 3 | // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. // 4 | // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. // 5 | // See src/Resources/Files/License.txt for full licensing and attribution // 6 | // details. // 7 | // . // 8 | ///////////////////////////////////////////////////////////////////////////////// 9 | 10 | using System; 11 | using System.ComponentModel; 12 | using System.Drawing; 13 | using System.Windows.Forms; 14 | 15 | namespace PaintDotNet 16 | { 17 | internal sealed class HeaderLabel 18 | : Control 19 | { 20 | private const TextFormatFlags textFormatFlags = 21 | TextFormatFlags.Default | 22 | TextFormatFlags.EndEllipsis | 23 | TextFormatFlags.HidePrefix | 24 | TextFormatFlags.NoPadding | 25 | TextFormatFlags.NoPrefix | 26 | TextFormatFlags.SingleLine; 27 | 28 | private int leftMargin = 0; 29 | private int rightMargin = 8; 30 | 31 | private EtchedLine etchedLine; 32 | 33 | [DefaultValue(8)] 34 | public int RightMargin 35 | { 36 | get 37 | { 38 | return this.rightMargin; 39 | } 40 | 41 | set 42 | { 43 | this.rightMargin = value; 44 | PerformLayout(); 45 | } 46 | } 47 | 48 | protected override void OnFontChanged(EventArgs e) 49 | { 50 | PerformLayout(); 51 | Refresh(); 52 | base.OnFontChanged(e); 53 | } 54 | 55 | protected override void OnTextChanged(EventArgs e) 56 | { 57 | PerformLayout(); 58 | Refresh(); 59 | base.OnTextChanged(e); 60 | } 61 | 62 | public HeaderLabel() 63 | { 64 | SetStyle(ControlStyles.AllPaintingInWmPaint, true); 65 | SetStyle(ControlStyles.Opaque, true); 66 | SetStyle(ControlStyles.ResizeRedraw, true); 67 | SetStyle(ControlStyles.UserPaint, true); 68 | SetStyle(ControlStyles.Selectable, false); 69 | UI.InitScaling(null); 70 | TabStop = false; 71 | DoubleBuffered = true; 72 | ResizeRedraw = true; 73 | 74 | SuspendLayout(); 75 | this.etchedLine = new EtchedLine(); 76 | Controls.Add(this.etchedLine); 77 | Size = new Size(144, 14); 78 | ResumeLayout(false); 79 | } 80 | 81 | private int GetPreferredWidth(Size proposedSize) 82 | { 83 | Size textSize = GetTextSize(); 84 | return this.leftMargin + textSize.Width; 85 | } 86 | 87 | public override Size GetPreferredSize(Size proposedSize) 88 | { 89 | return new Size(Math.Max(proposedSize.Width, GetPreferredWidth(proposedSize)), GetTextSize().Height); 90 | } 91 | 92 | private Size GetTextSize() 93 | { 94 | string textToUse = string.IsNullOrEmpty(Text) ? " " : Text; 95 | 96 | Size size = TextRenderer.MeasureText(textToUse, this.Font, this.ClientSize, textFormatFlags); 97 | 98 | if (string.IsNullOrEmpty(Text)) 99 | { 100 | size.Width = 0; 101 | } 102 | 103 | return size; 104 | } 105 | 106 | protected override void OnLayout(LayoutEventArgs levent) 107 | { 108 | Size textSize = GetTextSize(); 109 | 110 | Size = new Size(Size.Width, textSize.Height); 111 | 112 | int lineLeft = (string.IsNullOrEmpty(this.Text) ? 0 : this.leftMargin) + textSize.Width + (string.IsNullOrEmpty(this.Text) ? 0 : 1); 113 | int lineRight = ClientRectangle.Right - this.rightMargin; 114 | 115 | this.etchedLine.Size = this.etchedLine.GetPreferredSize(new Size(lineRight - lineLeft, 1)); 116 | this.etchedLine.Location = new Point(lineLeft, (ClientSize.Height - this.etchedLine.Height) / 2); 117 | 118 | base.OnLayout(levent); 119 | } 120 | 121 | protected override void OnPaint(PaintEventArgs e) 122 | { 123 | using (SolidBrush backBrush = new SolidBrush(BackColor)) 124 | { 125 | e.Graphics.FillRectangle(backBrush, e.ClipRectangle); 126 | } 127 | 128 | TextRenderer.DrawText(e.Graphics, this.Text, this.Font, new Point(this.leftMargin, 0), this.ForeColor, textFormatFlags); 129 | 130 | base.OnPaint(e); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /PaintDotNet/UI.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Paint.NET // 3 | // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. // 4 | // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. // 5 | // See src/Resources/Files/License.txt for full licensing and attribution // 6 | // details. // 7 | // . // 8 | ///////////////////////////////////////////////////////////////////////////////// 9 | 10 | 11 | using System; 12 | using System.Drawing; 13 | using System.Windows.Forms; 14 | using System.Windows.Forms.VisualStyles; 15 | 16 | namespace PaintDotNet 17 | { 18 | 19 | 20 | /// 21 | /// Contains static methods related to the user interface. 22 | /// 23 | internal static class UI 24 | { 25 | private static bool initScales = false; 26 | private static float xScale; 27 | 28 | private static void InitScaleFactors(Control c) 29 | { 30 | if (c == null) 31 | { 32 | xScale = 1.0f; 33 | } 34 | else 35 | { 36 | using (Graphics g = c.CreateGraphics()) 37 | { 38 | xScale = g.DpiX / 96.0f; 39 | } 40 | } 41 | 42 | initScales = true; 43 | } 44 | 45 | public static void InitScaling(Control c) 46 | { 47 | if (!initScales) 48 | { 49 | InitScaleFactors(c); 50 | } 51 | } 52 | 53 | private static VisualStyleClass DetermineVisualStyleClassImpl() 54 | { 55 | VisualStyleClass vsClass; 56 | 57 | try 58 | { 59 | if (!VisualStyleInformation.IsSupportedByOS) 60 | { 61 | vsClass = VisualStyleClass.Classic; 62 | } 63 | else if (!VisualStyleInformation.IsEnabledByUser) 64 | { 65 | vsClass = VisualStyleClass.Classic; 66 | } 67 | else if (0 == string.Compare(VisualStyleInformation.Author, "MSX", StringComparison.InvariantCulture) && 68 | 0 == string.Compare(VisualStyleInformation.DisplayName, "Aero style", StringComparison.InvariantCulture)) 69 | { 70 | vsClass = VisualStyleClass.Aero; 71 | } 72 | else if (0 == string.Compare(VisualStyleInformation.Company, "Microsoft Corporation", StringComparison.InvariantCulture) && 73 | 0 == string.Compare(VisualStyleInformation.Author, "Microsoft Design Team", StringComparison.InvariantCulture)) 74 | { 75 | if (0 == string.Compare(VisualStyleInformation.DisplayName, "Windows XP style", StringComparison.InvariantCulture) || // Luna 76 | 0 == string.Compare(VisualStyleInformation.DisplayName, "Zune Style", StringComparison.InvariantCulture) || // Zune 77 | 0 == string.Compare(VisualStyleInformation.DisplayName, "Media Center style", StringComparison.InvariantCulture)) // Royale 78 | { 79 | vsClass = VisualStyleClass.Luna; 80 | } 81 | else 82 | { 83 | vsClass = VisualStyleClass.Other; 84 | } 85 | } 86 | else 87 | { 88 | vsClass = VisualStyleClass.Other; 89 | } 90 | } 91 | catch (Exception) 92 | { 93 | vsClass = VisualStyleClass.Other; 94 | } 95 | 96 | return vsClass; 97 | } 98 | 99 | public static VisualStyleClass VisualStyleClass 100 | { 101 | get 102 | { 103 | return DetermineVisualStyleClassImpl(); 104 | } 105 | } 106 | 107 | public static float GetXScaleFactor() 108 | { 109 | if (!initScales) 110 | { 111 | throw new InvalidOperationException("Must call InitScaling() first"); 112 | } 113 | 114 | return xScale; 115 | } 116 | 117 | public static int ScaleWidth(int width) 118 | { 119 | return (int)Math.Round((float)width * GetXScaleFactor()); 120 | } 121 | 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /PaintDotNet/VisualStyleClass.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Paint.NET // 3 | // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. // 4 | // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. // 5 | // See src/Resources/Files/License.txt for full licensing and attribution // 6 | // details. // 7 | // . // 8 | ///////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace PaintDotNet 11 | { 12 | internal enum VisualStyleClass 13 | { 14 | Classic, 15 | Luna, // also covers Royale, which is a derivative of Luna 16 | Aero, 17 | Other 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("OptiPNG plugin for Paint.NET")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("ilikepi3142@gmail.com")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("(C) 2008 ilikepi3142@gmail.com")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("a9fde377-b0a4-4ba1-8278-2273486bbef3")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | [assembly: AssemblyVersion("11.1.0.0")] 32 | [assembly: AssemblyFileVersion("11.1.0.0")] 33 | --------------------------------------------------------------------------------