Go through every pixel of an image and then dispose of it I'm a little confused as to whether implementing the Dispose method serves a purpose in this code. It never gets referenced by any other class in my project, so should I simply get rid of it or should I make an explicit call to Dispose when releasing the bitmap image?

namespace ImageProcessor
    {
        /// &lt;summary&gt;
        /// A bitmap class that allows fast x, y access
        /// &lt;/summary&gt;
        public unsafe class UnsafeBitmap
        {
            Bitmap source;
            int width;
            BitmapData bmpData = null;
            IntPtr baseLine = IntPtr.Zero;
            BGRA* pCurrentPixel = null;
            Point size;
            internal bool locked = false;

            /// &lt;summary&gt;
            /// Create an instance from an existing bitmap
            /// &lt;/summary&gt;
            /// &lt;param name="src"&gt;The source bitmap&lt;/param&gt;
            public UnsafeBitmap(Bitmap src)
            {
                source = src;
                GraphicsUnit units = GraphicsUnit.Pixel;
                RectangleF boundsF = src.GetBounds(ref units);
                size = new Point((int)boundsF.Width, (int)boundsF.Height);
            }

            public Bitmap Bitmap
            {
                get { return (source); }
                set { source = value; }
            }

            /// &lt;summary&gt;
            /// Lock bitmap data
            /// &lt;/summary&gt;
            public void LockBitmap()
            {
                try
                {
                    GraphicsUnit units = GraphicsUnit.Pixel;
                    RectangleF boundsF = source.GetBounds(ref units);
                    Rectangle bounds = Rectangle.Round(boundsF);

                    // For a standard BMP, each individual scan line needs to be a multiple 
                    // of 4 bytes, so when we have a 24 bit image (3 bytes per pixel),
                    // we need to allow for padding at the end of every scan line
                    // to bring it up to a multiple of 4.
                    width = (int)boundsF.Width * sizeof(BGRA);
                    if (width % 4 != 0)
                        width = 4 * (width / 4 + 1);

                    // Lock the bitmap's bits
                    bmpData = source.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

                    // Get the address of the first line
                    //pBase = (Byte*)bmpData.Scan0.ToPointer();
                    baseLine = bmpData.Scan0;
                    locked = true;
                }
                catch(Exception)
                {
                    throw;
                }
            }

            /// &lt;summary&gt;
            /// Unlock bitmap data
            /// &lt;/summary&gt;

            public void UnlockBitmap()
            {
                try
                {
                    source.UnlockBits(bmpData);
                    bmpData = null;
                    baseLine = IntPtr.Zero;
                    locked = false;
                }
                catch (Exception)
                {
                    throw;
                }
            }

            public void Dispose()
            {
                source.Dispose();
            }

            public Point GetSize
            {
                get { return size; }
            }

            public BGRA* this[int x, int y]
            {
                get
                {
                    return (BGRA*)(baseLine + y * width + x * sizeof(BGRA));
                }
            }
        }


Any other comments are welcome.
I think your Bitmap property shouldn't have a setter. If you use it, you don't dispose the old Bitmap and you don't reset size. Both seem to be erroneous to me.



public Bitmap Bitmap
{
    get { return (source); }
    set { source = value; }
}


Why is source in parentheses?

Also, this could be an auto-property. You would then use the (possibly private) setter instead of the field in the constructor.



catch(Exception)
{
    throw;
}


This doesn't do anything, get rid of it.



public BGRA* this[int x, int y]
{
    get
    {
        return (BGRA*)(baseLine + y * width + x * sizeof(BGRA));
    }
}


If the type of baseLine was BGRA* (and you also changed width not to include the size), then the return statement could be simplified to:

return &amp;baseLine[y * width + x];


Also, I would consider returning BGRA directly, I think that's more natural (assuming doing that doesn't decrease performance noticeably).