if you interested with python, you can read a good doc. at GeospatialPython.com, here.
and clipraster.py source is here.

The Process
Clipping a raster is a series of simple button clicks in high-end
geospatial software packages. In terms of computing, geospatial
images are actually very large, multi-dimensional arrays. Remote
Sensing at its simplest is performing mathematical operations on these
arrays to extract information from the data. Behind the scenes here is
what the software is doing (give or take a few steps):
- Convert the vector shapefile to a matrix which can be used as mask
- Load the geospatial image into a matrix
- Throw out any image cells outside of the shapefile extent
- Set all values outside the shapefile boundary to NODATA (null) values
- OPTIONAL: Perform a histogram stretch on the image for better visualization
- Save the resulting image as a new raster.
i hope it helps you...