doc/classes/C64PhotoScrap.src/M000230.html in ripxplore-0.17.0 vs doc/classes/C64PhotoScrap.src/M000230.html in ripxplore-0.17.1

- old
+ new

@@ -3,51 +3,43 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>unpacked_bytes (C64PhotoScrap)</title> + <title>to_picture (C64PhotoScrap)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> - <pre><span class="ruby-comment cmt"># File lib/native_file_types/c64/C64PhotoScrap.rb, line 60</span> -<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unpacked_bytes</span> - <span class="ruby-identifier">bitmap_length</span>=(<span class="ruby-identifier">picture_width</span><span class="ruby-operator">/</span><span class="ruby-value">8</span>)<span class="ruby-operator">*</span><span class="ruby-identifier">picture_height</span> - <span class="ruby-identifier">colour_length</span>=(<span class="ruby-identifier">bitmap_length</span>)<span class="ruby-operator">/</span><span class="ruby-value">8</span> + <pre><span class="ruby-comment cmt"># File lib/native_file_types/c64/C64PhotoScrap.rb, line 99</span> +<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_picture</span> + <span class="ruby-identifier">require</span> <span class="ruby-value str">'PatchedPNG'</span> + (<span class="ruby-identifier">bitmap_bytes</span>,<span class="ruby-identifier">colour_bytes</span>)=<span class="ruby-identifier">unpacked_bytes</span> + <span class="ruby-identifier">width_in_bytes</span>=<span class="ruby-identifier">picture_width</span><span class="ruby-operator">/</span><span class="ruby-value">8</span> + <span class="ruby-identifier">canvas</span> = <span class="ruby-constant">PNG</span><span class="ruby-operator">::</span><span class="ruby-constant">Canvas</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">picture_width</span>,<span class="ruby-identifier">picture_height</span>, <span class="ruby-constant">C64</span><span class="ruby-operator">::</span><span class="ruby-constant">COLOR_LTGRAY</span> + <span class="ruby-identifier">picture_height</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> - <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@unpacked_bytes</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">then</span> - <span class="ruby-ivar">@unpacked_bytes</span>=<span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">bitmap_length</span><span class="ruby-operator">+</span><span class="ruby-identifier">colour_length</span>) - <span class="ruby-identifier">in_p</span>=<span class="ruby-value">3</span> - <span class="ruby-identifier">out_p</span>=<span class="ruby-value">0</span> - <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">in_p</span><span class="ruby-operator">&lt;</span><span class="ruby-identifier">contents</span>.<span class="ruby-identifier">length</span>) <span class="ruby-keyword kw">do</span> - <span class="ruby-identifier">count</span>=<span class="ruby-identifier">contents</span>[<span class="ruby-identifier">in_p</span>] - <span class="ruby-identifier">in_p</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> - <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">count</span> - <span class="ruby-keyword kw">when</span> <span class="ruby-value">00</span><span class="ruby-operator">..</span><span class="ruby-value">127</span> <span class="ruby-keyword kw">then</span> - <span class="ruby-identifier">repeat</span>=<span class="ruby-identifier">count</span> - <span class="ruby-identifier">b</span>=<span class="ruby-identifier">contents</span>[<span class="ruby-identifier">in_p</span>] - <span class="ruby-identifier">in_p</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> - <span class="ruby-identifier">repeat</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> - <span class="ruby-ivar">@unpacked_bytes</span>[<span class="ruby-identifier">out_p</span>]=<span class="ruby-identifier">b</span> - <span class="ruby-identifier">out_p</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> - <span class="ruby-keyword kw">end</span> - <span class="ruby-keyword kw">when</span> <span class="ruby-value">128</span><span class="ruby-operator">..</span><span class="ruby-value">220</span> <span class="ruby-keyword kw">then</span> - <span class="ruby-identifier">repeat</span>=<span class="ruby-identifier">count</span><span class="ruby-operator">-</span><span class="ruby-value">128</span> - <span class="ruby-identifier">repeat</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> - <span class="ruby-identifier">b</span>=<span class="ruby-identifier">contents</span>[<span class="ruby-identifier">in_p</span>] - <span class="ruby-identifier">in_p</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> - <span class="ruby-ivar">@unpacked_bytes</span>[<span class="ruby-identifier">out_p</span>]=<span class="ruby-identifier">b</span> - <span class="ruby-identifier">out_p</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> - <span class="ruby-keyword kw">end</span> - <span class="ruby-keyword kw">when</span> <span class="ruby-value">221</span><span class="ruby-operator">..</span><span class="ruby-value">225</span> <span class="ruby-keyword kw">then</span> - <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;BIGCOUNT not implemented yet&quot;</span> - <span class="ruby-keyword kw">end</span> + <span class="ruby-identifier">line_bytes</span>= <span class="ruby-identifier">bitmap_bytes</span>[<span class="ruby-identifier">width_in_bytes</span><span class="ruby-operator">*</span><span class="ruby-identifier">line</span>,<span class="ruby-identifier">width_in_bytes</span>] + <span class="ruby-identifier">width_in_bytes</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> + <span class="ruby-identifier">pattern_byte</span>=<span class="ruby-identifier">line_bytes</span>[<span class="ruby-identifier">i</span>] + <span class="ruby-identifier">card_number</span>=<span class="ruby-identifier">line</span><span class="ruby-operator">/</span><span class="ruby-value">8</span><span class="ruby-operator">+</span><span class="ruby-identifier">i</span> + <span class="ruby-identifier">colour_byte</span>=<span class="ruby-identifier">colour_bytes</span>[<span class="ruby-identifier">card_number</span>] + <span class="ruby-identifier">colour_byte</span>=<span class="ruby-value">0x0</span><span class="ruby-constant">F</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">colour_byte</span>.<span class="ruby-identifier">nil?</span> + <span class="ruby-identifier">foreground_colour</span>=<span class="ruby-constant">C64</span><span class="ruby-operator">::</span><span class="ruby-constant">COLOR_MAP</span>[<span class="ruby-identifier">colour_byte</span><span class="ruby-operator">/</span><span class="ruby-value">0x10</span>] + <span class="ruby-identifier">background_colour</span>=<span class="ruby-constant">C64</span><span class="ruby-operator">::</span><span class="ruby-constant">COLOR_MAP</span>[<span class="ruby-identifier">colour_byte</span><span class="ruby-operator">%</span><span class="ruby-value">0x10</span>] + <span class="ruby-identifier">y</span>=<span class="ruby-identifier">line</span> + <span class="ruby-identifier">bitmask</span>=<span class="ruby-value">0</span><span class="ruby-identifier">b10000000</span> + <span class="ruby-value">8</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">bit</span><span class="ruby-operator">|</span> + <span class="ruby-identifier">x</span>=(<span class="ruby-identifier">i</span><span class="ruby-operator">*</span><span class="ruby-value">8</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">bit</span> + <span class="ruby-identifier">canvas</span>[<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>]=(((<span class="ruby-identifier">pattern_byte</span> <span class="ruby-operator">&amp;</span> <span class="ruby-identifier">bitmask</span>)<span class="ruby-operator">==</span><span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">background_colour</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">foreground_colour</span> ) + <span class="ruby-identifier">bitmask</span>=<span class="ruby-identifier">bitmask</span><span class="ruby-operator">/</span><span class="ruby-value">2</span> + <span class="ruby-keyword kw">end</span> -<span class="ruby-comment cmt"># puts &quot;#{filename} #{in_p} #{out_p} of #{bitmap_length} #{count} #{picture_width}x#{picture_height}&quot;</span> - <span class="ruby-keyword kw">end</span> - <span class="ruby-keyword kw">return</span> [<span class="ruby-ivar">@unpacked_bytes</span>[<span class="ruby-value">0</span>,<span class="ruby-identifier">bitmap_length</span>],<span class="ruby-ivar">@unpacked_bytes</span>[<span class="ruby-identifier">bitmap_length</span>,<span class="ruby-identifier">colour_length</span>]] - + <span class="ruby-identifier">canvas</span> + <span class="ruby-keyword kw">end</span> + <span class="ruby-identifier">png</span> = <span class="ruby-constant">PNG</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">canvas</span> + <span class="ruby-identifier">result</span>=<span class="ruby-identifier">png</span>.<span class="ruby-identifier">raw_bytes</span> + <span class="ruby-identifier">result</span> <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file