protected override void InitWidgetFromToken(SaveConfigToken token)
        {
            TgaSaveConfigToken tgaToken = (TgaSaveConfigToken)token;

            if (tgaToken.BitDepth == 24)
            {
                this.bpp24Radio.Checked = true;
                this.bpp32Radio.Checked = false;
            }
            else
            {
                this.bpp24Radio.Checked = false;
                this.bpp32Radio.Checked = true;
            }

            this.rleCompressCheckBox.Checked = tgaToken.RleCompress;
        }
Exemple #2
0
        private void SaveTga(Surface input, Stream output, SaveConfigToken token, ProgressEventHandler progressCallback)
        {
            TgaSaveConfigToken tgaToken = (TgaSaveConfigToken)token;

            TgaHeader header = new TgaHeader();

            header.idLength      = 0;
            header.cmapType      = 0;
            header.imageType     = tgaToken.RleCompress ? TgaType.RleRgb : TgaType.Rgb;
            header.cmapIndex     = 0;
            header.cmapLength    = 0;
            header.cmapEntrySize = 0; // if bpp=8, set this to 24
            header.xOrigin       = 0;
            header.yOrigin       = 0;
            header.imageWidth    = (ushort)input.Width;
            header.imageHeight   = (ushort)input.Height;
            header.pixelDepth    = (byte)tgaToken.BitDepth;
            header.imageDesc     = 0;

            header.Write(output);

            // write palette if doing 8-bit
            // ... todo?

            for (int y = input.Height - 1; y >= 0; --y)
            {
                // non-rle output
                if (tgaToken.RleCompress)
                {
                    SaveTgaRowRle(output, input, ref header, y);
                }
                else
                {
                    SaveTgaRowRaw(output, input, ref header, y);
                }

                if (progressCallback != null)
                {
                    progressCallback(this, new ProgressEventArgs(100.0 * ((double)(input.Height - y) / (double)input.Height)));
                }
            }
        }
 protected TgaSaveConfigToken(TgaSaveConfigToken copyMe)
 {
     this.bitDepth = copyMe.bitDepth;
     this.rleCompress = copyMe.rleCompress;
 }
 protected TgaSaveConfigToken(TgaSaveConfigToken copyMe)
 {
     this.bitDepth    = copyMe.bitDepth;
     this.rleCompress = copyMe.rleCompress;
 }