//--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // b t n G e t P r o p e r t i e s _ C l i c k                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Called when the 'Get Properties' button is clicked.                //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void btnGetProperties_Click(object sender, RoutedEventArgs e)
        {
            Int32 result = 0;

            Int32 srcWidth  = 0,
                  srcHeight = 0,
                  srcResX   = 0,
                  srcResY   = 0;

            UInt32 srcCompression    = 0,
                   srcPaletteEntries = 0;

            UInt16 srcBitsPerPixel = 0;

            Boolean srcBlackWhite = false;

            Boolean bitmapOpen = false;

            bitmapOpen = ToolImageBitmapCore.bitmapOpen(_bitmapFilename);

            if (!bitmapOpen)
            {
                result = -1;
            }

            if (result == 0)
            {
                result = ToolImageBitmapCore.readBmpFileHeader();
            }

            if (result == 0)
            {
                result = ToolImageBitmapCore.readBmpInfoHeader();
            }

            if (result == 0)
            {
                result = ToolImageBitmapCore.readBmpPalette();
            }

            ToolImageBitmapCore.getBmpInfo(ref srcWidth,
                                           ref srcHeight,
                                           ref srcBitsPerPixel,
                                           ref srcCompression,
                                           ref srcResX,
                                           ref srcResY,
                                           ref srcPaletteEntries,
                                           ref srcBlackWhite);

            txtSrcWidth.Text       = srcWidth.ToString();
            txtSrcHeight.Text      = srcHeight.ToString();
            txtSrcResX.Text        = srcResX.ToString();
            txtSrcResY.Text        = srcResY.ToString();
            txtSrcResXDpi.Text     = ((Int32)(srcResX / 39.37)).ToString();
            txtSrcResYDpi.Text     = ((Int32)(srcResY / 39.37)).ToString();
            txtSrcBPP.Text         = srcBitsPerPixel.ToString();
            txtSrcCompression.Text = srcCompression.ToString();
            txtSrcMonoBW.Text      = srcBlackWhite.ToString();

            grpProps.Visibility = Visibility.Visible;

            if (bitmapOpen)
            {
                ToolImageBitmapCore.bitmapClose();
            }
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e I m a g e                                          //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate print equivalent of bitmap image.                         //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateImage(BinaryWriter prnWriter,
                                          Single destPosX,
                                          Single destPosY,
                                          Int32 destScalePercentX,
                                          Int32 destScalePercentY,
                                          Int32 rasterResolution)
        {
            Byte[] bufStd = new Byte[1024];

            Int32 srcWidth  = 0,
                  srcHeight = 0,
                  srcResX   = 0,
                  srcResY   = 0;

            UInt32 srcCompression    = 0,
                   srcPaletteEntries = 0;

            UInt16 srcBitsPerPixel = 0;

            Boolean srcBlackWhite = false;

            ToolImageBitmapCore.getBmpInfo(ref srcWidth,
                                           ref srcHeight,
                                           ref srcBitsPerPixel,
                                           ref srcCompression,
                                           ref srcResX,
                                           ref srcResY,
                                           ref srcPaletteEntries,
                                           ref srcBlackWhite);

            if (srcCompression != 0)
            {
                MessageBox.Show("Bitmaps: compressed formats not supported",
                                "Bitmap file",
                                MessageBoxButton.OK,
                                MessageBoxImage.Exclamation);
                return;
            }
            else if ((srcBitsPerPixel != 1) &&
                     (srcBitsPerPixel != 4) &&
                     (srcBitsPerPixel != 24))
            {
                MessageBox.Show("Bitmaps: only 1-, 4- and 24-bit supported",
                                "Bitmap file",
                                MessageBoxButton.OK,
                                MessageBoxImage.Exclamation);
                return;
            }
            else if (srcHeight < 0)
            {
                MessageBox.Show("Bitmaps: top-down DIBs not supported",
                                "Bitmap file",
                                MessageBoxButton.OK,
                                MessageBoxImage.Exclamation);
                return;
            }

            generateImageHeader(prnWriter,
                                srcBitsPerPixel,
                                srcWidth,
                                srcHeight,
                                srcResX,
                                srcResY,
                                destPosX,
                                destPosY,
                                destScalePercentX,
                                destScalePercentY,
                                rasterResolution,
                                srcPaletteEntries,
                                srcBlackWhite);

            generateImageData(prnWriter,
                              srcBitsPerPixel,
                              srcWidth,
                              srcHeight);

            generateImageTrailer(prnWriter);
        }