| 1 | <!DOCTYPE html> |
| 2 | <html><head> |
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 4 | <title>highlight.pb</title> |
| 5 | <meta name="generator" content="KF5::SyntaxHighlighting - Definition (PureBasic) - Theme (Breeze Light)"/> |
| 6 | </head><body style="background-color:#ffffff;color:#1f1c1b"><pre> |
| 7 | <span style="color:#898887">; This is a test file for kate's PureBasic highlighting.</span> |
| 8 | |
| 9 | <span style="color:#898887">; BMP2x Converter by Sven Langenkamp</span> |
| 10 | |
| 11 | <span style="color:#644a9b">UseJPEGImageEncoder</span>() |
| 12 | <span style="color:#644a9b">UsePNGImageEncoder</span>() |
| 13 | |
| 14 | <span style="font-weight:bold">Declare</span> Convert(JPEG) |
| 15 | |
| 16 | <span style="font-weight:bold">Enumeration </span><span style="color:#b08000">1</span> |
| 17 | <span style="color:#0057ae">#JPEG</span> |
| 18 | <span style="color:#0057ae">#PNG</span> |
| 19 | <span style="font-weight:bold">EndEnumeration</span> |
| 20 | |
| 21 | <span style="color:#0057ae;background-color:#e0e9f8">; BEGIN section</span> |
| 22 | |
| 23 | |
| 24 | <span style="color:#0057ae;background-color:#e0e9f8">; END</span> |
| 25 | |
| 26 | <span style="font-weight:bold">Global</span> Count |
| 27 | <span style="font-weight:bold">Global</span> file.s |
| 28 | <span style="font-weight:bold">Global</span> filename.s |
| 29 | <span style="font-weight:bold">Global</span> fileext.s |
| 30 | <span style="font-weight:bold">Global</span> OutputFormat |
| 31 | <span style="font-weight:bold">Global</span> JPEGQuality |
| 32 | |
| 33 | Count <span style="color:#ca60ca">=</span> <span style="color:#b08000">0</span> |
| 34 | OutputFormat <span style="color:#ca60ca">=</span> <span style="color:#b08000">1</span> |
| 35 | JPEGQuality <span style="color:#ca60ca">=</span> <span style="color:#ca60ca">-</span><span style="color:#b08000">1</span> |
| 36 | |
| 37 | <span style="color:#898887">; MAIN PROGRAM------------------------------------------------------------------</span> |
| 38 | |
| 39 | <span style="color:#898887">;Request Options</span> |
| 40 | <span style="color:#644a9b">PrintN</span>(<span style="color:#bf0303">"Output Format"</span>) |
| 41 | <span style="color:#644a9b">PrintN</span>(<span style="color:#bf0303">" [1] JPEG"</span>) |
| 42 | <span style="color:#644a9b">PrintN</span>(<span style="color:#bf0303">" [2] PNG"</span>) |
| 43 | <span style="color:#644a9b">Print</span> (<span style="color:#bf0303">"> "</span>) |
| 44 | OutputFormat <span style="color:#ca60ca">=</span> <span style="color:#644a9b">Int</span>(<span style="color:#644a9b">Input</span>()) |
| 45 | |
| 46 | <span style="font-weight:bold">Select </span>OutputFormat |
| 47 | <span style="font-weight:bold">Case</span> <span style="color:#0057ae">#JPEG</span>: |
| 48 | fileext <span style="color:#ca60ca">=</span> <span style="color:#bf0303">".jpg"</span> |
| 49 | <span style="color:#898887">;Request JPEG Quality</span> |
| 50 | <span style="color:#644a9b">PrintN</span>(<span style="color:#bf0303">""</span>) |
| 51 | <span style="color:#644a9b">PrintN</span>(<span style="color:#bf0303">"JPEG Quality"</span>) |
| 52 | <span style="color:#644a9b">PrintN</span>(<span style="color:#bf0303">" [0-10]"</span>) |
| 53 | <span style="color:#644a9b">Print</span> (<span style="color:#bf0303">"> "</span>) |
| 54 | JPEGQuality <span style="color:#ca60ca">=</span> <span style="color:#644a9b">Int</span>(<span style="color:#644a9b">Input</span>()) |
| 55 | |
| 56 | <span style="font-weight:bold">Case</span> <span style="color:#0057ae">#PNG</span>: |
| 57 | fileext <span style="color:#ca60ca">=</span> <span style="color:#bf0303">".png"</span> |
| 58 | <span style="font-weight:bold">EndSelect</span> |
| 59 | |
| 60 | <span style="color:#898887">;Convert all BMP files in the current directory</span> |
| 61 | <span style="color:#644a9b">ExamineDirectory</span>(<span style="color:#b08000">0</span>, <span style="color:#bf0303">""</span>, <span style="color:#bf0303">"*.bmp"</span>) |
| 62 | <span style="font-weight:bold">While </span><span style="color:#644a9b">NextDirectoryEntry</span>() |
| 63 | file <span style="color:#ca60ca">=</span> <span style="color:#644a9b">DirectoryEntryName</span>() |
| 64 | filename <span style="color:#ca60ca">=</span> <span style="color:#644a9b">GetFilePart</span>(file) |
| 65 | |
| 66 | <span style="font-weight:bold">If </span><span style="color:#644a9b">LoadImage</span>(<span style="color:#b08000">0</span>, file) |
| 67 | <span style="font-weight:bold">Select </span>OutputFormat |
| 68 | <span style="font-weight:bold">Case</span> <span style="color:#0057ae">#JPEG</span>: |
| 69 | Convert(JPEGQuality) |
| 70 | |
| 71 | <span style="font-weight:bold">Case</span> <span style="color:#0057ae">#PNG</span>: |
| 72 | Convert(<span style="color:#ca60ca">-</span><span style="color:#b08000">1</span>) |
| 73 | <span style="font-weight:bold">EndSelect</span> |
| 74 | Count <span style="color:#ca60ca">=</span> Count <span style="color:#ca60ca">+</span><span style="color:#b08000">1</span> |
| 75 | <span style="font-weight:bold">EndIf</span> |
| 76 | |
| 77 | <span style="font-weight:bold">Wend</span> |
| 78 | |
| 79 | <span style="color:#644a9b">PrintN</span>(<span style="color:#644a9b">Str</span>(Count) <span style="color:#ca60ca">+</span> <span style="color:#bf0303">" files converted"</span>) |
| 80 | <span style="color:#644a9b">CloseConsole</span>() |
| 81 | |
| 82 | <span style="color:#898887">; PROCUDURES--------------------------------------------------------------------</span> |
| 83 | |
| 84 | <span style="font-weight:bold">Procedure </span>Convert(JPEG) |
| 85 | <span style="font-weight:bold">Shared</span> filename, fileext |
| 86 | |
| 87 | <span style="font-weight:bold">If </span>JPEG <span style="color:#ca60ca">></span> <span style="color:#ca60ca">-</span><span style="color:#b08000">1</span> |
| 88 | <span style="color:#644a9b">SaveImage</span>(<span style="color:#b08000">0</span>, filename <span style="color:#ca60ca">+</span> fileext, <span style="color:#0057ae">#PB_ImagePlugin_JPEG</span>, JPEG) |
| 89 | <span style="font-weight:bold">Else</span> |
| 90 | <span style="color:#644a9b">SaveImage</span>(<span style="color:#b08000">0</span>, filename <span style="color:#ca60ca">+</span> fileext, <span style="color:#0057ae">#PB_ImagePlugin_PNG</span>) |
| 91 | <span style="font-weight:bold">EndIf</span> |
| 92 | <span style="color:#644a9b">PrintN</span>(file <span style="color:#ca60ca">+</span> <span style="color:#bf0303">" converted to "</span> <span style="color:#ca60ca">+</span> filename <span style="color:#ca60ca">+</span> fileext) |
| 93 | <span style="font-weight:bold">EndProcedure</span> |
| 94 | </pre></body></html> |