title: Printing PNG images to a zebra network printer
body: <p>I am trying to find a way of printing images to a zebra and having a lot of trouble.</p>
  
  <p>According to the docs:</p>
  
  <blockquote>
    <p>The first encoding, known as B64, encodes the data using the MIME
    Base64 scheme. Base64 is used to encode e-mail atachedments ... <br/>
    Base64 encodes six bits to the byte, for an expantion of 33 percent
    over the un-enclosed data.<br/> The second encoding, known as Z64,
    first compresses the data using the LZ77 algorithm to reduce its size.
    (This algorithm is used by the PKZIP and is intergral to the PNG
    graphics format.)<br/> The compressed data is then encoded using the
    MIME Base64 scheme as described above.<br/> A CRC will be calculated
    accross the Base64-encoded data.</p>
  </blockquote>
  
  <p>But it doesn't have a great deal more info.</p>
  
  <p>Basically I was trying encoding with</p>
  
  <pre><code>private byte[] GetItemFromPath(string filepath)
  {   
      using (MemoryStream ms = new MemoryStream())
      {
          using (Image img = Image.FromFile(filepath))
          {
              img.Save(ms, ImageFormat.Png);
              return ms.ToArray();
          }
      }
  }
  </code></pre>
  
  <p>Then trying to print with something like:</p>
  
  <pre><code>var initialArray = GetItemFromPath("C:\\RED.png");
  string converted = Convert.ToBase64String(b);
  
  PrintThis(string.Format(@"~DYRED.PNG,P,P,{1},0,:B64:
  {0}
  ^XA
  ^F0200,200^XGRED.PNG,1,1^FS
  ^XZ", converted .ToString(), initialArray.Length));
  </code></pre>
  
  <p>From the sounds of it, either B64 or Z64 are both accepted.</p>
  
  <p>I've tried a few variations, and a couple of methods for generating the CRC and calculating the 'size'.
  But none seem to work and the download of the graphics to the printer is always getting aborted.</p>
  
  <p>Has anyone managed to accomplish something like this? Or knows where I am going wrong?</p>