aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/Settings.Designer.cs
blob: ab102e0eb843427d98193ceb49157f812bda0387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Tango.PPC.Logging.Properties
{
    
    
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
    {
        
        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
        
        public static Settings Default
        {
            get
            {
                return defaultInstance;
            }
        }
    }
}
rong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;

public static class BitmapSourceExtensions
{
    /// <summary>
    /// Converts the bitmap source to GDI+ bitmap.
    /// </summary>
    /// <param name="bitmapsource">The bitmap source.</param>
    /// <returns></returns>
    public static System.Drawing.Bitmap ToGDIBitmap(this BitmapSource bitmapsource)
    {
        if (bitmapsource != null)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                BitmapEncoder enc = new BmpBitmapEncoder();
                enc.Frames.Add(BitmapFrame.Create(bitmapsource));
                enc.Save(stream);

                using (var tempBitmap = new System.Drawing.Bitmap(stream))
                {
                    // According to MSDN, one "must keep the stream open for the lifetime of the Bitmap."
                    // So we return a copy of the new bitmap, allowing us to dispose both the bitmap and the stream.
                    return new System.Drawing.Bitmap(tempBitmap);
                }
            }
        }
        else
        {
            return new System.Drawing.Bitmap(1, 1);
        }
    }

    /// <summary>
    /// Save to the BMP file.
    /// </summary>
    /// <param name="bitmapSource">The bitmap source.</param>
    /// <param name="fileName">Name of the file.</param>
    public static void SaveBmpFile(this BitmapSource bitmapSource, String fileName)
    {
        using (FileStream fs = new FileStream(fileName, FileMode.Create))
        {
            BitmapEncoder enc = new BmpBitmapEncoder();
            enc.Frames.Add(BitmapFrame.Create(bitmapSource));
            enc.Save(fs);
        }
    }

    /// <summary>
    /// Save to the PNG file.
    /// </summary>
    /// <param name="bitmapSource">The bitmap source.</param>
    /// <param name="fileName">Name of the file.</param>
    public static void SavePngFile(this BitmapSource bitmapSource, String fileName)
    {
        using (FileStream fs = new FileStream(fileName, FileMode.Create))
        {
            PngBitmapEncoder enc = new PngBitmapEncoder();
            enc.Frames.Add(BitmapFrame.Create(bitmapSource));
            enc.Save(fs);
        }
    }

    /// <summary>
    /// Save to the JPEG file.
    /// </summary>
    /// <param name="bitmapSource">The bitmap source.</param>
    /// <param name="fileName">Name of the file.</param>
    /// <param name="quality">The quality.</param>
    public static void SaveJpegFile(this BitmapSource bitmapSource, String fileName, int quality = 100)
    {
        using (FileStream fs = new FileStream(fileName, FileMode.Create))
        {
            JpegBitmapEncoder enc = new JpegBitmapEncoder();
            enc.QualityLevel = quality;
            enc.Frames.Add(BitmapFrame.Create(bitmapSource));
            enc.Save(fs);
        }
    }

    /// <summary>
    /// Converts the bitmap source to bitmap image.
    /// </summary>
    /// <param name="bitmapSource">The bitmap source.</param>
    /// <returns></returns>
    public static BitmapImage ConvertToBitmapImage(this BitmapSource bitmapSource)
    {
        JpegBitmapEncoder encoder = new JpegBitmapEncoder();
        MemoryStream memoryStream = new MemoryStream();
        BitmapImage bImg = new BitmapImage();

        encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
        encoder.Save(memoryStream);

        bImg.BeginInit();
        bImg.StreamSource = new MemoryStream(memoryStream.ToArray());
        bImg.EndInit();

        memoryStream.Close();

        return bImg;
    }

    /// <summary>
    /// Converts the Bitmap Source to Writeable Bitmap.
    /// </summary>
    /// <param name="bitmapsource">The bitmap source.</param>
    /// <returns></returns>
    public static WriteableBitmap ToWritableBitmap(this BitmapSource bitmapsource)
    {
        WriteableBitmap w = new WriteableBitmap(bitmapsource);
        return w;
    }

    /// <summary>
    /// Converts the BitmapSource to byte array.
    /// </summary>
    /// <param name="bitmapsource">The bitmap source.</param>
    /// <param name="format">The pixel format.</param>
    /// <returns></returns>
    public static byte[] ToBytes(this BitmapSource bitmapsource, PixelFormat format)
    {
        var bm = new FormatConvertedBitmap(bitmapsource, format, null, 0);

        BitmapEncoder encoder = new BmpBitmapEncoder();
        byte[] bytes = null;
        using (MemoryStream stream = new MemoryStream())
        {
            encoder.Frames.Add(BitmapFrame.Create(bm));
            encoder.Save(stream);
            bytes = stream.ToArray();
            stream.Close();
        }

        return bytes;
    }

    /// <summary>
    /// Converts the Bitmap Source to JPEG byte array.
    /// </summary>
    /// <param name="bitmapsource">The bitmap source.</param>
    /// <param name="quality">Compression quality.</param>
    /// <returns></returns>
    public static byte[] ToJpegBytes(this BitmapSource bitmapsource, int quality = 100)
    {
        var bm = new FormatConvertedBitmap(bitmapsource, PixelFormats.Bgr24, null, 0);

        JpegBitmapEncoder encoder = new JpegBitmapEncoder();
        encoder.QualityLevel = quality;
        byte[] bytes = null;
        using (MemoryStream stream = new MemoryStream())
        {
            encoder.Frames.Add(BitmapFrame.Create(bm));
            encoder.Save(stream);
            bytes = stream.ToArray();
            stream.Close();
        }

        return bytes;
    }

    /// <summary>
    /// Converts the BitmapSource to PNG byte array.
    /// </summary>
    /// <param name="bitmapsource">The bitmap source.</param>
    /// <returns></returns>
    public static byte[] ToPngBytes(this BitmapSource bitmapsource)
    {
        PngBitmapEncoder encoder = new PngBitmapEncoder();
        byte[] bytes = null;
        using (MemoryStream stream = new MemoryStream())
        {
            encoder.Frames.Add(BitmapFrame.Create(bitmapsource));
            encoder.Save(stream);
            bytes = stream.ToArray();
            stream.Close();
        }

        return bytes;
    }

    /// <summary>
    /// Converts the BitmapSource to BMP byte array.
    /// </summary>
    /// <param name="bitmapsource">The bitmap source.</param>
    /// <returns></returns>
    public static byte[] ToBmpBytes(this BitmapSource bitmapsource)
    {
        BmpBitmapEncoder encoder = new BmpBitmapEncoder();
        byte[] bytes = null;
        using (MemoryStream stream = new MemoryStream())
        {
            encoder.Frames.Add(BitmapFrame.Create(bitmapsource));
            encoder.Save(stream);
            bytes = stream.ToArray();
            stream.Close();
        }

        return bytes;
    }

    /// <summary>
    /// Converts the byte array to a Bitmap Source.
    /// </summary>
    /// <param name="bytes">The bytes.</param>
    /// <returns></returns>
    public static BitmapSource ToBitmapSource(this byte[] bytes)
    {
        var image = new BitmapImage();
        using (var mem = new MemoryStream(bytes))
        {
            mem.Position = 0;
            image.BeginInit();
            image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
            image.CacheOption = BitmapCacheOption.OnLoad;
            image.UriSource = null;
            image.StreamSource = mem;
            image.EndInit();
        }
        image.Freeze();
        return image;
    }

    /// <summary>
    /// Converts the bitmap source format.
    /// </summary>
    /// <param name="bitmapsource">The bitmap source.</param>
    /// <param name="format">The format.</param>
    /// <returns></returns>
    public static BitmapSource ConvertFormat(this BitmapSource bitmapsource, PixelFormat format)
    {
        var bm = new FormatConvertedBitmap(bitmapsource, format, null, 0);
        return bm;
    }

    /// <summary>
    /// Converts this GDI bitmap to WPF BitmapSource.
    /// </summary>
    /// <param name="bitmap">The bitmap.</param>
    /// <returns></returns>
    public static BitmapSource ToBitmapSource(this System.Drawing.Bitmap bitmap)
    {
        var bitmapData = bitmap.LockBits(
new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
     System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

        var bitmapSource = BitmapSource.Create(
            bitmapData.Width, bitmapData.Height, 96, 96, System.Windows.Media.PixelFormats.Bgra32, null,
            bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);

        bitmap.UnlockBits(bitmapData);

        bitmapSource.Freeze();
        return bitmapSource;
    }
}