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