private void setDeviceImage(
         Size size,
         System.Windows.Forms.ColorDepth colorDepth
         )
      {
         this.size = size;
         this.colorDepth = colorDepth;         
         // Initialise the data:
         BITMAPINFOHEADER bmInfoHdr = new BITMAPINFOHEADER(
            size, colorDepth);
         this.data = new byte[
            this.MaskImageIndex(bmInfoHdr) + this.MaskImageSize(bmInfoHdr)];
         
         MemoryStream mw = new MemoryStream(this.data, 0, this.data.Length,
          true);
         BinaryWriter bw = new BinaryWriter(mw);
         bmInfoHdr.Write(bw);
         // Write the colour indexes if required:
         switch (this.colorDepth)
         {
            case ColorDepth.Depth4Bit:
               write16ColorPalette(bw);
               break;
            case ColorDepth.Depth8Bit:
               write256ColorPalette(bw);
               break;
         }
         bw.Close();

      }
Exemple #2
0
        private void setDeviceImage(Size size, ColorDepth colorDepth)
        {
            this.size = size;
            this.colorDepth = colorDepth;
            BITMAPINFOHEADER bmInfoHeader = new BITMAPINFOHEADER(size, colorDepth);
            this.data = new byte[this.MaskImageIndex(bmInfoHeader) + this.MaskImageSize(bmInfoHeader)];
            MemoryStream output = new MemoryStream(this.data, 0, this.data.Length, true);
            BinaryWriter bw = new BinaryWriter(output);
            bmInfoHeader.Write(bw);
            switch (this.colorDepth)
            {
                case ColorDepth.Depth4Bit:
                    this.write16ColorPalette(bw);
                    break;

                case ColorDepth.Depth8Bit:
                    this.write256ColorPalette(bw);
                    goto Label_0077;
            }
            Label_0077:
            bw.Close();
        }