title: Stream canvas to imgITools to make ico
body: <p>So on WinXP I have been having a hard time converting a PNG file to an ICO with canvas. I found this method <code>encodeImage</code>. I don't know if it works but it looks promising but I can't figure out how to feed the image I drew on a canvas into <code>imgITools.decodeData</code>.</p>
  
  <p>What should I use for <code>aImageStream</code> and/or <code>aMimeType</code>?</p>
  
  <pre><code>imgTools.decodeImageData(aImageStream, aMimeType, imgContainer);
  </code></pre>
  
  <p>This is more of my code:</p>
  
  <pre><code> img['asdf'].file = new FileUtils.File(myPathHere);
  
  let iconStream;
  try {
    let imgTools = Cc["@mozilla.org/image/tools;1"]
                      .createInstance(Ci.imgITools);
    let imgContainer = { value: null };
  
    imgTools.decodeImageData(aImageStream, aMimeType, imgContainer);
    iconStream = imgTools.encodeImage(imgContainer.value,
                                      "image/vnd.microsoft.icon",
                                      "format=bmp;bpp=32");
  } catch (e) {
    alert('failure converting icon ' + e)
    throw("processIcon - Failure converting icon (" + e + ")");
  }
  
  let outputStream = FileUtils.openSafeFileOutputStream(img['asdf'].file);
  NetUtil.asyncCopy(iconStream, outStream, netutilCallback);
  </code></pre>