<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Georgia">Maybe the VM folks will see the value in adding
      this or maybe you could write a plugin. Barring that, this speeds
      things up quite a bit over the naive implementation:<br>
      <br>
      test2<br>
      "<br>
      BobsColorTest new test2<br>
      "<br>
      &nbsp;&nbsp;&nbsp; | target cmap1 inputData cmap2 nextPV cmap3 inputDataBits
      targetBits results t forceAlpha preAlloc |<br>
      &nbsp;&nbsp;&nbsp; <br>
      &nbsp;&nbsp;&nbsp; inputData _ Form extent: 800@800 depth: 32.<br>
      &nbsp;&nbsp;&nbsp; nextPV _ 1.<br>
      &nbsp;&nbsp;&nbsp; 0 to: 799 do: [ :x |<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0 to: 799 do: [ :y |<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; inputData pixelValueAt: x@y put: ((nextPV _ nextPV +
      1) \\ 30000 bitAnd: 16rffffff).<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ].<br>
      &nbsp;&nbsp;&nbsp; ].<br>
      &nbsp;&nbsp;&nbsp; forceAlpha _ 16rff000000.<br>
      &nbsp;&nbsp;&nbsp; cmap1 _&nbsp; Bitmap new: 256*256*256.<br>
      &nbsp;&nbsp;&nbsp; 1 to: cmap1 size do: [:i | cmap1 at: i put:( i&nbsp; \\ 65536 * 256
      + 1 bitOr: forceAlpha)].<br>
      &nbsp;&nbsp;&nbsp; cmap2 _&nbsp; Bitmap new: 256*256*256.<br>
      &nbsp;&nbsp;&nbsp; 1 to: cmap2 size do: [:i | cmap2 at: i put: (i - 1 \\ 256 + 1
      bitOr: forceAlpha)].<br>
      &nbsp;&nbsp;&nbsp; cmap3 _&nbsp; Bitmap new: 256*256*256.<br>
      &nbsp;&nbsp;&nbsp; 1 to: cmap3 size do: [:i | cmap3 at: i put: (i - 1 bitOr:
      forceAlpha)].<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
      &nbsp;&nbsp;&nbsp; preAlloc _ {cmap1. cmap2. cmap3} collect: [ :map |<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {map. Form extent: inputData extent depth: inputData
      depth}<br>
      &nbsp;&nbsp;&nbsp; ].<br>
      &nbsp;&nbsp;&nbsp; t _ [<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; results _ preAlloc collect: [ :pair |<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; target _ pair second.<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; targetBits _ target bits.<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; inputDataBits _ inputData bits.<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 1 to: targetBits size do: [ :i |<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; targetBits at: i put: (pair first at:
      (inputDataBits at: i) +1) <br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ].<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; target<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ].<br>
      &nbsp;&nbsp;&nbsp; ] timeToRun.<br>
      &nbsp;&nbsp;&nbsp; results do: [ :each |<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; each&nbsp; asMorph openInWorld.<br>
      &nbsp;&nbsp;&nbsp; ].<br>
      &nbsp;&nbsp;&nbsp; self inform: t asString,'ms to map ',results size asString,'
      times'.<br>
      <br>
      Cheers,<br>
      Bob<br>
    </font>
    <div class="moz-cite-prefix">On 8/5/12 2:43 AM, Lawson English
      wrote:<br>
    </div>
    <blockquote cite="mid:501E15FA.4090303@cox.net" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">Thanks, that works.<br>
        <br>
        Though I think the usecase of the ability to swiftly switch
        palettes is of value, even in 32 bit forms.<br>
        <br>
        form&gt;&gt;mapColor:to:&nbsp; and mapColors:to should be able to use
        a full 32 bit color. The bitblt docs say that only 5 bits of the
        Color object's RGB values are used no matter the depth of the
        destination form. This is a serious limitation for anyone hoping
        to prototype/implement a modern image-oriented application.<br>
        <br>
        Cairo no doubt changes this, but Cairo also violates the port
        anywhere paradigm that Squeak is based on, I think.<br>
        <br>
        L<br>
        <br>
        <br>
        <br>
        <br>
        On 8/4/12 8:34 AM, Bob Arning wrote:<br>
      </div>
      <blockquote cite="mid:501D411B.10008@comcast.net" type="cite">
        <meta content="text/html; charset=ISO-8859-1"
          http-equiv="Content-Type">
        <font face="Georgia">You could try something like this:<br>
          <br>
          test1<br>
          "<br>
          BobsColorTest new test1<br>
          "<br>
          &nbsp;&nbsp;&nbsp; | target cmap1 inputData cmap2 nextPV cmap3 |<br>
          &nbsp;&nbsp;&nbsp; <br>
          &nbsp;&nbsp;&nbsp; inputData _ Form extent: 800@800 depth: 16.<br>
          &nbsp;&nbsp;&nbsp; nextPV _ 1.<br>
          &nbsp;&nbsp;&nbsp; 0 to: 799 do: [ :x |<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0 to: 799 do: [ :y |<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; inputData pixelValueAt: x@y put: (nextPV _ nextPV
          + 1) \\ 30000.<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ].<br>
          &nbsp;&nbsp;&nbsp; ].<br>
          &nbsp;&nbsp;&nbsp; cmap1 _&nbsp; Bitmap new: 32768.<br>
          &nbsp;&nbsp;&nbsp; 1 to: cmap1 size do: [:i | cmap1 at: i put: i&nbsp; \\ 1023 *
          32 + 1].<br>
          &nbsp;&nbsp;&nbsp; cmap2 _&nbsp; Bitmap new: 32768.<br>
          &nbsp;&nbsp;&nbsp; 1 to: cmap2 size do: [:i | cmap2 at: i put: i - 1 \\ 32 +
          1].<br>
          &nbsp;&nbsp;&nbsp; cmap3 _&nbsp; Bitmap new: 32768.<br>
          &nbsp;&nbsp;&nbsp; 1 to: cmap3 size do: [:i | cmap3 at: i put: i - 1].<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
          &nbsp;&nbsp;&nbsp; {cmap1. cmap2. cmap3} do: [ :map |<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; target _ Form extent: inputData extent depth:
          inputData depth.<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (BitBlt current toForm: target)<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sourceForm: inputData;<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sourceOrigin: 0@0;<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; combinationRule: Form paint;<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; destX: 0 destY: 0 width: inputData width height:
          inputData height;<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; colorMap: map;<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; copyBits.<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; target asMorph openInWorld.<br>
          &nbsp;&nbsp;&nbsp; ].<br>
          <br>
          Cheers,<br>
          Bob<br>
          <br>
        </font>
        <div class="moz-cite-prefix">On 8/3/12 7:30 PM, Lawson English
          wrote:<br>
        </div>
        <blockquote cite="mid:501C5F23.202@cox.net" type="cite">OK, I'm
          such a noob here, that I'm not quite sure how to ask my
          question... <br>
          <br>
          <br>
          I have a "dwell file" -an array of values generated by a
          Mandelbrot Set application, one per pixel, with arbitrary
          values between 1 and xxxxxxxxxxx (currently less than 2
          billion, and right now far less than 1,000,000)- and I would
          like to use them, suitably tweaked, as indices into a
          ColorMap. The ColorMap need not have 1,000,000 entries. No-one
          can see that many color differences in a Mandelbrot set
          anyway. <br>
          <br>
          I can generate an array of Color (ColorArray?) but I'm not
          sure how to use them to create the ColorMap, and I'm not sure
          how to use the ColorMap to speedily change what is drawn in
          the first place. <br>
          <br>
          Right now, I'm creating a color dictionary and drawing via: <br>
          <br>
          <br>
          1 to: 800 do: [:y| <br>
          &nbsp;&nbsp;&nbsp; 1 to: 800 do: [:x| |i| <br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := x+ ((y-1) *800).&nbsp; aForm colorAt: x@y put:(
          myDictColors at:&nbsp; (myArray at: i )).] <br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]. <br>
          <br>
          <br>
          where myDictColors is a dictionary whose keys are the dwells
          listed in the dwell array file and whose values are Color
          objects from my array of colors. <br>
          <br>
          Drawing the above takes about 1.5 seconds, which is a bit
          slow. I'd like realtime-ish updating as I play with colors in
          the palette. Can this be done, at least up to the 4096 color
          limit that BitBlt has for ColorMaps? <br>
          <br>
          If so, how?&nbsp; I've been trying to figure out the various
          classes and I'm stumped. <br>
          <br>
          <br>
          Thanks <br>
          <br>
          <br>
          <br>
          <br>
          <br>
        </blockquote>
        <br>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
      </blockquote>
      <br>
      <br>
      <pre class="moz-signature" cols="72">-- 
Squeak from the very start (introduction to Squeak and Pharo Smalltalk for the (almost) complete and compleate beginner).
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://www.youtube.com/playlist?list=PL6601A198DF14788D&amp;feature=view_all">https://www.youtube.com/playlist?list=PL6601A198DF14788D&amp;feature=view_all</a> </pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">
</pre>
    </blockquote>
    <br>
  </body>
</html>