public void LockBits() {
			// ====
			// TODO: Use Bitmap.LockPixels, need to cast the pointer though
			// ====
			if( Bitmap == null ) throw new InvalidOperationException( "Underlying bitmap is null." );
			if( data != null ) return;

			data = ByteBuffer.AllocateDirect( Bitmap.Width * Bitmap.Height * 4 );
			Bitmap.CopyPixelsToBuffer( data );
			Scan0 = data.GetDirectBufferAddress();
			scan0Byte = (byte*)Scan0;			
			Stride = Bitmap.Width * 4;
			Width = Bitmap.Width;
			Height = Bitmap.Height;
		}
Example #2
0
        public void LockBits()
        {
            if (Bitmap == null)
            {
                throw new InvalidOperationException("Underlying bitmap is null.");
            }
            if (data != null)
            {
                return;
            }

            data = ByteBuffer.AllocateDirect(Bitmap.Width * Bitmap.Height * 4);
            Bitmap.CopyPixelsToBuffer(data);
            Scan0     = data.GetDirectBufferAddress();
            scan0Byte = (byte *)Scan0;
            Stride    = Bitmap.Width * 4;
            Width     = Bitmap.Width;
            Height    = Bitmap.Height;
        }