BitmapData.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Advanced / BitmapData.cs / 1305376 / BitmapData.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Drawing.Imaging { 
 
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis; 

    using System;
    using System.Drawing;
    using Marshal = System.Runtime.InteropServices.Marshal; 
    using System.Runtime.InteropServices;
 
    ///  
    /// 
    ///    Specifies the attributes of a bitmap image. 
    /// 
    [StructLayout(LayoutKind.Sequential)]
    public sealed class BitmapData {
        int width; 
        int height;
        int stride; 
        int pixelFormat; 
        IntPtr scan0;
        int reserved; 

        /// 
        /// 
        ///    Specifies the pixel width of the . 
        /// 
        public int Width { 
            get { return width; } 
            set { width = value; }
        } 

        /// 
        /// 
        ///    Specifies the pixel height of the . 
        /// 
        public int Height { 
            get { return height; } 
            set { height = value; }
        } 

        /// 
        /// 
        ///    Specifies the stride width of the . 
        /// 
        public int Stride { 
            get { return stride; } 
            set { stride = value; }
        } 

        /// 
        /// 
        ///    Specifies the format of the pixel 
        ///    information in this .
        ///  
        public PixelFormat PixelFormat { 
            get { return (PixelFormat) pixelFormat; }
            [SuppressMessage("Microsoft.Performance", "CA1803:AvoidCostlyCallsWherePossible")] 
            set {
                switch(value) {
                    case PixelFormat.DontCare:
                   // case PixelFormat.Undefined: same as DontCare 
                    case PixelFormat.Max:
                    case PixelFormat.Indexed: 
                    case PixelFormat.Gdi: 
                    case PixelFormat.Format16bppRgb555:
                    case PixelFormat.Format16bppRgb565: 
                    case PixelFormat.Format24bppRgb:
                    case PixelFormat.Format32bppRgb:
                    case PixelFormat.Format1bppIndexed:
                    case PixelFormat.Format4bppIndexed: 
                    case PixelFormat.Format8bppIndexed:
                    case PixelFormat.Alpha: 
                    case PixelFormat.Format16bppArgb1555: 
                    case PixelFormat.PAlpha:
                    case PixelFormat.Format32bppPArgb: 
                    case PixelFormat.Extended:
                    case PixelFormat.Format16bppGrayScale:
                    case PixelFormat.Format48bppRgb:
                    case PixelFormat.Format64bppPArgb: 
                    case PixelFormat.Canonical:
                    case PixelFormat.Format32bppArgb: 
                    case PixelFormat.Format64bppArgb: 
                        break;
                    default: 
                        throw new System.ComponentModel.InvalidEnumArgumentException("value", (int)value, typeof(PixelFormat));
                 }

 
                pixelFormat = (int) value;
            } 
        } 

        ///  
        /// 
        ///    Specifies the address of the pixel data.
        /// 
        public IntPtr Scan0 { 
            get { return scan0; }
            set { scan0 = value; } 
        } 

        ///  
        /// 
        ///    Reserved. Do not use.
        /// 
        public int Reserved { 
            // why make public??
            // 
            get { return reserved; } 
            set { reserved = value; }
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Drawing.Imaging { 
 
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis; 

    using System;
    using System.Drawing;
    using Marshal = System.Runtime.InteropServices.Marshal; 
    using System.Runtime.InteropServices;
 
    ///  
    /// 
    ///    Specifies the attributes of a bitmap image. 
    /// 
    [StructLayout(LayoutKind.Sequential)]
    public sealed class BitmapData {
        int width; 
        int height;
        int stride; 
        int pixelFormat; 
        IntPtr scan0;
        int reserved; 

        /// 
        /// 
        ///    Specifies the pixel width of the . 
        /// 
        public int Width { 
            get { return width; } 
            set { width = value; }
        } 

        /// 
        /// 
        ///    Specifies the pixel height of the . 
        /// 
        public int Height { 
            get { return height; } 
            set { height = value; }
        } 

        /// 
        /// 
        ///    Specifies the stride width of the . 
        /// 
        public int Stride { 
            get { return stride; } 
            set { stride = value; }
        } 

        /// 
        /// 
        ///    Specifies the format of the pixel 
        ///    information in this .
        ///  
        public PixelFormat PixelFormat { 
            get { return (PixelFormat) pixelFormat; }
            [SuppressMessage("Microsoft.Performance", "CA1803:AvoidCostlyCallsWherePossible")] 
            set {
                switch(value) {
                    case PixelFormat.DontCare:
                   // case PixelFormat.Undefined: same as DontCare 
                    case PixelFormat.Max:
                    case PixelFormat.Indexed: 
                    case PixelFormat.Gdi: 
                    case PixelFormat.Format16bppRgb555:
                    case PixelFormat.Format16bppRgb565: 
                    case PixelFormat.Format24bppRgb:
                    case PixelFormat.Format32bppRgb:
                    case PixelFormat.Format1bppIndexed:
                    case PixelFormat.Format4bppIndexed: 
                    case PixelFormat.Format8bppIndexed:
                    case PixelFormat.Alpha: 
                    case PixelFormat.Format16bppArgb1555: 
                    case PixelFormat.PAlpha:
                    case PixelFormat.Format32bppPArgb: 
                    case PixelFormat.Extended:
                    case PixelFormat.Format16bppGrayScale:
                    case PixelFormat.Format48bppRgb:
                    case PixelFormat.Format64bppPArgb: 
                    case PixelFormat.Canonical:
                    case PixelFormat.Format32bppArgb: 
                    case PixelFormat.Format64bppArgb: 
                        break;
                    default: 
                        throw new System.ComponentModel.InvalidEnumArgumentException("value", (int)value, typeof(PixelFormat));
                 }

 
                pixelFormat = (int) value;
            } 
        } 

        ///  
        /// 
        ///    Specifies the address of the pixel data.
        /// 
        public IntPtr Scan0 { 
            get { return scan0; }
            set { scan0 = value; } 
        } 

        ///  
        /// 
        ///    Reserved. Do not use.
        /// 
        public int Reserved { 
            // why make public??
            // 
            get { return reserved; } 
            set { reserved = value; }
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK